本文整理汇总了C++中mozilla::ErrorResult::Failed方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorResult::Failed方法的具体用法?C++ ErrorResult::Failed怎么用?C++ ErrorResult::Failed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla::ErrorResult
的用法示例。
在下文中一共展示了ErrorResult::Failed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDataAtInternal
void
DataTransfer::MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
uint32_t aIndex,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIVariant> data;
aRv = GetDataAtInternal(aFormat, aIndex, &aSubjectPrincipal,
getter_AddRefs(data));
if (aRv.Failed()) {
return;
}
if (!data) {
aRetval.setNull();
return;
}
JS::Rooted<JS::Value> result(aCx);
if (!VariantToJsval(aCx, data, aRetval)) {
aRv = NS_ERROR_FAILURE;
return;
}
}
示例2:
void
nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey,
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
nsDOMTouchList* aTouches,
nsDOMTouchList* aTargetTouches,
nsDOMTouchList* aChangedTouches,
mozilla::ErrorResult& aRv)
{
aRv = nsDOMUIEvent::InitUIEvent(aType,
aCanBubble,
aCancelable,
aView,
aDetail);
if (aRv.Failed()) {
return;
}
static_cast<nsInputEvent*>(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mTouches = aTouches;
mTargetTouches = aTargetTouches;
mChangedTouches = aChangedTouches;
}
示例3: global
void
DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
AnyCallback* aRejectCallback,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv)
{
if (!mPromise) {
mPromise = Promise::Create(DOMEventTargetHelper::GetParentObject(), aRv);
if (aRv.Failed()) {
return;
}
if (mDone) {
// Since we create mPromise lazily, it's possible that the DOMRequest object
// has already fired its success/error event. In that case we should
// manually resolve/reject mPromise here. mPromise will take care of
// calling the callbacks on |promise| as needed.
if (mError) {
mPromise->MaybeRejectBrokenly(mError);
} else {
mPromise->MaybeResolve(mResult);
}
}
}
// Just use the global of the Promise itself as the callee global.
JS::Rooted<JSObject*> global(aCx, mPromise->PromiseObj());
global = js::GetGlobalForObjectCrossCompartment(global);
mPromise->Then(aCx, global, aResolveCallback, aRejectCallback, aRetval, aRv);
}
示例4: WakeLock
already_AddRefed<WakeLock>
PowerManagerService::NewWakeLock(const nsAString& aTopic,
nsIDOMWindow* aWindow,
mozilla::ErrorResult& aRv)
{
nsRefPtr<WakeLock> wakelock = new WakeLock();
aRv = wakelock->Init(aTopic, aWindow);
if (aRv.Failed()) {
return nullptr;
}
return wakelock.forget();
}
示例5: RemoveRequestPromise
void
Cache::RecvAddAllResponse(RequestId aRequestId,
const mozilla::ErrorResult& aError)
{
nsRefPtr<Promise> promise = RemoveRequestPromise(aRequestId);
if (aError.Failed()) {
// TODO: Remove this const_cast (bug 1152078).
// It is safe for now since this ErrorResult is handed off to us by IPDL
// and is thrown into the trash afterwards.
promise->MaybeReject(const_cast<ErrorResult&>(aError));
return;
}
promise->MaybeResolve(JS::UndefinedHandleValue);
}
示例6:
already_AddRefed<Promise>
DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
AnyCallback* aRejectCallback, mozilla::ErrorResult& aRv)
{
if (!mPromise) {
mPromise = Promise::Create(DOMEventTargetHelper::GetParentObject(), aRv);
if (aRv.Failed()) {
return nullptr;
}
if (mDone) {
// Since we create mPromise lazily, it's possible that the DOMRequest object
// has already fired its success/error event. In that case we should
// manually resolve/reject mPromise here. mPromise will take care of
// calling the callbacks on |promise| as needed.
if (mError) {
mPromise->MaybeRejectBrokenly(mError);
} else {
mPromise->MaybeResolve(mResult);
}
}
}
return mPromise->Then(aCx, aResolveCallback, aRejectCallback, aRv);
}