• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NS_DispatchToCurrentThread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NS_DispatchToCurrentThread函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_DispatchToCurrentThread函数的具体用法?C++ NS_DispatchToCurrentThread怎么用?C++ NS_DispatchToCurrentThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NS_DispatchToCurrentThread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:14,代码来源:nsListBoxBodyFrame.cpp


示例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();
    }
  }
}
开发者ID:MekliCZ,项目名称:positron,代码行数:14,代码来源:AndroidSurfaceTexture.cpp


示例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);
  }
}
开发者ID:chenhequn,项目名称:gecko,代码行数:14,代码来源:GMPParent.cpp


示例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);
}
开发者ID:Jaxo,项目名称:releases-mozilla-central,代码行数:14,代码来源:ArchiveRequest.cpp


示例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();
    }
  }
}
开发者ID:multi-sim,项目名称:releases-mozilla-central,代码行数:14,代码来源:ErrorReporter.cpp


示例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;
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:14,代码来源:FTPChannelChild.cpp


示例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);
  }
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:14,代码来源:HttpServer.cpp


示例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);
}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:15,代码来源:TVSource.cpp


示例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);
}
开发者ID:philbooth,项目名称:gecko-dev,代码行数:15,代码来源:TVTuner.cpp


示例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));
}
开发者ID:brendandahl,项目名称:positron,代码行数:16,代码来源:nsNativeAppSupportUnix.cpp


示例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);
}
开发者ID:RobertJGabriel,项目名称:Waterfox,代码行数:16,代码来源:BroadcastChannel.cpp


示例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;
    }
}
开发者ID:70599,项目名称:Waterfox,代码行数:16,代码来源:WebBrowserPersistSerializeParent.cpp


示例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);
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:17,代码来源:nsFormFillController.cpp


示例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);
}
开发者ID:marshall,项目名称:gecko-dev,代码行数:17,代码来源:ProgressTracker.cpp


示例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);
}
开发者ID:Balakrishnan-Vivek,项目名称:gecko-dev,代码行数:17,代码来源:DOMStorageIPC.cpp


示例16: MOZ_ASSERT

bool
BluetoothRequestChild::Recv__delete__(const BluetoothReply& aReply)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(mReplyRunnable);

  nsRefPtr<BluetoothReplyRunnable> replyRunnable;
  mReplyRunnable.swap(replyRunnable);

  if (replyRunnable) {
    // XXXbent Need to fix this, it copies unnecessarily.
    replyRunnable->SetReply(new BluetoothReply(aReply));
    return NS_SUCCEEDED(NS_DispatchToCurrentThread(replyRunnable));
  }

  return true;
}
开发者ID:ethantseng,项目名称:mozilla-central,代码行数:17,代码来源:BluetoothChild.cpp


示例17: GetParent

NS_IMETHODIMP
nsMenuFrame::SelectMenu(PRBool aActivateFlag)
{
  if (mContent) {
    // When a menu opens a submenu, the mouse will often be moved onto a
    // sibling before moving onto an item within the submenu, causing the
    // parent to become deselected. We need to ensure that the parent menu
    // is reselected when an item in the submenu is selected, so navigate up
    // from the item to its popup, and then to the popup above that.
    if (aActivateFlag) {
      nsIFrame* parent = GetParent();
      while (parent) {
        if (parent->GetType() == nsGkAtoms::menuPopupFrame) {
          // a menu is always the direct parent of a menupopup
          parent = parent->GetParent();
          if (parent && parent->GetType() == nsGkAtoms::menuFrame) {
            // a popup however is not necessarily the direct parent of a menu
            nsIFrame* popupParent = parent->GetParent();
            while (popupParent) {
              if (popupParent->GetType() == nsGkAtoms::menuPopupFrame) {
                nsMenuPopupFrame* popup = static_cast<nsMenuPopupFrame *>(popupParent);
                popup->SetCurrentMenuItem(static_cast<nsMenuFrame *>(parent));
                break;
              }
              popupParent = popupParent->GetParent();
            }
          }
          break;
        }
        parent = parent->GetParent();
      }
    }

    // cancel the close timer if selecting a menu within the popup to be closed
    nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
    if (pm)
      pm->CancelMenuTimer(mMenuParent);

    nsCOMPtr<nsIRunnable> event =
      new nsMenuActivateEvent(mContent, PresContext(), aActivateFlag);
    NS_DispatchToCurrentThread(event);
  }

  return NS_OK;
}
开发者ID:mmmulani,项目名称:v8monkey,代码行数:45,代码来源:nsMenuFrame.cpp


示例18: CloseRunnable

void
BroadcastChannel::Close()
{
  if (mState != StateActive) {
    return;
  }

  // We cannot call Shutdown() immediatelly because we could have some
  // postMessage runnable already dispatched. Instead, we change the state to
  // StateClosed and we shutdown the actor asynchrounsly.

  mState = StateClosed;
  RefPtr<CloseRunnable> runnable = new CloseRunnable(this);

  if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) {
    NS_WARNING("Failed to dispatch to the current thread!");
  }
}
开发者ID:heiher,项目名称:gecko-dev,代码行数:18,代码来源:BroadcastChannel.cpp


示例19: nsMenuBarSwitchMenu

NS_IMETHODIMP
nsMenuBarFrame::ChangeMenuItem(nsMenuFrame* aMenuItem,
                               bool aSelectFirstItem)
{
  if (mCurrentMenu == aMenuItem)
    return NS_OK;

  // check if there's an open context menu, we ignore this
  nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
  if (pm && pm->HasContextMenu(nullptr))
    return NS_OK;

  nsIContent* aOldMenu = nullptr, *aNewMenu = nullptr;
  
  // Unset the current child.
  bool wasOpen = false;
  if (mCurrentMenu) {
    wasOpen = mCurrentMenu->IsOpen();
    mCurrentMenu->SelectMenu(false);
    if (wasOpen) {
      nsMenuPopupFrame* popupFrame = mCurrentMenu->GetPopup();
      if (popupFrame)
        aOldMenu = popupFrame->GetContent();
    }
  }

  // set to null first in case the IsAlive check below returns false
  mCurrentMenu = nullptr;

  // Set the new child.
  if (aMenuItem) {
    nsCOMPtr<nsIContent> content = aMenuItem->GetContent();
    aMenuItem->SelectMenu(true);
    mCurrentMenu = aMenuItem;
    if (wasOpen && !aMenuItem->IsDisabled())
      aNewMenu = content;
  }

  // use an event so that hiding and showing can be done synchronously, which
  // avoids flickering
  nsCOMPtr<nsIRunnable> event =
    new nsMenuBarSwitchMenu(GetContent(), aOldMenu, aNewMenu, aSelectFirstItem);
  return NS_DispatchToCurrentThread(event);
}
开发者ID:at13,项目名称:mozilla-central,代码行数:44,代码来源:nsMenuBarFrame.cpp


示例20: TRACE

nsresult
sbFileMetadataService::ProxiedRestartProcessors(PRUint16 aProcessorsToRestart)
{
  TRACE(("%s[%.8x]", __FUNCTION__, this));
  nsresult rv = NS_OK;

  if (!NS_IsMainThread()) {
    LOG(("%s[%.8x] proxying main thread RestartProcessors()", __FUNCTION__, this));
    nsCOMPtr<nsIThread> target;
    rv = NS_GetMainThread(getter_AddRefs(target));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<sbIFileMetadataService> proxy;
    rv = do_GetProxyForObject(target,
                              NS_GET_IID(sbIFileMetadataService),
                              static_cast<sbIFileMetadataService*>(this),
                              NS_PROXY_SYNC | NS_PROXY_ALWAYS,
                              getter_AddRefs(proxy));
    NS_ENSURE_SUCCESS(rv, rv);
    // Can't call ProxiedRestartProcessors via proxy, since it is not
    // an interface method.
    rv = proxy->RestartProcessors(aProcessorsToRestart);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  else {
    NS_ENSURE_STATE(mMainThreadProcessor);
    NS_ENSURE_STATE(mBackgroundThreadProcessor);

    if (aProcessorsToRestart & sbIFileMetadataService::MAIN_THREAD_PROCESSOR) {
      rv = mMainThreadProcessor->Start();
      NS_ENSURE_SUCCESS(rv, rv);
    }

    if (aProcessorsToRestart & sbIFileMetadataService::BACKGROUND_THREAD_PROCESSOR) {
      nsCOMPtr<nsIRunnable> event =
        NS_NEW_RUNNABLE_METHOD(sbBackgroundThreadMetadataProcessor,
                               mBackgroundThreadProcessor.get(),
                               Start);
      NS_DispatchToCurrentThread(event);
    }
  }

  return NS_OK;
}
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:44,代码来源:sbFileMetadataService.cpp



注:本文中的NS_DispatchToCurrentThread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NS_DispatchToMainThread函数代码示例发布时间:2022-05-30
下一篇:
C++ NS_ConvertUTF8toUTF16函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap