コード例 #1
0
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
0
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
0
ファイル: GMPParent.cpp プロジェクト: chenhequn/gecko
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
0
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
0
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
0
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
0
ファイル: HttpServer.cpp プロジェクト: bgrins/gecko-dev
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
0
ファイル: TVSource.cpp プロジェクト: SJasoria/gecko-dev
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
0
ファイル: TVTuner.cpp プロジェクト: philbooth/gecko-dev
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
0
ファイル: TVSource.cpp プロジェクト: SJasoria/gecko-dev
nsresult
TVSource::DispatchCurrentChannelChangedEvent(TVChannel* aChannel)
{
  TVCurrentChannelChangedEventInit init;
  init.mChannel = aChannel;
  nsCOMPtr<nsIDOMEvent> event =
    TVCurrentChannelChangedEvent::Constructor(this,
                                              NS_LITERAL_STRING("currentchannelchanged"),
                                              init);
  nsCOMPtr<nsIRunnable> runnable =
    NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this,
                                             &TVSource::DispatchTVEvent,
                                             event);
  return NS_DispatchToCurrentThread(runnable);
}
コード例 #11
0
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));
}
コード例 #12
0
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);
}
コード例 #13
0
ファイル: GMPParent.cpp プロジェクト: chenhequn/gecko
void
GMPParent::VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder)
{
  MOZ_ASSERT(GMPThread() == NS_GetCurrentThread());

  // If the constructor fails, we'll get called before it's added
  unused << NS_WARN_IF(!mVideoEncoders.RemoveElement(aEncoder));

  if (mVideoDecoders.IsEmpty() &&
      mVideoEncoders.IsEmpty()) {
    // Recv__delete__ is on the stack, don't potentially destroy the top-level actor
    // until after this has completed.
    nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &GMPParent::CloseIfUnused);
    NS_DispatchToCurrentThread(event);
  }
}
コード例 #14
0
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;
    }
}
コード例 #15
0
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);
}
コード例 #16
0
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);
}
コード例 #17
0
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);
}
コード例 #18
0
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;
}
コード例 #19
0
ファイル: nsMenuFrame.cpp プロジェクト: mmmulani/v8monkey
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;
}
コード例 #20
0
ファイル: BroadcastChannel.cpp プロジェクト: heiher/gecko-dev
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!");
  }
}
コード例 #21
0
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);
}
コード例 #22
0
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;
}
コード例 #23
0
// static
void
SetVersionHelper::QueueVersionChange(nsTArray<nsRefPtr<IDBDatabase> >& aDatabases,
                                     void* aClosure)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
  NS_ASSERTION(!aDatabases.IsEmpty(), "Why are we here?");

  SetVersionHelper* helper = static_cast<SetVersionHelper*>(aClosure);
  NS_ASSERTION(helper, "Why don't we have a helper?");

  nsRefPtr<VersionChangeEventsRunnable> eventsRunnable =
    new VersionChangeEventsRunnable(helper->mOpenHelper->Database(),
                                    helper->mOpenRequest,
                                    aDatabases,
                                    helper->mCurrentVersion,
                                    helper->mRequestedVersion);

  NS_DispatchToCurrentThread(eventsRunnable);
}
コード例 #24
0
ファイル: nsWyciwygChannel.cpp プロジェクト: haasn/gecko-dev
NS_IMETHODIMP
nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntry *aCacheEntry,
                                        bool aNew,
                                        nsIApplicationCache* aAppCache,
                                        nsresult aStatus)
{
    LOG(("nsWyciwygChannel::OnCacheEntryAvailable [this=%p entry=%p "
         "new=%d status=%x]\n", this, aCacheEntry, aNew, aStatus));

    // if the channel's already fired onStopRequest,
    // then we should ignore this event.
    if (!mIsPending && !aNew)
        return NS_OK;

    // otherwise, we have to handle this event.
    if (NS_SUCCEEDED(aStatus))
        mCacheEntry = aCacheEntry;
    else if (NS_SUCCEEDED(mStatus))
        mStatus = aStatus;

    nsresult rv = NS_OK;
    if (NS_FAILED(mStatus)) {
        LOG(("channel was canceled [this=%p status=%x]\n", this, mStatus));
        rv = mStatus;
    }
    else if (!aNew) { // advance to the next state...
        rv = ReadFromCache();
    }

    // a failure from Connect means that we have to abort the channel.
    if (NS_FAILED(rv)) {
        CloseCacheEntry(rv);

        if (!aNew) {
            // Since OnCacheEntryAvailable can be called directly from AsyncOpen
            // we must dispatch.
            NS_DispatchToCurrentThread(NS_NewRunnableMethod(
                                           this, &nsWyciwygChannel::NotifyListener));
        }
    }

    return NS_OK;
}
コード例 #25
0
void
BroadcastChannel::Shutdown()
{
  mState = StateClosed;

  // The DTOR of this WorkerHolder will release the worker for us.
  mWorkerHolder = nullptr;

  if (mActor) {
    mActor->SetParent(nullptr);

    RefPtr<TeardownRunnable> runnable = new TeardownRunnable(mActor);
    NS_DispatchToCurrentThread(runnable);

    mActor = nullptr;
  }

  IgnoreKeepAliveIfHasListenersFor(NS_LITERAL_STRING("message"));
}
コード例 #26
0
void
WebGL2Context::EndQuery(GLenum target)
{
    if (IsContextLost())
        return;

    if (!ValidateQueryTarget(target, "endQuery"))
        return;

    WebGLRefPtr<WebGLQuery>& querySlot = GetQuerySlotByTarget(target);
    WebGLQuery* activeQuery = querySlot.get();

    if (!activeQuery || target != activeQuery->mType)
    {
        /* From GLES's EXT_occlusion_query_boolean:
         *     marks the end of the sequence of commands to be tracked for the
         *     query type given by <target>. The active query object for
         *     <target> is updated to indicate that query results are not
         *     available, and the active query object name for <target> is reset
         *     to zero. When the commands issued prior to EndQueryEXT have
         *     completed and a final query result is available, the query object
         *     active when EndQueryEXT is called is updated by the GL. The query
         *     object is updated to indicate that the query results are
         *     available and to contain the query result. If the active query
         *     object name for <target> is zero when EndQueryEXT is called, the
         *     error INVALID_OPERATION is generated.
         */
        ErrorInvalidOperation("endQuery: There is no active query of type %s.",
                              GetQueryTargetEnumString(target));
        return;
    }

    MakeContextCurrent();

    if (target == LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) {
        gl->fEndQuery(LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
    } else {
        gl->fEndQuery(SimulateOcclusionQueryTarget(gl, target));
    }

    UpdateBoundQuery(target, nullptr);
    NS_DispatchToCurrentThread(new WebGLQuery::AvailableRunnable(activeQuery));
}
コード例 #27
0
Tickler::~Tickler()
{
  // non main thread uses of the tickler should hold weak
  // references to it if they must hold a reference at all
  MOZ_ASSERT(NS_IsMainThread());

  // Shutting down a thread can spin the event loop - which is a surprising
  // thing to do from a dtor. Running it on its own event is safer.
  nsRefPtr<nsIRunnable> event = new TicklerThreadDestructor(mThread);
  if (NS_FAILED(NS_DispatchToCurrentThread(event))) {
    mThread->Shutdown();
  }
  mThread = nullptr;

  if (mTimer)
    mTimer->Cancel();
  if (mFD)
    PR_Close(mFD);
}
コード例 #28
0
status_t AudioOffloadPlayer::DoSeek()
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(mSeekTarget.IsValid());
  CHECK(mAudioSink.get());

  AUDIO_OFFLOAD_LOG(LogLevel::Debug,
                    ("DoSeek ( %lld )", mSeekTarget.GetTime().ToMicroseconds()));

  mReachedEOS = false;
  mPositionTimeMediaUs = -1;
  mStartPosUs = mSeekTarget.GetTime().ToMicroseconds();

  if (!mSeekPromise.IsEmpty()) {
    nsCOMPtr<nsIRunnable> nsEvent =
      NewRunnableMethod<MediaDecoderEventVisibility>(
        mObserver,
        &MediaDecoder::SeekingStarted,
        mSeekTarget.mEventVisibility);
    NS_DispatchToCurrentThread(nsEvent);
  }

  if (mPlaying) {
    mAudioSink->Pause();
    mAudioSink->Flush();
    mAudioSink->Start();

  } else {
    if (mStarted) {
      mAudioSink->Flush();
    }

    if (!mSeekPromise.IsEmpty()) {
      AUDIO_OFFLOAD_LOG(LogLevel::Debug, ("Fake seek complete during pause"));
      // We do not reset mSeekTarget here.
      MediaDecoder::SeekResolveValue val(mReachedEOS, mSeekTarget.mEventVisibility);
      mSeekPromise.Resolve(val, __func__);
    }
  }

  return OK;
}
コード例 #29
0
ファイル: GMPContentParent.cpp プロジェクト: heiher/gecko-dev
void
GMPContentParent::CloseIfUnused()
{
  if (mVideoDecoders.IsEmpty() &&
      mVideoEncoders.IsEmpty() &&
      mChromiumCDMs.IsEmpty() &&
      mCloseBlockerCount == 0) {
    RefPtr<GMPContentParent> toClose;
    if (mParent) {
      toClose = mParent->ForgetGMPContentParent();
    } else {
      toClose = this;
      RefPtr<GeckoMediaPluginServiceChild> gmp(
        GeckoMediaPluginServiceChild::GetSingleton());
      gmp->RemoveGMPContentParent(toClose);
    }
    NS_DispatchToCurrentThread(NewRunnableMethod(
      "gmp::GMPContentParent::Close", toClose, &GMPContentParent::Close));
  }
}
コード例 #30
0
void
FileSystemTaskChildBase::Start()
{
  mFileSystem->AssertIsOnOwningThread();

  if (HasError()) {
    // In this case we don't want to use IPC at all.
    RefPtr<ErrorRunnable> runnable = new ErrorRunnable(this);
    nsresult rv = NS_DispatchToCurrentThread(runnable);
    NS_WARN_IF(NS_FAILED(rv));
    return;
  }

  if (mFileSystem->IsShutdown()) {
    return;
  }

  nsAutoString serialization;
  mFileSystem->SerializeDOMPath(serialization);

  ErrorResult rv;
  FileSystemParams params = GetRequestParams(serialization, rv);
  if (NS_WARN_IF(rv.Failed())) {
    rv.SuppressException();
    return;
  }

  // Retain a reference so the task object isn't deleted without IPDL's
  // knowledge. The reference will be released by
  // mozilla::ipc::BackgroundChildImpl::DeallocPFileSystemRequestChild.
  NS_ADDREF_THIS();

  // If we are here, PBackground must be up and running, because Start() is
  // called only by FileSystemPermissionRequest, and that class takes care of
  // PBackground initialization.
  PBackgroundChild* actor =
    mozilla::ipc::BackgroundChild::GetForCurrentThread();
  MOZ_ASSERT(actor);

  actor->SendPFileSystemRequestConstructor(this, params);
}