本文整理汇总了C++中NS_DispatchToCurrentThread函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_DispatchToCurrentThread函数的具体用法?C++ NS_DispatchToCurrentThread怎么用?C++ NS_DispatchToCurrentThread使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_DispatchToCurrentThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsPositionChangedEvent
nsresult
nsListBoxBodyFrame::InternalPositionChanged(bool aUp, PRInt32 aDelta)
{
nsRefPtr<nsPositionChangedEvent> ev =
new nsPositionChangedEvent(this, aUp, aDelta);
nsresult rv = NS_DispatchToCurrentThread(ev);
if (NS_SUCCEEDED(rv)) {
if (!mPendingPositionChangeEvents.AppendElement(ev)) {
rv = NS_ERROR_OUT_OF_MEMORY;
ev->Revoke();
}
}
return rv;
}
示例2: NS_NewRunnableMethod
void
AndroidSurfaceTexture::NotifyFrameAvailable()
{
if (mFrameAvailableCallback) {
// Proxy to main thread if we aren't on it
if (!NS_IsMainThread()) {
// Proxy to main thread
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable);
NS_DispatchToCurrentThread(event);
} else {
mFrameAvailableCallback->Run();
}
}
}
示例3: MOZ_ASSERT
void
GMPParent::DecryptorDestroyed(GMPDecryptorParent* aSession)
{
MOZ_ASSERT(GMPThread() == NS_GetCurrentThread());
MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession));
// Recv__delete__ is on the stack, don't potentially destroy the top-level actor
// until after this has completed.
if (mDecryptors.IsEmpty()) {
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &GMPParent::CloseIfUnused);
NS_DispatchToCurrentThread(event);
}
}
示例4: DOMRequest
ArchiveRequest::ArchiveRequest(nsIDOMWindow* aWindow,
ArchiveReader* aReader)
: DOMRequest(aWindow),
mArchiveReader(aReader)
{
MOZ_ASSERT(aReader);
MOZ_COUNT_CTOR(ArchiveRequest);
nsLayoutStatics::AddRef();
/* An event to make this request asynchronous: */
nsRefPtr<ArchiveRequestEvent> event = new ArchiveRequestEvent(this);
NS_DispatchToCurrentThread(event);
}
示例5:
ErrorReporter::~ErrorReporter()
{
// Schedule deferred cleanup for cached data. We want to strike a
// balance between performance and memory usage, so we only allow
// short-term caching.
if (sSpecCache && sSpecCache->IsInUse() && !sSpecCache->IsPending()) {
if (NS_FAILED(NS_DispatchToCurrentThread(sSpecCache))) {
// Peform the "deferred" cleanup immediately if the dispatch fails.
sSpecCache->Run();
} else {
sSpecCache->SetPending();
}
}
}
示例6: NS_NewRunnableMethod
nsresult
FTPChannelChild::AsyncCall(void (FTPChannelChild::*funcPtr)(),
nsRunnableMethod<FTPChannelChild> **retval)
{
nsresult rv;
nsRefPtr<nsRunnableMethod<FTPChannelChild> > event = NS_NewRunnableMethod(this, funcPtr);
rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv) && retval) {
*retval = event;
}
return rv;
}
示例7: NS_NewRunnableFunction
void
HttpServer::TransportProvider::MaybeNotify()
{
if (mTransport && mListener) {
RefPtr<TransportProvider> self = this;
nsCOMPtr<nsIRunnable> event = NS_NewRunnableFunction(
"dom::HttpServer::TransportProvider::MaybeNotify", [self, this]() {
DebugOnly<nsresult> rv =
mListener->OnTransportAvailable(mTransport, mInput, mOutput);
MOZ_ASSERT(NS_SUCCEEDED(rv));
});
NS_DispatchToCurrentThread(event);
}
}
示例8: NS_LITERAL_STRING
nsresult
TVSource::DispatchEITBroadcastedEvent(const Sequence<OwningNonNull<TVProgram>>& aPrograms)
{
TVEITBroadcastedEventInit init;
init.mPrograms = aPrograms;
nsCOMPtr<nsIDOMEvent> event =
TVEITBroadcastedEvent::Constructor(this,
NS_LITERAL_STRING("eitbroadcasted"),
init);
nsCOMPtr<nsIRunnable> runnable =
NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this,
&TVSource::DispatchTVEvent,
event);
return NS_DispatchToCurrentThread(runnable);
}
示例9: NS_LITERAL_STRING
nsresult
TVTuner::DispatchCurrentSourceChangedEvent(TVSource* aSource)
{
TVCurrentSourceChangedEventInit init;
init.mSource = aSource;
nsCOMPtr<nsIDOMEvent> event =
TVCurrentSourceChangedEvent::Constructor(this,
NS_LITERAL_STRING("currentsourcechanged"),
init);
nsCOMPtr<nsIRunnable> runnable =
NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this,
&TVTuner::DispatchTVEvent,
event);
return NS_DispatchToCurrentThread(runnable);
}
示例10: NS_DispatchToCurrentThread
void
nsNativeAppSupportUnix::InteractCB(SmcConn smc_conn, SmPointer client_data)
{
nsNativeAppSupportUnix *self =
static_cast<nsNativeAppSupportUnix *>(client_data);
self->SetClientState(STATE_INTERACTING);
// We do this asynchronously, as we spin the event loop recursively if
// a dialog is displayed. If we do this synchronously, we don't finish
// processing the current ICE event whilst the dialog is displayed, which
// means we won't process any more. libsm hates us if we do the InteractDone
// with a pending ShutdownCancelled, and we would certainly like to handle Die
// whilst a dialog is displayed
NS_DispatchToCurrentThread(NewRunnableMethod(self, &nsNativeAppSupportUnix::DoInteract));
}
示例11: BCPostMessageRunnable
void
BroadcastChannel::PostMessageData(BroadcastChannelMessage* aData)
{
if (mActor) {
nsRefPtr<BCPostMessageRunnable> runnable =
new BCPostMessageRunnable(mActor, aData);
if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) {
NS_WARNING("Failed to dispatch to the current thread!");
}
return;
}
mPendingMessages.AppendElement(aData);
}
示例12: MOZ_ASSERT
void
WebBrowserPersistSerializeParent::ActorDestroy(ActorDestroyReason aWhy)
{
if (mFinish) {
MOZ_ASSERT(aWhy != Deletion);
// See comment in WebBrowserPersistDocumentParent::ActorDestroy
// (or bug 1202887) for why this is deferred.
nsCOMPtr<nsIRunnable> errorLater = NS_NewRunnableMethodWithArgs
<nsCOMPtr<nsIWebBrowserPersistDocument>, nsCOMPtr<nsIOutputStream>,
nsCString, nsresult>
(mFinish, &nsIWebBrowserPersistWriteCompletion::OnFinish,
mDocument, mStream, EmptyCString(), NS_ERROR_FAILURE);
NS_DispatchToCurrentThread(errorLater);
mFinish = nullptr;
}
}
示例13: do_GetService
void nsFormFillController::RevalidateDataList()
{
nsresult rv;
nsCOMPtr <nsIInputListAutoComplete> inputListAutoComplete =
do_GetService("@mozilla.org/satchel/inputlist-autocomplete;1", &rv);
nsCOMPtr<nsIAutoCompleteResult> result;
rv = inputListAutoComplete->AutoCompleteSearch(mLastSearchResult,
mLastSearchString,
mFocusedInput,
getter_AddRefs(result));
nsCOMPtr<nsIRunnable> event =
new UpdateSearchResultRunnable(mLastListener, this, result);
NS_DispatchToCurrentThread(event);
}
示例14: MOZ_ASSERT
void
ProgressTracker::NotifyCurrentState(imgRequestProxy* proxy)
{
MOZ_ASSERT(NS_IsMainThread(), "imgRequestProxy is not threadsafe");
#ifdef PR_LOGGING
nsRefPtr<ImageURL> uri;
proxy->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(GetImgLog(), "ProgressTracker::NotifyCurrentState", "uri", spec.get());
#endif
proxy->SetNotificationsDeferred(true);
nsCOMPtr<nsIRunnable> ev = new AsyncNotifyCurrentStateRunnable(this, proxy);
NS_DispatchToCurrentThread(ev);
}
示例15: mIPCOpen
DOMStorageDBParent::DOMStorageDBParent()
: mIPCOpen(false)
{
DOMStorageObserver* observer = DOMStorageObserver::Self();
if (observer) {
observer->AddSink(this);
}
// We are always open by IPC only
AddIPDLReference();
// Cannot send directly from here since the channel
// is not completely built at this moment.
nsRefPtr<SendInitialChildDataRunnable> r =
new SendInitialChildDataRunnable(this);
NS_DispatchToCurrentThread(r);
}