Beispiel #1
0
void
CacheStorage::ActorCreated(PBackgroundChild* aActor)
{
  NS_ASSERT_OWNINGTHREAD(CacheStorage);
  MOZ_ASSERT(aActor);

  if (NS_WARN_IF(mFeature && mFeature->Notified())) {
    ActorFailed();
    return;
  }

  // Feature ownership is passed to the CacheStorageChild actor and any actors
  // it may create.  The Feature will keep the worker thread alive until the
  // actors can gracefully shutdown.
  CacheStorageChild* newActor = new CacheStorageChild(this, mFeature);
  PCacheStorageChild* constructedActor =
    aActor->SendPCacheStorageConstructor(newActor, mNamespace, *mPrincipalInfo);

  if (NS_WARN_IF(!constructedActor)) {
    ActorFailed();
    return;
  }

  mFeature = nullptr;

  MOZ_ASSERT(constructedActor == newActor);
  mActor = newActor;

  MaybeRunPendingRequests();
  MOZ_ASSERT(mPendingRequests.IsEmpty());
}
Beispiel #2
0
CacheStorage::CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
                           const PrincipalInfo& aPrincipalInfo, Feature* aFeature)
  : mNamespace(aNamespace)
  , mGlobal(aGlobal)
  , mPrincipalInfo(MakeUnique<PrincipalInfo>(aPrincipalInfo))
  , mFeature(aFeature)
  , mActor(nullptr)
  , mStatus(NS_OK)
{
  MOZ_ASSERT(mGlobal);

  // If the PBackground actor is already initialized then we can
  // immediately use it
  PBackgroundChild* actor = BackgroundChild::GetForCurrentThread();
  if (actor) {
    ActorCreated(actor);
    return;
  }

  // Otherwise we must begin the PBackground initialization process and
  // wait for the async ActorCreated() callback.
  MOZ_ASSERT(NS_IsMainThread());
  bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
  if (NS_WARN_IF(!ok)) {
    ActorFailed();
  }
}
Beispiel #3
0
void
CacheStorage::DestroyInternal(CacheStorageChild* aActor)
{
  NS_ASSERT_OWNINGTHREAD(CacheStorage);
  MOZ_ASSERT(mActor);
  MOZ_ASSERT(mActor == aActor);
  mActor->ClearListener();
  mActor = nullptr;

  // Note that we will never get an actor again in case another request is
  // made before this object is destructed.
  ActorFailed();
}
void
GamepadServiceTest::ActorCreated(PBackgroundChild* aActor)
{
  MOZ_ASSERT(aActor);
  // If we are shutting down, we don't need to create the
  // IPDL child/parent pair anymore.
  if (mShuttingDown) {
    // mPendingOperations should be cleared in
    // DestroyPBackgroundActor()
    MOZ_ASSERT(mPendingOperations.IsEmpty());
    return;
  }

  mChild = new GamepadTestChannelChild();
  PGamepadTestChannelChild* initedChild =
    aActor->SendPGamepadTestChannelConstructor(mChild);
  if (NS_WARN_IF(!initedChild)) {
    ActorFailed();
    return;
  }
  FlushPendingOperations();
}