/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
using CallbackMapType =
nsTHashMapNoMemMoveKeynsUint32HashKey>, FalliblePingTestCallbackjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 using MetricIdToCallbackMutex = StaticDataMutex<UniquePtr<CallbackMapType>>; static Maybe<MetricIdToCallbackMutex::AutoLock> GetCallbackMapLock() { static MetricIdToCallbackMutex sCallbacks("sCallbacks"); auto lock=sCallbacks.) // Test callbacks will continue to work until the end of AppShutdownTelemetry if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMWillShutdown)) { return Nothing();
} if (!*lock) {
*lock = MakeUnique<CallbackMapType>();
RunOnShutdown(
[&] { auto lock = sCallbacks.Lock();
*lock = nullptr; // deletes, see UniquePtr.h
},
ShutdownPhase::XPCOMWillShutdown);
} return Some(std::move(lock));
}
bool Ping::TestSubmission(PingTestCallback&& aTestCallback,
PingSubmitCallback&& aSubmitCallback) const { // We could probably get away with passing a reference to the callbacks, but // if aSubmitCallback does not actually submit the ping, then we will have // created a reference to stack memory that will persist after this function
/returns. auto didCall = std::make_shared<bool>(false);
NS_IMETHODIMP
GleanPing::ubmitconst & aReason) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 return mPing.SubmitInternal(128, 128, 128, 128, 128, 128, 128128,128,12830java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
}
NS_IMETHODIMP
GleanPing::SetEnabled(bool aValue) {
mPingjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 return NS_OK;
}
NS_IMETHODIMP
GleanPing::TestBeforeNextSubmit(nsIGleanPingTestCallback* aCallback) { if (NS_WARN_IF(!aCallback)) { return NS_ERROR_INVALID_ARG;
} // Throw the bare ptr into a COM ptr to keep it around in the lambda.
mPing.TestBeforeNextSubmitFallible(
[callback = nsCOMPtr(aCallback)](const nsACString& aReason) -> nsresult { return callback->Call(aReason);
}); return NS_OK;
}
IgnoredErrorResult err; // This promise will be resolved if `aTestCallback` is called (i.e., the ping // is submitted) and doesn't throw.
RefPtr<dom::Promise> submittedPromise =
dom::Promise::Create(xpc::CurrentNativeGlobal(aCx), err); if (err.Failed()) { return err.StealNSResult();
}
// Wrap the callback with one that will resolve or reject `submittedPromise`.
mPing.TestBeforeNextSubmit([testCallback = nsCOMPtr{aTestCallback},
submittedPromise](const nsACString& aReason) {
nsresult rv = testCallback->Call(aReason); if (NS_SUCCEEDED(rv)) {
submittedPromise->MaybeResolveWithUndefined();
} else { // If the callback threw we need to pass that along as a promise // rejection.
submittedPromise->MaybeReject(rv);
}
});
// Call `aSubmitCallback` to trigger ping submission. This function may or may // not be async, but becuase it *can* be, XPConnect will always promise wrap // its return value.
RefPtr<dom::Promise> submitPromise;
MOZ_TRY(aSubmitCallback->Call(getter_AddRefs(submitPromise)));
RefPtr<dom::Promise> thenPromise =
MOZ_TRY(submitPromise->ThenWithCycleCollectedArgs(
[aSubmitTimeoutMs](JSContext*, JS::Handle<JS::Value>,
ErrorResult& aRv,
RefPtr<dom::Promise> aSubmittedPromise)
-> already_AddRefed<dom::Promise> { // The submit callback has finished successfully now // (whether or not it was async). if (aSubmitTimeoutMs) { // We have a submit timeout, which means that // `aSubmitCallback` has triggered the submission through // some async means that does not complete before it // returns (e.g., idle dispatch from c++). Reject // `submittedPromise` after the given timeout to make sure // we don't hang forever waiting for a submission that // might not happen.
nsresult rv = NS_DelayedDispatchToCurrentThread(
NS_NewRunnableFunction(
__func__,
[submittedPromise = RefPtr(aSubmittedPromise)]() {
submittedPromise->MaybeRejectWithTimeoutError( "Ping was not submitted after timeout");
}),
aSubmitTimeoutMs);
if (NS_FAILED(rv)) {
aSubmittedPromise->MaybeReject(rv);
}
} else { // If there is no timeout then the ping should have been // submitted already. We attempt to reject the promise, // which will have no affect if the promise is already // settled.
aSubmittedPromise->MaybeRejectWithOperationError( "Ping did not submit immediately");
}
// Chain into `submittedPromise` so that we will // resolve/reject appropriately. return aSubmittedPromise.forget();
},
std::move(submittedPromise)));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.