Backed out changeset 1c5d78c7ba43 (bug 1269154) for bustage on a CLOSED TREE

--HG--
rename : dom/cache/CacheWorkerHolder.cpp => dom/cache/Feature.cpp
rename : dom/cache/CacheWorkerHolder.h => dom/cache/Feature.h
rename : dom/workers/WorkerHolder.h => dom/workers/WorkerFeature.h
extra : rebase_source : 49f9e9ce0500ac441fe97878cf9308804926544f
This commit is contained in:
Carsten "Tomcat" Book 2016-06-23 10:13:54 +02:00
Родитель 8f44efbeeb
Коммит 47aeb86e2c
52 изменённых файлов: 434 добавлений и 493 удалений

Просмотреть файл

@ -604,7 +604,7 @@ FileReader::OnInputStreamReady(nsIAsyncInputStream* aStream)
// We use this class to decrease the busy counter at the end of this method.
// In theory we can do it immediatelly but, for debugging reasons, we want to
// be 100% sure we have a workerHolder when OnLoadEnd() is called.
// be 100% sure we have a feature when OnLoadEnd() is called.
FileReaderDecreaseBusyCounter RAII(this);
uint64_t aCount;
@ -701,7 +701,7 @@ nsresult
FileReader::IncreaseBusyCounter()
{
if (mWorkerPrivate && mBusyCount++ == 0 &&
!HoldWorker(mWorkerPrivate)) {
!mWorkerPrivate->AddFeature(this)) {
return NS_ERROR_FAILURE;
}
@ -713,7 +713,7 @@ FileReader::DecreaseBusyCounter()
{
MOZ_ASSERT_IF(mWorkerPrivate, mBusyCount);
if (mWorkerPrivate && --mBusyCount == 0) {
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
}
}
@ -742,7 +742,7 @@ FileReader::Shutdown()
}
if (mWorkerPrivate && mBusyCount != 0) {
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
mWorkerPrivate = nullptr;
mBusyCount = 0;
}

Просмотреть файл

@ -15,7 +15,7 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsWeakReference.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#define NS_PROGRESS_EVENT_INTERVAL 50
@ -41,7 +41,7 @@ class FileReader final : public DOMEventTargetHelper,
public nsSupportsWeakReference,
public nsIInputStreamCallback,
public nsITimerCallback,
public workers::WorkerHolder
public workers::WorkerFeature
{
friend class FileReaderDecreaseBusyCounter;
@ -106,7 +106,7 @@ public:
ReadFileContent(aBlob, EmptyString(), FILE_AS_BINARY, aRv);
}
// WorkerHolder
// WorkerFeature
bool Notify(workers::Status) override;
private:
@ -190,7 +190,7 @@ private:
uint64_t mBusyCount;
// Kept alive with a WorkerHolder.
// Kept alive with a WorkerFeature.
workers::WorkerPrivate* mWorkerPrivate;
};

Просмотреть файл

@ -99,7 +99,7 @@ public:
, mInnerWindowID(0)
, mWorkerPrivate(nullptr)
#ifdef DEBUG
, mHasWorkerHolderRegistered(false)
, mHasFeatureRegistered(false)
#endif
, mIsMainThread(true)
, mMutex("WebSocketImpl::mMutex")
@ -166,8 +166,8 @@ public:
void AddRefObject();
void ReleaseObject();
bool RegisterWorkerHolder();
void UnregisterWorkerHolder();
bool RegisterFeature();
void UnregisterFeature();
nsresult CancelInternal();
@ -213,24 +213,24 @@ public:
uint64_t mInnerWindowID;
WorkerPrivate* mWorkerPrivate;
nsAutoPtr<WorkerHolder> mWorkerHolder;
nsAutoPtr<WorkerFeature> mWorkerFeature;
#ifdef DEBUG
// This is protected by mutex.
bool mHasWorkerHolderRegistered;
bool mHasFeatureRegistered;
bool HasWorkerHolderRegistered()
bool HasFeatureRegistered()
{
MOZ_ASSERT(mWebSocket);
MutexAutoLock lock(mWebSocket->mMutex);
return mHasWorkerHolderRegistered;
return mHasFeatureRegistered;
}
void SetHasWorkerHolderRegistered(bool aValue)
void SetHasFeatureRegistered(bool aValue)
{
MOZ_ASSERT(mWebSocket);
MutexAutoLock lock(mWebSocket->mMutex);
mHasWorkerHolderRegistered = aValue;
mHasFeatureRegistered = aValue;
}
#endif
@ -489,7 +489,7 @@ WebSocketImpl::CloseConnection(uint16_t aReasonCode,
// If this method is called because the worker is going away, we will not
// receive the OnStop() method and we have to disconnect the WebSocket and
// release the WorkerHolder.
// release the WorkerFeature.
MaybeDisconnect md(this);
uint16_t readyState = mWebSocket->ReadyState();
@ -610,7 +610,7 @@ WebSocketImpl::Disconnect()
AssertIsOnTargetThread();
// Disconnect can be called from some control event (such as Notify() of
// WorkerHolder). This will be schedulated before any other sync/async
// WorkerFeature). This will be schedulated before any other sync/async
// runnable. In order to prevent some double Disconnect() calls, we use this
// boolean.
mDisconnectingOrDisconnected = true;
@ -640,8 +640,8 @@ WebSocketImpl::Disconnect()
mWebSocket->DontKeepAliveAnyMore();
mWebSocket->mImpl = nullptr;
if (mWorkerPrivate && mWorkerHolder) {
UnregisterWorkerHolder();
if (mWorkerPrivate && mWorkerFeature) {
UnregisterFeature();
}
// We want to release the WebSocket in the correct thread.
@ -1262,9 +1262,9 @@ WebSocket::ConstructorCommon(const GlobalObject& aGlobal,
aUrl, protocolArray, EmptyCString(),
0, 0, aRv, &connectionFailed);
} else {
// In workers we have to keep the worker alive using a workerHolder in order
// to dispatch messages correctly.
if (!webSocket->mImpl->RegisterWorkerHolder()) {
// In workers we have to keep the worker alive using a feature in order to
// dispatch messages correctly.
if (!webSocket->mImpl->RegisterFeature()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -2204,10 +2204,10 @@ WebSocket::DontKeepAliveAnyMore()
namespace {
class WebSocketWorkerHolder final : public WorkerHolder
class WebSocketWorkerFeature final : public WorkerFeature
{
public:
explicit WebSocketWorkerHolder(WebSocketImpl* aWebSocketImpl)
explicit WebSocketWorkerFeature(WebSocketImpl* aWebSocketImpl)
: mWebSocketImpl(aWebSocketImpl)
{
}
@ -2250,39 +2250,39 @@ WebSocketImpl::ReleaseObject()
}
bool
WebSocketImpl::RegisterWorkerHolder()
WebSocketImpl::RegisterFeature()
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerHolder);
mWorkerHolder = new WebSocketWorkerHolder(this);
MOZ_ASSERT(!mWorkerFeature);
mWorkerFeature = new WebSocketWorkerFeature(this);
if (NS_WARN_IF(!mWorkerHolder->HoldWorker(mWorkerPrivate))) {
mWorkerHolder = nullptr;
if (!mWorkerPrivate->AddFeature(mWorkerFeature)) {
NS_WARNING("Failed to register a feature.");
mWorkerFeature = nullptr;
return false;
}
#ifdef DEBUG
SetHasWorkerHolderRegistered(true);
SetHasFeatureRegistered(true);
#endif
return true;
}
void
WebSocketImpl::UnregisterWorkerHolder()
WebSocketImpl::UnregisterFeature()
{
MOZ_ASSERT(mDisconnectingOrDisconnected);
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mWorkerHolder);
// The DTOR of this WorkerHolder will release the worker for us.
mWorkerHolder = nullptr;
MOZ_ASSERT(mWorkerFeature);
mWorkerPrivate->RemoveFeature(mWorkerFeature);
mWorkerFeature = nullptr;
mWorkerPrivate = nullptr;
#ifdef DEBUG
SetHasWorkerHolderRegistered(false);
SetHasFeatureRegistered(false);
#endif
}
@ -2842,7 +2842,7 @@ WebSocketImpl::Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
MOZ_ASSERT(mWorkerPrivate);
#ifdef DEBUG
MOZ_ASSERT(HasWorkerHolderRegistered());
MOZ_ASSERT(HasFeatureRegistered());
#endif
// If the target is a worker, we have to use a custom WorkerRunnableDispatcher

Просмотреть файл

@ -3298,7 +3298,7 @@ namespace {
// This runnable is used to write a deprecation message from a worker to the
// console running on the main-thread.
class DeprecationWarningRunnable final : public Runnable
, public WorkerHolder
, public WorkerFeature
{
WorkerPrivate* mWorkerPrivate;
nsIDocument::DeprecatedOperations mOperation;
@ -3315,12 +3315,12 @@ public:
void
Dispatch()
{
if (NS_WARN_IF(!HoldWorker(mWorkerPrivate))) {
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
return;
}
if (NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(this)))) {
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
return;
}
}
@ -3351,12 +3351,12 @@ private:
window->GetExtantDoc()->WarnOnceAbout(mOperation);
}
ReleaseWorkerHolder();
ReleaseWorker();
return NS_OK;
}
void
ReleaseWorkerHolder()
ReleaseWorker()
{
class ReleaseRunnable final : public MainThreadWorkerRunnable
{
@ -3375,7 +3375,7 @@ private:
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
mRunnable->ReleaseWorker();
aWorkerPrivate->RemoveFeature(mRunnable);
return true;
}
};

Просмотреть файл

@ -266,15 +266,15 @@ private:
NS_IMPL_ISUPPORTS(TeardownRunnable, nsICancelableRunnable, nsIRunnable)
class BroadcastChannelWorkerHolder final : public workers::WorkerHolder
class BroadcastChannelFeature final : public workers::WorkerFeature
{
BroadcastChannel* mChannel;
public:
explicit BroadcastChannelWorkerHolder(BroadcastChannel* aChannel)
explicit BroadcastChannelFeature(BroadcastChannel* aChannel)
: mChannel(aChannel)
{
MOZ_COUNT_CTOR(BroadcastChannelWorkerHolder);
MOZ_COUNT_CTOR(BroadcastChannelFeature);
}
virtual bool Notify(workers::Status aStatus) override
@ -287,9 +287,9 @@ public:
}
private:
~BroadcastChannelWorkerHolder()
~BroadcastChannelFeature()
{
MOZ_COUNT_DTOR(BroadcastChannelWorkerHolder);
MOZ_COUNT_DTOR(BroadcastChannelFeature);
}
};
@ -300,7 +300,7 @@ BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow,
const nsACString& aOrigin,
const nsAString& aChannel)
: DOMEventTargetHelper(aWindow)
, mWorkerHolder(nullptr)
, mWorkerFeature(nullptr)
, mPrincipalInfo(new PrincipalInfo(aPrincipalInfo))
, mOrigin(aOrigin)
, mChannel(aChannel)
@ -314,7 +314,7 @@ BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow,
BroadcastChannel::~BroadcastChannel()
{
Shutdown();
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mWorkerFeature);
}
JSObject*
@ -406,9 +406,10 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
obs->AddObserver(bc, "inner-window-destroyed", false);
}
} else {
bc->mWorkerHolder = new BroadcastChannelWorkerHolder(bc);
if (NS_WARN_IF(!bc->mWorkerHolder->HoldWorker(workerPrivate))) {
bc->mWorkerHolder = nullptr;
bc->mWorkerFeature = new BroadcastChannelFeature(bc);
if (NS_WARN_IF(!workerPrivate->AddFeature(bc->mWorkerFeature))) {
NS_WARNING("Failed to register the BroadcastChannel worker feature.");
bc->mWorkerFeature = nullptr;
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -527,8 +528,11 @@ BroadcastChannel::Shutdown()
{
mState = StateClosed;
// The DTOR of this WorkerHolder will release the worker for us.
mWorkerHolder = nullptr;
if (mWorkerFeature) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
workerPrivate->RemoveFeature(mWorkerFeature);
mWorkerFeature = nullptr;
}
if (mActor) {
mActor->SetParent(nullptr);

Просмотреть файл

@ -26,7 +26,7 @@ class PrincipalInfo;
namespace dom {
namespace workers {
class WorkerHolder;
class WorkerFeature;
} // namespace workers
class BroadcastChannelChild;
@ -110,7 +110,7 @@ private:
RefPtr<BroadcastChannelChild> mActor;
nsTArray<RefPtr<BroadcastChannelMessage>> mPendingMessages;
nsAutoPtr<workers::WorkerHolder> mWorkerHolder;
nsAutoPtr<workers::WorkerFeature> mWorkerFeature;
nsAutoPtr<PrincipalInfo> mPrincipalInfo;

40
dom/cache/ActorChild.cpp поставляемый
Просмотреть файл

@ -6,7 +6,7 @@
#include "mozilla/dom/cache/ActorChild.h"
#include "mozilla/dom/cache/CacheWorkerHolder.h"
#include "mozilla/dom/cache/Feature.h"
#include "nsThreadUtils.h"
namespace mozilla {
@ -14,42 +14,42 @@ namespace dom {
namespace cache {
void
ActorChild::SetWorkerHolder(CacheWorkerHolder* aWorkerHolder)
ActorChild::SetFeature(Feature* aFeature)
{
// Some of the Cache actors can have multiple DOM objects associated with
// them. In this case the workerHolder will be added multiple times. This is
// permitted, but the workerHolder should be the same each time.
if (mWorkerHolder) {
MOZ_ASSERT(mWorkerHolder == aWorkerHolder);
// them. In this case the feature will be added multiple times. This is
// permitted, but the feature should be the same each time.
if (mFeature) {
MOZ_ASSERT(mFeature == aFeature);
return;
}
mWorkerHolder = aWorkerHolder;
if (mWorkerHolder) {
mWorkerHolder->AddActor(this);
mFeature = aFeature;
if (mFeature) {
mFeature->AddActor(this);
}
}
void
ActorChild::RemoveWorkerHolder()
ActorChild::RemoveFeature()
{
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
if (mWorkerHolder) {
mWorkerHolder->RemoveActor(this);
mWorkerHolder = nullptr;
MOZ_ASSERT_IF(!NS_IsMainThread(), mFeature);
if (mFeature) {
mFeature->RemoveActor(this);
mFeature = nullptr;
}
}
CacheWorkerHolder*
ActorChild::GetWorkerHolder() const
Feature*
ActorChild::GetFeature() const
{
return mWorkerHolder;
return mFeature;
}
bool
ActorChild::WorkerHolderNotified() const
ActorChild::FeatureNotified() const
{
return mWorkerHolder && mWorkerHolder->Notified();
return mFeature && mFeature->Notified();
}
ActorChild::ActorChild()
@ -58,7 +58,7 @@ ActorChild::ActorChild()
ActorChild::~ActorChild()
{
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mFeature);
}
} // namespace cache

14
dom/cache/ActorChild.h поставляемый
Просмотреть файл

@ -13,7 +13,7 @@ namespace mozilla {
namespace dom {
namespace cache {
class CacheWorkerHolder;
class Feature;
class ActorChild
{
@ -22,23 +22,23 @@ public:
StartDestroy() = 0;
void
SetWorkerHolder(CacheWorkerHolder* aWorkerHolder);
SetFeature(Feature* aFeature);
void
RemoveWorkerHolder();
RemoveFeature();
CacheWorkerHolder*
GetWorkerHolder() const;
Feature*
GetFeature() const;
bool
WorkerHolderNotified() const;
FeatureNotified() const;
protected:
ActorChild();
~ActorChild();
private:
RefPtr<CacheWorkerHolder> mWorkerHolder;
RefPtr<Feature> mFeature;
};
} // namespace cache

21
dom/cache/Cache.cpp поставляемый
Просмотреть файл

@ -15,7 +15,7 @@
#include "mozilla/dom/CacheBinding.h"
#include "mozilla/dom/cache/AutoUtils.h"
#include "mozilla/dom/cache/CacheChild.h"
#include "mozilla/dom/cache/CacheWorkerHolder.h"
#include "mozilla/dom/cache/Feature.h"
#include "mozilla/dom/cache/ReadStream.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Preferences.h"
@ -82,21 +82,21 @@ IsValidPutRequestMethod(const RequestOrUSVString& aRequest, ErrorResult& aRv)
} // namespace
// Helper class to wait for Add()/AddAll() fetch requests to complete and
// then perform a PutAll() with the responses. This class holds a WorkerHolder
// then perform a PutAll() with the responses. This class holds a Feature
// to keep the Worker thread alive. This is mainly to ensure that Add/AddAll
// act the same as other Cache operations that directly create a CacheOpChild
// actor.
class Cache::FetchHandler final : public PromiseNativeHandler
{
public:
FetchHandler(CacheWorkerHolder* aWorkerHolder, Cache* aCache,
FetchHandler(Feature* aFeature, Cache* aCache,
nsTArray<RefPtr<Request>>&& aRequestList, Promise* aPromise)
: mWorkerHolder(aWorkerHolder)
: mFeature(aFeature)
, mCache(aCache)
, mRequestList(Move(aRequestList))
, mPromise(aPromise)
{
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), mFeature);
MOZ_ASSERT(mCache);
MOZ_ASSERT(mPromise);
}
@ -107,8 +107,8 @@ public:
NS_ASSERT_OWNINGTHREAD(FetchHandler);
// Stop holding the worker alive when we leave this method.
RefPtr<CacheWorkerHolder> workerHolder;
workerHolder.swap(mWorkerHolder);
RefPtr<Feature> feature;
feature.swap(mFeature);
// Promise::All() passed an array of fetch() Promises should give us
// an Array of Response objects. The following code unwraps these
@ -217,7 +217,7 @@ private:
mPromise->MaybeReject(rv);
}
RefPtr<CacheWorkerHolder> mWorkerHolder;
RefPtr<Feature> mFeature;
RefPtr<Cache> mCache;
nsTArray<RefPtr<Request>> mRequestList;
RefPtr<Promise> mPromise;
@ -614,9 +614,8 @@ Cache::AddAll(const GlobalObject& aGlobal,
return nullptr;
}
RefPtr<FetchHandler> handler =
new FetchHandler(mActor->GetWorkerHolder(), this,
Move(aRequestList), promise);
RefPtr<FetchHandler> handler = new FetchHandler(mActor->GetFeature(), this,
Move(aRequestList), promise);
RefPtr<Promise> fetchPromise = Promise::All(aGlobal, fetchList, aRv);
if (NS_WARN_IF(aRv.Failed())) {

6
dom/cache/CacheChild.cpp поставляемый
Просмотреть файл

@ -70,7 +70,7 @@ CacheChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
{
mNumChildActors += 1;
MOZ_ALWAYS_TRUE(SendPCacheOpConstructor(
new CacheOpChild(GetWorkerHolder(), aGlobal, aParent, aPromise), aArgs));
new CacheOpChild(GetFeature(), aGlobal, aParent, aPromise), aArgs));
}
void
@ -103,7 +103,7 @@ CacheChild::StartDestroy()
RefPtr<Cache> listener = mListener;
// StartDestroy() can get called from either Cache or the WorkerHolder.
// StartDestroy() can get called from either Cache or the Feature.
// Theoretically we can get double called if the right race happens. Handle
// that by just ignoring the second StartDestroy() call.
if (!listener) {
@ -130,7 +130,7 @@ CacheChild::ActorDestroy(ActorDestroyReason aReason)
MOZ_ASSERT(!mListener);
}
RemoveWorkerHolder();
RemoveFeature();
}
PCacheOpChild*

2
dom/cache/CacheChild.h поставляемый
Просмотреть файл

@ -65,7 +65,7 @@ public:
private:
// ActorChild methods
// WorkerHolder is trying to destroy due to worker shutdown.
// Feature is trying to destroy due to worker shutdown.
virtual void StartDestroy() override;
// PCacheChild methods

44
dom/cache/CacheOpChild.cpp поставляемый
Просмотреть файл

@ -22,49 +22,43 @@ using mozilla::ipc::PBackgroundChild;
namespace {
void
AddWorkerHolderToStreamChild(const CacheReadStream& aReadStream,
CacheWorkerHolder* aWorkerHolder)
AddFeatureToStreamChild(const CacheReadStream& aReadStream, Feature* aFeature)
{
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
CacheStreamControlChild* cacheControl =
static_cast<CacheStreamControlChild*>(aReadStream.controlChild());
if (cacheControl) {
cacheControl->SetWorkerHolder(aWorkerHolder);
cacheControl->SetFeature(aFeature);
}
}
void
AddWorkerHolderToStreamChild(const CacheResponse& aResponse,
CacheWorkerHolder* aWorkerHolder)
AddFeatureToStreamChild(const CacheResponse& aResponse, Feature* aFeature)
{
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
if (aResponse.body().type() == CacheReadStreamOrVoid::Tvoid_t) {
return;
}
AddWorkerHolderToStreamChild(aResponse.body().get_CacheReadStream(),
aWorkerHolder);
AddFeatureToStreamChild(aResponse.body().get_CacheReadStream(), aFeature);
}
void
AddWorkerHolderToStreamChild(const CacheRequest& aRequest,
CacheWorkerHolder* aWorkerHolder)
AddFeatureToStreamChild(const CacheRequest& aRequest, Feature* aFeature)
{
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
if (aRequest.body().type() == CacheReadStreamOrVoid::Tvoid_t) {
return;
}
AddWorkerHolderToStreamChild(aRequest.body().get_CacheReadStream(),
aWorkerHolder);
AddFeatureToStreamChild(aRequest.body().get_CacheReadStream(), aFeature);
}
} // namespace
CacheOpChild::CacheOpChild(CacheWorkerHolder* aWorkerHolder,
nsIGlobalObject* aGlobal,
CacheOpChild::CacheOpChild(Feature* aFeature, nsIGlobalObject* aGlobal,
nsISupports* aParent, Promise* aPromise)
: mGlobal(aGlobal)
, mParent(aParent)
@ -74,8 +68,8 @@ CacheOpChild::CacheOpChild(CacheWorkerHolder* aWorkerHolder,
MOZ_ASSERT(mParent);
MOZ_ASSERT(mPromise);
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
SetWorkerHolder(aWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
SetFeature(aFeature);
}
CacheOpChild::~CacheOpChild()
@ -96,7 +90,7 @@ CacheOpChild::ActorDestroy(ActorDestroyReason aReason)
mPromise = nullptr;
}
RemoveWorkerHolder();
RemoveFeature();
}
bool
@ -155,7 +149,7 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
{
auto actor = static_cast<CacheChild*>(
aResult.get_StorageOpenResult().actorChild());
actor->SetWorkerHolder(GetWorkerHolder());
actor->SetFeature(GetFeature());
RefPtr<Cache> cache = new Cache(mGlobal, actor);
mPromise->MaybeResolve(cache);
break;
@ -184,8 +178,8 @@ CacheOpChild::StartDestroy()
{
NS_ASSERT_OWNINGTHREAD(CacheOpChild);
// Do not cancel on-going operations when WorkerHolder calls this. Instead,
// keep the Worker alive until we are done.
// Do not cancel on-going operations when Feature calls this. Instead, keep
// the Worker alive until we are done.
}
nsIGlobalObject*
@ -218,7 +212,7 @@ CacheOpChild::HandleResponse(const CacheResponseOrVoid& aResponseOrVoid)
const CacheResponse& cacheResponse = aResponseOrVoid.get_CacheResponse();
AddWorkerHolderToStreamChild(cacheResponse, GetWorkerHolder());
AddFeatureToStreamChild(cacheResponse, GetFeature());
RefPtr<Response> response = ToResponse(cacheResponse);
mPromise->MaybeResolve(response);
@ -231,7 +225,7 @@ CacheOpChild::HandleResponseList(const nsTArray<CacheResponse>& aResponseList)
responses.SetCapacity(aResponseList.Length());
for (uint32_t i = 0; i < aResponseList.Length(); ++i) {
AddWorkerHolderToStreamChild(aResponseList[i], GetWorkerHolder());
AddFeatureToStreamChild(aResponseList[i], GetFeature());
responses.AppendElement(ToResponse(aResponseList[i]));
}
@ -245,7 +239,7 @@ CacheOpChild::HandleRequestList(const nsTArray<CacheRequest>& aRequestList)
requests.SetCapacity(aRequestList.Length());
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
AddWorkerHolderToStreamChild(aRequestList[i], GetWorkerHolder());
AddFeatureToStreamChild(aRequestList[i], GetFeature());
requests.AppendElement(ToRequest(aRequestList[i]));
}

2
dom/cache/CacheOpChild.h поставляемый
Просмотреть файл

@ -31,7 +31,7 @@ class CacheOpChild final : public PCacheOpChild
private:
// This class must be constructed by CacheChild or CacheStorageChild using
// their ExecuteOp() factory method.
CacheOpChild(CacheWorkerHolder* aWorkerHolder, nsIGlobalObject* aGlobal,
CacheOpChild(Feature* aFeature, nsIGlobalObject* aGlobal,
nsISupports* aParent, Promise* aPromise);
~CacheOpChild();

28
dom/cache/CacheStorage.cpp поставляемый
Просмотреть файл

@ -14,7 +14,7 @@
#include "mozilla/dom/cache/Cache.h"
#include "mozilla/dom/cache/CacheChild.h"
#include "mozilla/dom/cache/CacheStorageChild.h"
#include "mozilla/dom/cache/CacheWorkerHolder.h"
#include "mozilla/dom/cache/Feature.h"
#include "mozilla/dom/cache/PCacheChild.h"
#include "mozilla/dom/cache/ReadStream.h"
#include "mozilla/dom/cache/TypeUtils.h"
@ -202,9 +202,8 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
return ref.forget();
}
RefPtr<CacheWorkerHolder> workerHolder =
CacheWorkerHolder::Create(aWorkerPrivate);
if (!workerHolder) {
RefPtr<Feature> feature = Feature::Create(aWorkerPrivate);
if (!feature) {
NS_WARNING("Worker thread is shutting down.");
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
@ -237,7 +236,7 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
}
RefPtr<CacheStorage> ref = new CacheStorage(aNamespace, aGlobal,
principalInfo, workerHolder);
principalInfo, feature);
return ref.forget();
}
@ -277,12 +276,11 @@ CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
}
CacheStorage::CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
const PrincipalInfo& aPrincipalInfo,
CacheWorkerHolder* aWorkerHolder)
const PrincipalInfo& aPrincipalInfo, Feature* aFeature)
: mNamespace(aNamespace)
, mGlobal(aGlobal)
, mPrincipalInfo(MakeUnique<PrincipalInfo>(aPrincipalInfo))
, mWorkerHolder(aWorkerHolder)
, mFeature(aFeature)
, mActor(nullptr)
, mStatus(NS_OK)
{
@ -511,15 +509,15 @@ CacheStorage::ActorCreated(PBackgroundChild* aActor)
NS_ASSERT_OWNINGTHREAD(CacheStorage);
MOZ_ASSERT(aActor);
if (NS_WARN_IF(mWorkerHolder && mWorkerHolder->Notified())) {
if (NS_WARN_IF(mFeature && mFeature->Notified())) {
ActorFailed();
return;
}
// WorkerHolder ownership is passed to the CacheStorageChild actor and any
// actors it may create. The WorkerHolder will keep the worker thread alive
// until the actors can gracefully shutdown.
CacheStorageChild* newActor = new CacheStorageChild(this, mWorkerHolder);
// 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);
@ -528,7 +526,7 @@ CacheStorage::ActorCreated(PBackgroundChild* aActor)
return;
}
mWorkerHolder = nullptr;
mFeature = nullptr;
MOZ_ASSERT(constructedActor == newActor);
mActor = newActor;
@ -544,7 +542,7 @@ CacheStorage::ActorFailed()
MOZ_ASSERT(!NS_FAILED(mStatus));
mStatus = NS_ERROR_UNEXPECTED;
mWorkerHolder = nullptr;
mFeature = nullptr;
for (uint32_t i = 0; i < mPendingRequests.Length(); ++i) {
nsAutoPtr<Entry> entry(mPendingRequests[i].forget());

7
dom/cache/CacheStorage.h поставляемый
Просмотреть файл

@ -38,7 +38,7 @@ namespace workers {
namespace cache {
class CacheStorageChild;
class CacheWorkerHolder;
class Feature;
class CacheStorage final : public nsIIPCBackgroundChildCreateCallback
, public nsWrapperCache
@ -97,8 +97,7 @@ public:
private:
CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
CacheWorkerHolder* aWorkerHolder);
const mozilla::ipc::PrincipalInfo& aPrincipalInfo, Feature* aFeature);
explicit CacheStorage(nsresult aFailureResult);
~CacheStorage();
@ -107,7 +106,7 @@ private:
const Namespace mNamespace;
nsCOMPtr<nsIGlobalObject> mGlobal;
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
RefPtr<CacheWorkerHolder> mWorkerHolder;
RefPtr<Feature> mFeature;
// weak ref cleared in DestroyInternal
CacheStorageChild* mActor;

12
dom/cache/CacheStorageChild.cpp поставляемый
Просмотреть файл

@ -22,8 +22,7 @@ DeallocPCacheStorageChild(PCacheStorageChild* aActor)
delete aActor;
}
CacheStorageChild::CacheStorageChild(CacheStorage* aListener,
CacheWorkerHolder* aWorkerHolder)
CacheStorageChild::CacheStorageChild(CacheStorage* aListener, Feature* aFeature)
: mListener(aListener)
, mNumChildActors(0)
, mDelayedDestroy(false)
@ -31,7 +30,7 @@ CacheStorageChild::CacheStorageChild(CacheStorage* aListener,
MOZ_COUNT_CTOR(cache::CacheStorageChild);
MOZ_ASSERT(mListener);
SetWorkerHolder(aWorkerHolder);
SetFeature(aFeature);
}
CacheStorageChild::~CacheStorageChild()
@ -55,7 +54,7 @@ CacheStorageChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
{
mNumChildActors += 1;
Unused << SendPCacheOpConstructor(
new CacheOpChild(GetWorkerHolder(), aGlobal, aParent, aPromise), aArgs);
new CacheOpChild(GetFeature(), aGlobal, aParent, aPromise), aArgs);
}
void
@ -87,8 +86,7 @@ CacheStorageChild::StartDestroy()
RefPtr<CacheStorage> listener = mListener;
// StartDestroy() can get called from either CacheStorage or the
// CacheWorkerHolder.
// StartDestroy() can get called from either CacheStorage or the Feature.
// Theoretically we can get double called if the right race happens. Handle
// that by just ignoring the second StartDestroy() call.
if (!listener) {
@ -115,7 +113,7 @@ CacheStorageChild::ActorDestroy(ActorDestroyReason aReason)
MOZ_ASSERT(!mListener);
}
RemoveWorkerHolder();
RemoveFeature();
}
PCacheOpChild*

6
dom/cache/CacheStorageChild.h поставляемый
Просмотреть файл

@ -22,14 +22,14 @@ namespace cache {
class CacheOpArgs;
class CacheStorage;
class CacheWorkerHolder;
class PCacheChild;
class Feature;
class CacheStorageChild final : public PCacheStorageChild
, public ActorChild
{
public:
CacheStorageChild(CacheStorage* aListener, CacheWorkerHolder* aWorkerHolder);
CacheStorageChild(CacheStorage* aListener, Feature* aFeature);
~CacheStorageChild();
// Must be called by the associated CacheStorage listener in its
@ -48,7 +48,7 @@ public:
private:
// ActorChild methods
// CacheWorkerHolder is trying to destroy due to worker shutdown.
// Feature is trying to destroy due to worker shutdown.
virtual void StartDestroy() override;
// PCacheStorageChild methods

6
dom/cache/CacheStreamControlChild.cpp поставляемый
Просмотреть файл

@ -58,8 +58,8 @@ CacheStreamControlChild::StartDestroy()
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
// This can get called twice under some circumstances. For example, if the
// actor is added to a CacheWorkerHolder that has already been notified and
// the Cache actor has no mListener.
// actor is added to a Feature that has already been notified and the Cache
// actor has no mListener.
if (mDestroyStarted) {
return;
}
@ -135,7 +135,7 @@ CacheStreamControlChild::ActorDestroy(ActorDestroyReason aReason)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
CloseAllReadStreamsWithoutReporting();
RemoveWorkerHolder();
RemoveFeature();
}
bool

1
dom/cache/Connection.h поставляемый
Просмотреть файл

@ -8,7 +8,6 @@
#define mozilla_dom_cache_Connection_h
#include "mozIStorageConnection.h"
#include "nsCOMPtr.h"
namespace mozilla {
namespace dom {

Просмотреть файл

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/cache/CacheWorkerHolder.h"
#include "mozilla/dom/cache/Feature.h"
#include "mozilla/dom/cache/ActorChild.h"
#include "WorkerPrivate.h"
@ -18,25 +18,24 @@ using mozilla::dom::workers::Status;
using mozilla::dom::workers::WorkerPrivate;
// static
already_AddRefed<CacheWorkerHolder>
CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate)
already_AddRefed<Feature>
Feature::Create(WorkerPrivate* aWorkerPrivate)
{
MOZ_ASSERT(aWorkerPrivate);
RefPtr<CacheWorkerHolder> workerHolder =
new CacheWorkerHolder(aWorkerPrivate);
RefPtr<Feature> feature = new Feature(aWorkerPrivate);
if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate))) {
if (!aWorkerPrivate->AddFeature(feature)) {
return nullptr;
}
return workerHolder.forget();
return feature.forget();
}
void
CacheWorkerHolder::AddActor(ActorChild* aActor)
Feature::AddActor(ActorChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
NS_ASSERT_OWNINGTHREAD(Feature);
MOZ_ASSERT(aActor);
MOZ_ASSERT(!mActorList.Contains(aActor));
@ -52,9 +51,9 @@ CacheWorkerHolder::AddActor(ActorChild* aActor)
}
void
CacheWorkerHolder::RemoveActor(ActorChild* aActor)
Feature::RemoveActor(ActorChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
NS_ASSERT_OWNINGTHREAD(Feature);
MOZ_ASSERT(aActor);
DebugOnly<bool> removed = mActorList.RemoveElement(aActor);
@ -64,15 +63,15 @@ CacheWorkerHolder::RemoveActor(ActorChild* aActor)
}
bool
CacheWorkerHolder::Notified() const
Feature::Notified() const
{
return mNotified;
}
bool
CacheWorkerHolder::Notify(Status aStatus)
Feature::Notify(Status aStatus)
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
NS_ASSERT_OWNINGTHREAD(Feature);
// When the service worker thread is stopped we will get Terminating,
// but nothing higher than that. We must shut things down at Terminating.
@ -91,17 +90,19 @@ CacheWorkerHolder::Notify(Status aStatus)
return true;
}
CacheWorkerHolder::CacheWorkerHolder(WorkerPrivate* aWorkerPrivate)
Feature::Feature(WorkerPrivate* aWorkerPrivate)
: mWorkerPrivate(aWorkerPrivate)
, mNotified(false)
{
MOZ_ASSERT(mWorkerPrivate);
}
CacheWorkerHolder::~CacheWorkerHolder()
Feature::~Feature()
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
NS_ASSERT_OWNINGTHREAD(Feature);
MOZ_ASSERT(mActorList.IsEmpty());
mWorkerPrivate->RemoveFeature(this);
}
} // namespace cache

Просмотреть файл

@ -4,12 +4,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_cache_CacheWorkerHolder_h
#define mozilla_dom_cache_CacheWorkerHolder_h
#ifndef mozilla_dom_cache_Feature_h
#define mozilla_dom_cache_Feature_h
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
namespace mozilla {
@ -22,34 +22,33 @@ namespace cache {
class ActorChild;
class CacheWorkerHolder final : public workers::WorkerHolder
class Feature final : public workers::WorkerFeature
{
public:
static already_AddRefed<CacheWorkerHolder>
Create(workers::WorkerPrivate* aWorkerPrivate);
static already_AddRefed<Feature> Create(workers::WorkerPrivate* aWorkerPrivate);
void AddActor(ActorChild* aActor);
void RemoveActor(ActorChild* aActor);
bool Notified() const;
// WorkerHolder methods
// WorkerFeature methods
virtual bool Notify(workers::Status aStatus) override;
private:
explicit CacheWorkerHolder(workers::WorkerPrivate *aWorkerPrivate);
~CacheWorkerHolder();
explicit Feature(workers::WorkerPrivate *aWorkerPrivate);
~Feature();
workers::WorkerPrivate* mWorkerPrivate;
nsTArray<ActorChild*> mActorList;
bool mNotified;
public:
NS_INLINE_DECL_REFCOUNTING(mozilla::dom::cache::CacheWorkerHolder)
NS_INLINE_DECL_REFCOUNTING(mozilla::dom::cache::Feature)
};
} // namespace cache
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_cache_CacheWorkerHolder_h
#endif // mozilla_dom_cache_Feature_h

4
dom/cache/moz.build поставляемый
Просмотреть файл

@ -19,11 +19,11 @@ EXPORTS.mozilla.dom.cache += [
'CacheStorageParent.h',
'CacheStreamControlChild.h',
'CacheStreamControlParent.h',
'CacheWorkerHolder.h',
'Connection.h',
'Context.h',
'DBAction.h',
'DBSchema.h',
'Feature.h',
'FileUtils.h',
'IPCUtils.h',
'Manager.h',
@ -52,11 +52,11 @@ UNIFIED_SOURCES += [
'CacheStorageParent.cpp',
'CacheStreamControlChild.cpp',
'CacheStreamControlParent.cpp',
'CacheWorkerHolder.cpp',
'Connection.cpp',
'Context.cpp',
'DBAction.cpp',
'DBSchema.cpp',
'Feature.cpp',
'FileUtils.cpp',
'Manager.cpp',
'ManagerId.cpp',

Просмотреть файл

@ -107,7 +107,7 @@ WebGLContextLossHandler::WebGLContextLossHandler(WebGLContext* webgl)
, mIsTimerRunning(false)
, mShouldRunTimerAgain(false)
, mIsDisabled(false)
, mWorkerHolderAdded(false)
, mFeatureAdded(false)
#ifdef DEBUG
, mThread(NS_GetCurrentThread())
#endif
@ -186,9 +186,9 @@ WebGLContextLossHandler::RunTimer()
dom::workers::GetCurrentThreadWorkerPrivate();
nsCOMPtr<nsIEventTarget> target = workerPrivate->GetEventTarget();
mTimer->SetTarget(new ContextLossWorkerEventTarget(target));
if (!mWorkerHolderAdded) {
HoldWorker(workerPrivate);
mWorkerHolderAdded = true;
if (!mFeatureAdded) {
workerPrivate->AddFeature(this);
mFeatureAdded = true;
}
}
@ -206,12 +206,12 @@ WebGLContextLossHandler::DisableTimer()
mIsDisabled = true;
if (mWorkerHolderAdded) {
if (mFeatureAdded) {
dom::workers::WorkerPrivate* workerPrivate =
dom::workers::GetCurrentThreadWorkerPrivate();
MOZ_RELEASE_ASSERT(workerPrivate, "GFX: No private worker created.");
ReleaseWorker();
mWorkerHolderAdded = false;
workerPrivate->RemoveFeature(this);
mFeatureAdded = false;
}
// We can't just Cancel() the timer, as sometimes we end up

Просмотреть файл

@ -10,7 +10,7 @@
#include "mozilla/WeakPtr.h"
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
class nsIThread;
class nsITimer;
@ -18,14 +18,14 @@ class nsITimer;
namespace mozilla {
class WebGLContext;
class WebGLContextLossHandler : public dom::workers::WorkerHolder
class WebGLContextLossHandler : public dom::workers::WorkerFeature
{
WeakPtr<WebGLContext> mWeakWebGL;
nsCOMPtr<nsITimer> mTimer;
bool mIsTimerRunning;
bool mShouldRunTimerAgain;
bool mIsDisabled;
bool mWorkerHolderAdded;
bool mFeatureAdded;
#ifdef DEBUG
nsIThread* mThread;
#endif

Просмотреть файл

@ -314,7 +314,7 @@ private:
};
class ConsoleRunnable : public Runnable
, public WorkerHolder
, public WorkerFeature
, public StructuredCloneHolderBase
{
public:
@ -382,7 +382,7 @@ private:
return false;
}
if (NS_WARN_IF(!HoldWorker(mWorkerPrivate))) {
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
return false;
}
@ -427,7 +427,7 @@ private:
mRunnable->ReleaseData();
mRunnable->mConsole = nullptr;
mRunnable->ReleaseWorker();
aWorkerPrivate->RemoveFeature(mRunnable);
return true;
}

Просмотреть файл

@ -229,7 +229,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
RefPtr<WorkerFetchResolver> resolver = WorkerFetchResolver::Create(worker, p);
if (!resolver) {
NS_WARNING("Could not add WorkerFetchResolver workerHolder to worker");
NS_WARNING("Could not add WorkerFetchResolver feature to worker");
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
return nullptr;
}
@ -405,7 +405,7 @@ WorkerFetchResolver::OnResponseEnd()
RefPtr<WorkerFetchResponseEndControlRunnable> cr =
new WorkerFetchResponseEndControlRunnable(mPromiseProxy);
// This can fail if the worker thread is canceled or killed causing
// the PromiseWorkerProxy to give up its WorkerHolder immediately,
// the PromiseWorkerProxy to give up its WorkerFeature immediately,
// allowing the worker thread to become Dead.
if (!cr->Dispatch()) {
NS_WARNING("Failed to dispatch WorkerFetchResponseEndControlRunnable");
@ -753,7 +753,7 @@ public:
nonconstResult);
if (!r->Dispatch()) {
// XXXcatalinb: The worker is shutting down, the pump will be canceled
// by FetchBodyWorkerHolder::Notify.
// by FetchBodyFeature::Notify.
NS_WARNING("Could not dispatch ConsumeBodyRunnable");
// Return failure so that aResult is freed.
return NS_ERROR_FAILURE;
@ -819,20 +819,20 @@ public:
} // namespace
template <class Derived>
class FetchBodyWorkerHolder final : public workers::WorkerHolder
class FetchBodyFeature final : public workers::WorkerFeature
{
// This is addrefed before the workerHolder is created, and is released in
// ContinueConsumeBody() so we can hold a rawptr.
// This is addrefed before the feature is created, and is released in ContinueConsumeBody()
// so we can hold a rawptr.
FetchBody<Derived>* mBody;
bool mWasNotified;
public:
explicit FetchBodyWorkerHolder(FetchBody<Derived>* aBody)
explicit FetchBodyFeature(FetchBody<Derived>* aBody)
: mBody(aBody)
, mWasNotified(false)
{ }
~FetchBodyWorkerHolder()
~FetchBodyFeature()
{ }
bool Notify(workers::Status aStatus) override
@ -848,7 +848,7 @@ public:
template <class Derived>
FetchBody<Derived>::FetchBody()
: mWorkerHolder(nullptr)
: mFeature(nullptr)
, mBodyUsed(false)
#ifdef DEBUG
, mReadDone(false)
@ -875,8 +875,8 @@ FetchBody<Derived>::~FetchBody()
// Returns true if addref succeeded.
// Always succeeds on main thread.
// May fail on worker if RegisterWorkerHolder() fails. In that case, it will
// release the object before returning false.
// May fail on worker if RegisterFeature() fails. In that case, it will release
// the object before returning false.
template <class Derived>
bool
FetchBody<Derived>::AddRefObject()
@ -884,8 +884,8 @@ FetchBody<Derived>::AddRefObject()
AssertIsOnTargetThread();
DerivedClass()->AddRef();
if (mWorkerPrivate && !mWorkerHolder) {
if (!RegisterWorkerHolder()) {
if (mWorkerPrivate && !mFeature) {
if (!RegisterFeature()) {
ReleaseObject();
return false;
}
@ -899,8 +899,8 @@ FetchBody<Derived>::ReleaseObject()
{
AssertIsOnTargetThread();
if (mWorkerPrivate && mWorkerHolder) {
UnregisterWorkerHolder();
if (mWorkerPrivate && mFeature) {
UnregisterFeature();
}
DerivedClass()->Release();
@ -908,16 +908,16 @@ FetchBody<Derived>::ReleaseObject()
template <class Derived>
bool
FetchBody<Derived>::RegisterWorkerHolder()
FetchBody<Derived>::RegisterFeature()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerHolder);
mWorkerHolder = new FetchBodyWorkerHolder<Derived>(this);
MOZ_ASSERT(!mFeature);
mFeature = new FetchBodyFeature<Derived>(this);
if (!mWorkerHolder->HoldWorker(mWorkerPrivate)) {
NS_WARNING("Failed to add workerHolder");
mWorkerHolder = nullptr;
if (!mWorkerPrivate->AddFeature(mFeature)) {
NS_WARNING("Failed to add feature");
mFeature = nullptr;
return false;
}
@ -926,14 +926,14 @@ FetchBody<Derived>::RegisterWorkerHolder()
template <class Derived>
void
FetchBody<Derived>::UnregisterWorkerHolder()
FetchBody<Derived>::UnregisterFeature()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mWorkerHolder);
MOZ_ASSERT(mFeature);
mWorkerHolder->ReleaseWorker();
mWorkerHolder = nullptr;
mWorkerPrivate->RemoveFeature(mFeature);
mFeature = nullptr;
}
template <class Derived>
@ -952,7 +952,7 @@ nsresult
FetchBody<Derived>::BeginConsumeBody()
{
AssertIsOnTargetThread();
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mFeature);
MOZ_ASSERT(mConsumePromise);
// The FetchBody is not thread-safe refcounted. We addref it here and release
@ -1036,7 +1036,7 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
// sync with a body read.
MOZ_ASSERT(mBodyUsed);
MOZ_ASSERT(!mReadDone);
MOZ_ASSERT_IF(mWorkerPrivate, mWorkerHolder);
MOZ_ASSERT_IF(mWorkerPrivate, mFeature);
#ifdef DEBUG
mReadDone = true;
#endif

Просмотреть файл

@ -20,7 +20,7 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
class nsIGlobalObject;
@ -63,7 +63,7 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
nsCString& aContentType,
uint64_t& aContentLength);
template <class Derived> class FetchBodyWorkerHolder;
template <class Derived> class FetchBodyFeature;
/*
* FetchBody's body consumption uses nsIInputStreamPump to read from the
@ -155,7 +155,7 @@ public:
// Set when consuming the body is attempted on a worker.
// Unset when consumption is done/aborted.
nsAutoPtr<workers::WorkerHolder> mWorkerHolder;
nsAutoPtr<workers::WorkerFeature> mFeature;
protected:
FetchBody();
@ -193,10 +193,10 @@ private:
ReleaseObject();
bool
RegisterWorkerHolder();
RegisterFeature();
void
UnregisterWorkerHolder();
UnregisterFeature();
bool
IsOnTargetThread()

Просмотреть файл

@ -903,7 +903,7 @@ protected:
};
class WorkerPermissionChallenge final : public Runnable
, public WorkerHolder
, public WorkerFeature
{
public:
WorkerPermissionChallenge(WorkerPrivate* aWorkerPrivate,
@ -963,7 +963,7 @@ public:
mActor = nullptr;
mWorkerPrivate->AssertIsOnWorkerThread();
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
}
private:
@ -1415,7 +1415,7 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge(
new WorkerPermissionChallenge(workerPrivate, this, mFactory,
aPrincipalInfo);
if (NS_WARN_IF(!challenge->HoldWorker(workerPrivate))) {
if (NS_WARN_IF(!workerPrivate->AddFeature(challenge))) {
return false;
}

Просмотреть файл

@ -30,7 +30,7 @@
#include "nsPIDOMWindow.h"
#include "nsString.h"
#include "ReportInternalError.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#include "WorkerPrivate.h"
// Include this last to avoid path problems on Windows.
@ -461,19 +461,19 @@ IDBRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
return NS_OK;
}
class IDBOpenDBRequest::WorkerHolder final
: public mozilla::dom::workers::WorkerHolder
class IDBOpenDBRequest::WorkerFeature final
: public mozilla::dom::workers::WorkerFeature
{
WorkerPrivate* mWorkerPrivate;
#ifdef DEBUG
// This is only here so that assertions work in the destructor even if
// NoteAddWorkerHolderFailed was called.
// NoteAddFeatureFailed was called.
WorkerPrivate* mWorkerPrivateDEBUG;
#endif
public:
explicit
WorkerHolder(WorkerPrivate* aWorkerPrivate)
WorkerFeature(WorkerPrivate* aWorkerPrivate)
: mWorkerPrivate(aWorkerPrivate)
#ifdef DEBUG
, mWorkerPrivateDEBUG(aWorkerPrivate)
@ -482,20 +482,24 @@ public:
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
MOZ_COUNT_CTOR(IDBOpenDBRequest::WorkerHolder);
MOZ_COUNT_CTOR(IDBOpenDBRequest::WorkerFeature);
}
~WorkerHolder()
~WorkerFeature()
{
#ifdef DEBUG
mWorkerPrivateDEBUG->AssertIsOnWorkerThread();
#endif
MOZ_COUNT_DTOR(IDBOpenDBRequest::WorkerHolder);
MOZ_COUNT_DTOR(IDBOpenDBRequest::WorkerFeature);
if (mWorkerPrivate) {
mWorkerPrivate->RemoveFeature(this);
}
}
void
NoteAddWorkerHolderFailed()
NoteAddFeatureFailed()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
@ -573,13 +577,13 @@ IDBOpenDBRequest::CreateForJS(JSContext* aCx,
workerPrivate->AssertIsOnWorkerThread();
nsAutoPtr<WorkerHolder> workerHolder(new WorkerHolder(workerPrivate));
if (NS_WARN_IF(!workerHolder->HoldWorker(workerPrivate))) {
workerHolder->NoteAddWorkerHolderFailed();
nsAutoPtr<WorkerFeature> feature(new WorkerFeature(workerPrivate));
if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
feature->NoteAddFeatureFailed();
return nullptr;
}
request->mWorkerHolder = Move(workerHolder);
request->mWorkerFeature = Move(feature);
}
return request.forget();
@ -599,11 +603,11 @@ void
IDBOpenDBRequest::NoteComplete()
{
AssertIsOnOwningThread();
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerFeature);
// If we have a WorkerHolder installed on the worker then nulling this out
// If we have a WorkerFeature installed on the worker then nulling this out
// will uninstall it from the worker.
mWorkerHolder = nullptr;
mWorkerFeature = nullptr;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBOpenDBRequest)
@ -646,7 +650,7 @@ IDBOpenDBRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
bool
IDBOpenDBRequest::
WorkerHolder::Notify(Status aStatus)
WorkerFeature::Notify(Status aStatus)
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();

Просмотреть файл

@ -226,12 +226,12 @@ protected:
class IDBOpenDBRequest final
: public IDBRequest
{
class WorkerHolder;
class WorkerFeature;
// Only touched on the owning thread.
RefPtr<IDBFactory> mFactory;
nsAutoPtr<WorkerHolder> mWorkerHolder;
nsAutoPtr<WorkerFeature> mWorkerFeature;
const bool mFileHandleDisabled;

Просмотреть файл

@ -22,7 +22,7 @@
#include "nsTHashtable.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#include "WorkerPrivate.h"
// Include this last to avoid path problems on Windows.
@ -35,8 +35,8 @@ using namespace mozilla::dom::indexedDB;
using namespace mozilla::dom::workers;
using namespace mozilla::ipc;
class IDBTransaction::WorkerHolder final
: public mozilla::dom::workers::WorkerHolder
class IDBTransaction::WorkerFeature final
: public mozilla::dom::workers::WorkerFeature
{
WorkerPrivate* mWorkerPrivate;
@ -45,7 +45,7 @@ class IDBTransaction::WorkerHolder final
IDBTransaction* mTransaction;
public:
WorkerHolder(WorkerPrivate* aWorkerPrivate, IDBTransaction* aTransaction)
WorkerFeature(WorkerPrivate* aWorkerPrivate, IDBTransaction* aTransaction)
: mWorkerPrivate(aWorkerPrivate)
, mTransaction(aTransaction)
{
@ -54,14 +54,16 @@ public:
aWorkerPrivate->AssertIsOnWorkerThread();
aTransaction->AssertIsOnOwningThread();
MOZ_COUNT_CTOR(IDBTransaction::WorkerHolder);
MOZ_COUNT_CTOR(IDBTransaction::WorkerFeature);
}
~WorkerHolder()
~WorkerFeature()
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_COUNT_DTOR(IDBTransaction::WorkerHolder);
MOZ_COUNT_DTOR(IDBTransaction::WorkerFeature);
mWorkerPrivate->RemoveFeature(this);
}
private:
@ -239,8 +241,8 @@ IDBTransaction::Create(JSContext* aCx, IDBDatabase* aDatabase,
workerPrivate->AssertIsOnWorkerThread();
transaction->mWorkerHolder = new WorkerHolder(workerPrivate, transaction);
MOZ_ALWAYS_TRUE(transaction->mWorkerHolder->HoldWorker(workerPrivate));
transaction->mWorkerFeature = new WorkerFeature(workerPrivate, transaction);
MOZ_ALWAYS_TRUE(workerPrivate->AddFeature(transaction->mWorkerFeature));
}
return transaction.forget();
@ -784,8 +786,8 @@ IDBTransaction::FireCompleteOrAbortEvents(nsresult aResult)
mFiredCompleteOrAbort = true;
#endif
// Make sure we drop the WorkerHolder when this function completes.
nsAutoPtr<WorkerHolder> workerHolder = Move(mWorkerHolder);
// Make sure we drop the WorkerFeature when this function completes.
nsAutoPtr<WorkerFeature> workerFeature = Move(mWorkerFeature);
nsCOMPtr<nsIDOMEvent> event;
if (NS_SUCCEEDED(aResult)) {
@ -1028,7 +1030,7 @@ IDBTransaction::Run()
bool
IDBTransaction::
WorkerHolder::Notify(Status aStatus)
WorkerFeature::Notify(Status aStatus)
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();

Просмотреть файл

@ -50,8 +50,8 @@ class IDBTransaction final
friend class indexedDB::BackgroundCursorChild;
friend class indexedDB::BackgroundRequestChild;
class WorkerHolder;
friend class WorkerHolder;
class WorkerFeature;
friend class WorkerFeature;
public:
enum Mode
@ -80,7 +80,7 @@ private:
nsTArray<nsString> mObjectStoreNames;
nsTArray<RefPtr<IDBObjectStore>> mObjectStores;
nsTArray<RefPtr<IDBObjectStore>> mDeletedObjectStores;
nsAutoPtr<WorkerHolder> mWorkerHolder;
nsAutoPtr<WorkerFeature> mWorkerFeature;
// Tagged with mMode. If mMode is VERSION_CHANGE then mBackgroundActor will be
// a BackgroundVersionChangeTransactionChild. Otherwise it will be a

Просмотреть файл

@ -195,16 +195,16 @@ NS_IMPL_RELEASE_INHERITED(MessagePort, DOMEventTargetHelper)
namespace {
class MessagePortWorkerHolder final : public workers::WorkerHolder
class MessagePortFeature final : public workers::WorkerFeature
{
MessagePort* mPort;
public:
explicit MessagePortWorkerHolder(MessagePort* aPort)
explicit MessagePortFeature(MessagePort* aPort)
: mPort(aPort)
{
MOZ_ASSERT(aPort);
MOZ_COUNT_CTOR(MessagePortWorkerHolder);
MOZ_COUNT_CTOR(MessagePortFeature);
}
virtual bool Notify(workers::Status aStatus) override
@ -219,9 +219,9 @@ public:
}
private:
~MessagePortWorkerHolder()
~MessagePortFeature()
{
MOZ_COUNT_DTOR(MessagePortWorkerHolder);
MOZ_COUNT_DTOR(MessagePortFeature);
}
};
@ -287,7 +287,7 @@ MessagePort::MessagePort(nsIGlobalObject* aGlobal)
MessagePort::~MessagePort()
{
CloseForced();
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mWorkerFeature);
}
/* static */ already_AddRefed<MessagePort>
@ -340,7 +340,7 @@ MessagePort::Initialize(const nsID& aUUID,
if (mNeutered) {
// If this port is neutered we don't want to keep it alive artificially nor
// we want to add listeners or workerWorkerHolders.
// we want to add listeners or workerFeatures.
mState = eStateDisentangled;
return;
}
@ -357,15 +357,15 @@ MessagePort::Initialize(const nsID& aUUID,
if (!NS_IsMainThread()) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mWorkerFeature);
nsAutoPtr<WorkerHolder> workerHolder(new MessagePortWorkerHolder(this));
if (NS_WARN_IF(!workerHolder->HoldWorker(workerPrivate))) {
nsAutoPtr<WorkerFeature> feature(new MessagePortFeature(this));
if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
mWorkerHolder = Move(workerHolder);
mWorkerFeature = Move(feature);
} else if (GetOwner()) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(GetOwner()->IsInnerWindow());
@ -912,8 +912,13 @@ MessagePort::UpdateMustKeepAlive()
mIsKeptAlive) {
mIsKeptAlive = false;
// The DTOR of this WorkerHolder will release the worker for us.
mWorkerHolder = nullptr;
if (mWorkerFeature) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
workerPrivate->RemoveFeature(mWorkerFeature);
mWorkerFeature = nullptr;
}
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> obs =

Просмотреть файл

@ -29,7 +29,7 @@ class PostMessageRunnable;
class SharedMessagePortMessage;
namespace workers {
class WorkerHolder;
class WorkerFeature;
} // namespace workers
class MessagePort final : public DOMEventTargetHelper
@ -164,7 +164,7 @@ private:
return mIsKeptAlive;
}
nsAutoPtr<workers::WorkerHolder> mWorkerHolder;
nsAutoPtr<workers::WorkerFeature> mWorkerFeature;
RefPtr<PostMessageRunnable> mPostMessageRunnable;

Просмотреть файл

@ -458,10 +458,9 @@ public:
}
// This is only required because Gecko runs script in a worker's onclose
// handler (non-standard, Bug 790919) where calls to HoldWorker() will
// fail. Due to non-standardness and added complications if we decide to
// support this, attempts to create a Notification in onclose just throw
// exceptions.
// handler (non-standard, Bug 790919) where calls to AddFeature() will fail.
// Due to non-standardness and added complications if we decide to support
// this, attempts to create a Notification in onclose just throw exceptions.
bool
Initialized()
{
@ -1200,7 +1199,7 @@ Notification::~Notification()
mData.setUndefined();
mozilla::DropJSObjects(this);
AssertIsOnTargetThread();
MOZ_ASSERT(!mWorkerHolder);
MOZ_ASSERT(!mFeature);
MOZ_ASSERT(!mTempRef);
}
@ -2441,10 +2440,10 @@ bool
Notification::AddRefObject()
{
AssertIsOnTargetThread();
MOZ_ASSERT_IF(mWorkerPrivate && !mWorkerHolder, mTaskCount == 0);
MOZ_ASSERT_IF(mWorkerPrivate && mWorkerHolder, mTaskCount > 0);
if (mWorkerPrivate && !mWorkerHolder) {
if (!RegisterWorkerHolder()) {
MOZ_ASSERT_IF(mWorkerPrivate && !mFeature, mTaskCount == 0);
MOZ_ASSERT_IF(mWorkerPrivate && mFeature, mTaskCount > 0);
if (mWorkerPrivate && !mFeature) {
if (!RegisterFeature()) {
return false;
}
}
@ -2458,16 +2457,16 @@ Notification::ReleaseObject()
{
AssertIsOnTargetThread();
MOZ_ASSERT(mTaskCount > 0);
MOZ_ASSERT_IF(mWorkerPrivate, mWorkerHolder);
MOZ_ASSERT_IF(mWorkerPrivate, mFeature);
--mTaskCount;
if (mWorkerPrivate && mTaskCount == 0) {
UnregisterWorkerHolder();
UnregisterFeature();
}
Release();
}
NotificationWorkerHolder::NotificationWorkerHolder(Notification* aNotification)
NotificationFeature::NotificationFeature(Notification* aNotification)
: mNotification(aNotification)
{
MOZ_ASSERT(mNotification->mWorkerPrivate);
@ -2515,7 +2514,7 @@ class CloseNotificationRunnable final
};
bool
NotificationWorkerHolder::Notify(Status aStatus)
NotificationFeature::Notify(Status aStatus)
{
if (aStatus >= Canceling) {
// CloseNotificationRunnable blocks the worker by pushing a sync event loop
@ -2558,26 +2557,28 @@ NotificationWorkerHolder::Notify(Status aStatus)
}
bool
Notification::RegisterWorkerHolder()
Notification::RegisterFeature()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerHolder);
mWorkerHolder = MakeUnique<NotificationWorkerHolder>(this);
if (NS_WARN_IF(!mWorkerHolder->HoldWorker(mWorkerPrivate))) {
return false;
MOZ_ASSERT(!mFeature);
mFeature = MakeUnique<NotificationFeature>(this);
bool added = mWorkerPrivate->AddFeature(mFeature.get());
if (!added) {
mFeature = nullptr;
}
return true;
return added;
}
void
Notification::UnregisterWorkerHolder()
Notification::UnregisterFeature()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mWorkerHolder);
mWorkerHolder = nullptr;
MOZ_ASSERT(mFeature);
mWorkerPrivate->RemoveFeature(mFeature.get());
mFeature = nullptr;
}
/*

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/NotificationBinding.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#include "nsIObserver.h"
@ -36,14 +36,14 @@ namespace workers {
} // namespace workers
class Notification;
class NotificationWorkerHolder final : public workers::WorkerHolder
class NotificationFeature final : public workers::WorkerFeature
{
// Since the feature is strongly held by a Notification, it is ok to hold
// a raw pointer here.
Notification* mNotification;
public:
explicit NotificationWorkerHolder(Notification* aNotification);
explicit NotificationFeature(Notification* aNotification);
bool
Notify(workers::Status aStatus) override;
@ -448,13 +448,13 @@ private:
return NS_IsMainThread() == !mWorkerPrivate;
}
bool RegisterWorkerHolder();
void UnregisterWorkerHolder();
bool RegisterFeature();
void UnregisterFeature();
nsresult ResolveIconAndSoundURL(nsString&, nsString&);
// Only used for Notifications on Workers, worker thread only.
UniquePtr<NotificationWorkerHolder> mWorkerHolder;
UniquePtr<NotificationFeature> mFeature;
// Target thread only.
uint32_t mTaskCount;
};

Просмотреть файл

@ -2527,7 +2527,7 @@ Promise::AppendCallbacks(PromiseCallback* aResolveCallback,
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
// Now that there is a callback, we don't need to report anymore.
mHadRejectCallback = true;
RemoveWorkerHolder();
RemoveFeature();
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
mResolveCallbacks.AppendElement(aResolveCallback);
@ -2767,9 +2767,10 @@ Promise::Settle(JS::Handle<JS::Value> aValue, PromiseState aState)
MOZ_ASSERT(worker);
worker->AssertIsOnWorkerThread();
mWorkerHolder = new PromiseReportRejectWorkerHolder(this);
if (NS_WARN_IF(!mWorkerHolder->HoldWorker(worker))) {
mWorkerHolder = nullptr;
mFeature = new PromiseReportRejectFeature(this);
if (NS_WARN_IF(!worker->AddFeature(mFeature))) {
// To avoid a false RemoveFeature().
mFeature = nullptr;
// Worker is shutting down, report rejection immediately since it is
// unlikely that reject callbacks will be added after this point.
MaybeReportRejectedOnce();
@ -2818,20 +2819,24 @@ Promise::TriggerPromiseReactions()
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
void
Promise::RemoveWorkerHolder()
Promise::RemoveFeature()
{
NS_ASSERT_OWNINGTHREAD(Promise);
// The DTOR of this WorkerHolder will release the worker for us.
mWorkerHolder = nullptr;
if (mFeature) {
workers::WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(worker);
worker->RemoveFeature(mFeature);
mFeature = nullptr;
}
}
bool
PromiseReportRejectWorkerHolder::Notify(workers::Status aStatus)
PromiseReportRejectFeature::Notify(workers::Status aStatus)
{
MOZ_ASSERT(aStatus > workers::Running);
mPromise->MaybeReportRejectedOnce();
// After this point, `this` has been deleted by RemoveWorkerHolder!
// After this point, `this` has been deleted by RemoveFeature!
return true;
}
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
@ -2966,7 +2971,7 @@ PromiseWorkerProxy::PromiseWorkerProxy(workers::WorkerPrivate* aWorkerPrivate,
, mCallbacks(aCallbacks)
, mCleanUpLock("cleanUpLock")
#ifdef DEBUG
, mWorkerHolderAdded(false)
, mFeatureAdded(false)
#endif
{
}
@ -2974,7 +2979,7 @@ PromiseWorkerProxy::PromiseWorkerProxy(workers::WorkerPrivate* aWorkerPrivate,
PromiseWorkerProxy::~PromiseWorkerProxy()
{
MOZ_ASSERT(mCleanedUp);
MOZ_ASSERT(!mWorkerHolderAdded);
MOZ_ASSERT(!mFeatureAdded);
MOZ_ASSERT(!mWorkerPromise);
MOZ_ASSERT(!mWorkerPrivate);
}
@ -3002,13 +3007,13 @@ PromiseWorkerProxy::AddRefObject()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerHolderAdded);
if (NS_WARN_IF(!HoldWorker(mWorkerPrivate))) {
MOZ_ASSERT(!mFeatureAdded);
if (!mWorkerPrivate->AddFeature(this)) {
return false;
}
#ifdef DEBUG
mWorkerHolderAdded = true;
mFeatureAdded = true;
#endif
// Maintain a reference so that we have a valid object to clean up when
// removing the feature.
@ -3027,7 +3032,7 @@ PromiseWorkerProxy::GetWorkerPrivate() const
// Safe to check this without a lock since we assert lock ownership on the
// main thread above.
MOZ_ASSERT(!mCleanedUp);
MOZ_ASSERT(mWorkerHolderAdded);
MOZ_ASSERT(mFeatureAdded);
return mWorkerPrivate;
}
@ -3111,8 +3116,7 @@ PromiseWorkerProxy::CleanUp()
MutexAutoLock lock(Lock());
// |mWorkerPrivate| is not safe to use anymore if we have already
// cleaned up and RemoveWorkerHolder(), so we need to check |mCleanedUp|
// first.
// cleaned up and RemoveFeature(), so we need to check |mCleanedUp| first.
if (CleanedUp()) {
return;
}
@ -3123,10 +3127,10 @@ PromiseWorkerProxy::CleanUp()
// Release the Promise and remove the PromiseWorkerProxy from the features of
// the worker thread since the Promise has been resolved/rejected or the
// worker thread has been cancelled.
MOZ_ASSERT(mWorkerHolderAdded);
ReleaseWorker();
MOZ_ASSERT(mFeatureAdded);
mWorkerPrivate->RemoveFeature(this);
#ifdef DEBUG
mWorkerHolderAdded = false;
mFeatureAdded = false;
#endif
CleanProperties();
}

Просмотреть файл

@ -29,7 +29,7 @@
#define DOM_PROMISE_DEPRECATED_REPORTING !SPIDERMONKEY_PROMISE
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
class nsIGlobalObject;
@ -48,15 +48,14 @@ class PromiseDebugging;
class Promise;
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
class PromiseReportRejectWorkerHolder : public workers::WorkerHolder
class PromiseReportRejectFeature : public workers::WorkerFeature
{
// PromiseReportRejectWorkerHolder is held by an nsAutoPtr on the Promise
// which means that this object will be destroyed before the Promise is
// destroyed.
// PromiseReportRejectFeature is held by an nsAutoPtr on the Promise which
// means that this object will be destroyed before the Promise is destroyed.
Promise* MOZ_NON_OWNING_REF mPromise;
public:
explicit PromiseReportRejectWorkerHolder(Promise* aPromise)
explicit PromiseReportRejectFeature(Promise* aPromise)
: mPromise(aPromise)
{
MOZ_ASSERT(mPromise);
@ -85,7 +84,7 @@ class Promise : public nsISupports,
friend class PromiseResolverTask;
friend class PromiseTask;
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
friend class PromiseReportRejectWorkerHolder;
friend class PromiseReportRejectFeature;
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
friend class PromiseWorkerProxy;
friend class PromiseWorkerProxyRunnable;
@ -410,7 +409,7 @@ private:
void MaybeReportRejectedOnce() {
MaybeReportRejected();
RemoveWorkerHolder();
RemoveFeature();
mResult.setUndefined();
}
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
@ -465,7 +464,7 @@ private:
CreateThenableFunction(JSContext* aCx, Promise* aPromise, uint32_t aTask);
#if defined(DOM_PROMISE_DEPRECATED_REPORTING)
void RemoveWorkerHolder();
void RemoveFeature();
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
// Capture the current stack and store it in aTarget. If false is
@ -504,7 +503,7 @@ private:
// needs to know when the worker is shutting down, to report the error on the
// console before the worker's context is deleted. This feature is used for
// that purpose.
nsAutoPtr<PromiseReportRejectWorkerHolder> mWorkerHolder;
nsAutoPtr<PromiseReportRejectFeature> mFeature;
#endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
bool mTaskPending;

Просмотреть файл

@ -11,7 +11,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#include "nsProxyRelease.h"
#include "WorkerRunnable.h"
@ -110,7 +110,7 @@ class WorkerPrivate;
// references to it are dropped.
class PromiseWorkerProxy : public PromiseNativeHandler
, public workers::WorkerHolder
, public workers::WorkerFeature
, public StructuredCloneHolderBase
{
friend class PromiseWorkerProxyRunnable;
@ -229,7 +229,7 @@ private:
#ifdef DEBUG
// Maybe get rid of this entirely and rely on mCleanedUp
bool mWorkerHolderAdded;
bool mFeatureAdded;
#endif
};
} // namespace dom

Просмотреть файл

@ -58,7 +58,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/UniquePtr.h"
#include "Principal.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
@ -538,7 +538,7 @@ private:
NS_IMPL_ISUPPORTS(LoaderListener, nsIStreamLoaderObserver, nsIRequestObserver)
class ScriptLoaderRunnable final : public WorkerHolder
class ScriptLoaderRunnable final : public WorkerFeature
, public nsIRunnable
{
friend class ScriptExecutorRunnable;
@ -1946,7 +1946,7 @@ ScriptExecutorRunnable::ShutdownScriptLoader(JSContext* aCx,
}
}
mScriptLoader.ReleaseWorker();
aWorkerPrivate->RemoveFeature(&mScriptLoader);
aWorkerPrivate->StopSyncLoop(mSyncLoopTarget, aResult);
}
@ -1998,7 +1998,7 @@ LoadAllScripts(WorkerPrivate* aWorkerPrivate,
NS_ASSERTION(aLoadInfos.IsEmpty(), "Should have swapped!");
if (NS_WARN_IF(!loader->HoldWorker(aWorkerPrivate))) {
if (!aWorkerPrivate->AddFeature(loader)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
@ -2006,7 +2006,7 @@ LoadAllScripts(WorkerPrivate* aWorkerPrivate,
if (NS_FAILED(NS_DispatchToMainThread(loader))) {
NS_ERROR("Failed to dispatch!");
loader->ReleaseWorker();
aWorkerPrivate->RemoveFeature(loader);
aRv.Throw(NS_ERROR_FAILURE);
return;
}

Просмотреть файл

@ -212,14 +212,14 @@ class KeepAliveHandler final
// preemptively cleanup if the service worker is timed out and
// terminated.
class InternalHandler final : public PromiseNativeHandler
, public WorkerHolder
, public WorkerFeature
{
nsMainThreadPtrHandle<KeepAliveToken> mKeepAliveToken;
// Worker thread only
WorkerPrivate* mWorkerPrivate;
RefPtr<Promise> mPromise;
bool mWorkerHolderAdded;
bool mFeatureAdded;
~InternalHandler()
{
@ -227,13 +227,13 @@ class KeepAliveHandler final
}
bool
UseWorkerHolder()
AddFeature()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerHolderAdded);
mWorkerHolderAdded = HoldWorker(mWorkerPrivate);
return mWorkerHolderAdded;
MOZ_ASSERT(!mFeatureAdded);
mFeatureAdded = mWorkerPrivate->AddFeature(this);
return mFeatureAdded;
}
void
@ -244,8 +244,8 @@ class KeepAliveHandler final
if (!mPromise) {
return;
}
if (mWorkerHolderAdded) {
ReleaseWorker();
if (mFeatureAdded) {
mWorkerPrivate->RemoveFeature(this);
}
mPromise = nullptr;
mKeepAliveToken = nullptr;
@ -285,7 +285,7 @@ class KeepAliveHandler final
: mKeepAliveToken(aKeepAliveToken)
, mWorkerPrivate(aWorkerPrivate)
, mPromise(aPromise)
, mWorkerHolderAdded(false)
, mFeatureAdded(false)
{
MOZ_ASSERT(mKeepAliveToken);
MOZ_ASSERT(mWorkerPrivate);
@ -302,7 +302,7 @@ class KeepAliveHandler final
aWorkerPrivate,
aPromise);
if (NS_WARN_IF(!ref->UseWorkerHolder())) {
if (NS_WARN_IF(!ref->AddFeature())) {
return nullptr;
}
@ -518,7 +518,7 @@ private:
* with advancing the job queue for install/activate tasks.
*/
class LifeCycleEventWatcher final : public PromiseNativeHandler,
public WorkerHolder
public WorkerFeature
{
WorkerPrivate* mWorkerPrivate;
RefPtr<LifeCycleEventCallback> mCallback;
@ -564,7 +564,7 @@ public:
// case the registration/update promise will be rejected
// 2. A new service worker is registered which will terminate the current
// installing worker.
if (NS_WARN_IF(!HoldWorker(mWorkerPrivate))) {
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
NS_WARNING("LifeCycleEventWatcher failed to add feature.");
ReportResult(false);
return false;
@ -602,7 +602,7 @@ public:
NS_RUNTIMEABORT("Failed to dispatch life cycle event handler.");
}
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
}
void

Просмотреть файл

@ -861,7 +861,7 @@ ServiceWorkerRegistrationMainThread::GetPushManager(JSContext* aCx,
// Worker Thread implementation
class ServiceWorkerRegistrationWorkerThread final : public ServiceWorkerRegistration
, public WorkerHolder
, public WorkerFeature
{
public:
NS_DECL_ISUPPORTS_INHERITED
@ -1188,7 +1188,7 @@ ServiceWorkerRegistrationWorkerThread::InitListener()
worker->AssertIsOnWorkerThread();
mListener = new WorkerListener(worker, this);
if (!HoldWorker(worker)) {
if (!worker->AddFeature(this)) {
mListener = nullptr;
NS_WARNING("Could not add feature");
return;
@ -1242,12 +1242,12 @@ ServiceWorkerRegistrationWorkerThread::ReleaseListener(Reason aReason)
}
// We can assert worker here, because:
// 1) We always HoldWorker, so if the worker has shutdown already, we'll
// have received Notify and removed it. If HoldWorker had failed,
// mListener will be null and we won't reach here.
// 1) We always AddFeature, so if the worker has shutdown already, we'll have
// received Notify and removed it. If AddFeature had failed, mListener will
// be null and we won't reach here.
// 2) Otherwise, worker is still around even if we are going away.
mWorkerPrivate->AssertIsOnWorkerThread();
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
mListener->ClearRegistration();

Просмотреть файл

@ -10,7 +10,7 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/ServiceWorkerBinding.h"
#include "mozilla/dom/ServiceWorkerCommon.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
// Support for Notification API extension.

Просмотреть файл

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_workers_WorkerHolder_h
#define mozilla_dom_workers_WorkerHolder_h
#ifndef mozilla_dom_workers_workerfeature_h__
#define mozilla_dom_workers_workerfeature_h__
#include "mozilla/dom/workers/Workers.h"
@ -69,23 +69,14 @@ enum Status
Dead
};
class WorkerHolder
class WorkerFeature
{
public:
WorkerHolder();
virtual ~WorkerHolder();
bool HoldWorker(WorkerPrivate* aWorkerPrivate);
void ReleaseWorker();
virtual ~WorkerFeature() { }
virtual bool Notify(Status aStatus) = 0;
protected:
void ReleaseWorkerInternal();
WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
};
END_WORKERS_NAMESPACE
#endif /* mozilla_dom_workers_WorkerHolder_h */
#endif /* mozilla_dom_workers_workerfeature_h__ */

Просмотреть файл

@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WorkerHolder.h"
#include "WorkerPrivate.h"
BEGIN_WORKERS_NAMESPACE
WorkerHolder::WorkerHolder()
: mWorkerPrivate(nullptr)
{
}
WorkerHolder::~WorkerHolder()
{
ReleaseWorkerInternal();
MOZ_ASSERT(mWorkerPrivate == nullptr);
}
bool
WorkerHolder::HoldWorker(WorkerPrivate* aWorkerPrivate)
{
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
if (!aWorkerPrivate->AddHolder(this)) {
return false;
}
mWorkerPrivate = aWorkerPrivate;
return true;
}
void
WorkerHolder::ReleaseWorker()
{
MOZ_ASSERT(mWorkerPrivate);
ReleaseWorkerInternal();
}
void
WorkerHolder::ReleaseWorkerInternal()
{
if (mWorkerPrivate) {
mWorkerPrivate->RemoveHolder(this);
mWorkerPrivate = nullptr;
}
}
END_WORKERS_NAMESPACE

Просмотреть файл

@ -102,7 +102,7 @@
#include "ServiceWorkerWindowClient.h"
#include "SharedWorker.h"
#include "WorkerDebuggerManager.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#include "WorkerNavigator.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
@ -4548,7 +4548,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
// If the close handler has finished and all features are done then we can
// kill this thread.
if (currentStatus != Running && !HasActiveHolders()) {
if (currentStatus != Running && !HasActiveFeatures()) {
if (mCloseHandlerFinished && currentStatus != Killing) {
NotifyInternal(aCx, Killing);
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
@ -5252,7 +5252,7 @@ WorkerPrivate::RemoveChildWorker(ParentType* aChildWorker)
}
bool
WorkerPrivate::AddHolder(WorkerHolder* aHolder)
WorkerPrivate::AddFeature(WorkerFeature* aFeature)
{
AssertIsOnWorkerThread();
@ -5264,31 +5264,31 @@ WorkerPrivate::AddHolder(WorkerHolder* aHolder)
}
}
MOZ_ASSERT(!mHolders.Contains(aHolder), "Already know about this one!");
MOZ_ASSERT(!mFeatures.Contains(aFeature), "Already know about this one!");
if (mHolders.IsEmpty() && !ModifyBusyCountFromWorker(true)) {
if (mFeatures.IsEmpty() && !ModifyBusyCountFromWorker(true)) {
return false;
}
mHolders.AppendElement(aHolder);
mFeatures.AppendElement(aFeature);
return true;
}
void
WorkerPrivate::RemoveHolder(WorkerHolder* aHolder)
WorkerPrivate::RemoveFeature(WorkerFeature* aFeature)
{
AssertIsOnWorkerThread();
MOZ_ASSERT(mHolders.Contains(aHolder), "Didn't know about this one!");
mHolders.RemoveElement(aHolder);
MOZ_ASSERT(mFeatures.Contains(aFeature), "Didn't know about this one!");
mFeatures.RemoveElement(aFeature);
if (mHolders.IsEmpty() && !ModifyBusyCountFromWorker(false)) {
if (mFeatures.IsEmpty() && !ModifyBusyCountFromWorker(false)) {
NS_WARNING("Failed to modify busy count!");
}
}
void
WorkerPrivate::NotifyHolders(JSContext* aCx, Status aStatus)
WorkerPrivate::NotifyFeatures(JSContext* aCx, Status aStatus)
{
AssertIsOnWorkerThread();
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
@ -5299,9 +5299,9 @@ WorkerPrivate::NotifyHolders(JSContext* aCx, Status aStatus)
CancelAllTimeouts();
}
nsTObserverArray<WorkerHolder*>::ForwardIterator iter(mHolders);
nsTObserverArray<WorkerFeature*>::ForwardIterator iter(mFeatures);
while (iter.HasMore()) {
WorkerHolder* feature = iter.GetNext();
WorkerFeature* feature = iter.GetNext();
if (!feature->Notify(aStatus)) {
NS_WARNING("Failed to notify feature!");
}
@ -5795,7 +5795,7 @@ WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
MOZ_ASSERT(previousStatus >= Canceling || mKillTime.IsNull());
// Let all our features know the new status.
NotifyHolders(aCx, aStatus);
NotifyFeatures(aCx, aStatus);
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
// If this is the first time our status has changed then we need to clear the

Просмотреть файл

@ -30,7 +30,7 @@
#include "nsTObserverArray.h"
#include "Queue.h"
#include "WorkerHolder.h"
#include "WorkerFeature.h"
#ifdef XP_WIN
#undef PostMessage
@ -862,7 +862,6 @@ private:
class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
{
friend class WorkerHolder;
friend class WorkerPrivateParent<WorkerPrivate>;
typedef WorkerPrivateParent<WorkerPrivate> ParentType;
friend class AutoSyncLoopHolder;
@ -898,7 +897,7 @@ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
RefPtr<WorkerGlobalScope> mScope;
RefPtr<WorkerDebuggerGlobalScope> mDebuggerScope;
nsTArray<ParentType*> mChildWorkers;
nsTObserverArray<WorkerHolder*> mHolders;
nsTObserverArray<WorkerFeature*> mFeatures;
nsTArray<nsAutoPtr<TimeoutInfo>> mTimeouts;
uint32_t mDebuggerEventLoopLevel;
@ -1076,6 +1075,22 @@ public:
void
RemoveChildWorker(ParentType* aChildWorker);
bool
AddFeature(WorkerFeature* aFeature);
void
RemoveFeature(WorkerFeature* aFeature);
void
NotifyFeatures(JSContext* aCx, Status aStatus);
bool
HasActiveFeatures()
{
return !(mChildWorkers.IsEmpty() && mTimeouts.IsEmpty() &&
mFeatures.IsEmpty());
}
void
PostMessageToParent(JSContext* aCx,
JS::Handle<JS::Value> aMessage,
@ -1427,22 +1442,6 @@ private:
void
ShutdownGCTimers();
bool
AddHolder(WorkerHolder* aHolder);
void
RemoveHolder(WorkerHolder* aHolder);
void
NotifyHolders(JSContext* aCx, Status aStatus);
bool
HasActiveHolders()
{
return !(mChildWorkers.IsEmpty() && mTimeouts.IsEmpty() &&
mHolders.IsEmpty());
}
};
// This class is only used to trick the DOM bindings. We never create

Просмотреть файл

@ -1685,7 +1685,7 @@ XMLHttpRequest::MaybePin(ErrorResult& aRv)
return;
}
if (!HoldWorker(mWorkerPrivate)) {
if (!mWorkerPrivate->AddFeature(this)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
@ -1803,7 +1803,7 @@ XMLHttpRequest::Unpin()
MOZ_ASSERT(mRooted, "Mismatched calls to Unpin!");
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
mRooted = false;

Просмотреть файл

@ -7,7 +7,7 @@
#ifndef mozilla_dom_workers_xmlhttprequest_h__
#define mozilla_dom_workers_xmlhttprequest_h__
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
// Need this for XMLHttpRequestResponseType.
#include "mozilla/dom/XMLHttpRequestBinding.h"
@ -30,7 +30,7 @@ class XMLHttpRequestUpload;
class WorkerPrivate;
class XMLHttpRequest final: public nsXHREventTarget,
public WorkerHolder
public WorkerFeature
{
public:
struct StateData

Просмотреть файл

@ -38,7 +38,7 @@ EXPORTS.mozilla.dom.workers.bindings += [
'ServiceWorkerWindowClient.h',
'SharedWorker.h',
'URL.h',
'WorkerHolder.h',
'WorkerFeature.h',
'XMLHttpRequest.h',
'XMLHttpRequestUpload.h',
]
@ -82,7 +82,6 @@ UNIFIED_SOURCES += [
'SharedWorker.cpp',
'URL.cpp',
'WorkerDebuggerManager.cpp',
'WorkerHolder.cpp',
'WorkerLocation.cpp',
'WorkerNavigator.cpp',
'WorkerPrivate.cpp',

Просмотреть файл

@ -5,8 +5,7 @@ var p = new Promise(function(resolve, reject) {
// This prevents that runnable from running until the window calls terminate(),
// at which point the worker goes into the Canceling state and then an
// HoldWorker() is attempted, which fails, which used to result in
// multiple calls to the error reporter, one after the worker's context had
// been GCed.
// AddFeature() is attempted, which fails, which used to result in multiple
// calls to the error reporter, one after the worker's context had been GCed.
while (true);
});

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozilla/unused.h"
#include "mozilla/dom/PContentChild.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "nsIAsyncInputStream.h"
#include "nsICancelableRunnable.h"
@ -23,13 +23,13 @@ namespace ipc {
using mozilla::dom::PContentChild;
using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
using mozilla::dom::workers::Status;
using mozilla::dom::workers::WorkerHolder;
using mozilla::dom::workers::WorkerFeature;
using mozilla::dom::workers::WorkerPrivate;
namespace {
class SendStreamChildImpl final : public SendStreamChild
, public WorkerHolder
, public WorkerFeature
{
public:
explicit SendStreamChildImpl(nsIAsyncInputStream* aStream);
@ -39,7 +39,7 @@ public:
void StartDestroy() override;
bool
AddAsWorkerHolder(dom::workers::WorkerPrivate* aWorkerPrivate);
AddAsWorkerFeature(dom::workers::WorkerPrivate* aWorkerPrivate);
private:
class Callback;
@ -51,7 +51,7 @@ private:
virtual bool
RecvRequestClose(const nsresult& aRv) override;
// WorkerHolder methods
// WorkerFeature methods
virtual bool
Notify(Status aStatus) override;
@ -93,7 +93,7 @@ public:
// If this fails, then it means the owning thread is a Worker that has
// been shutdown. Its ok to lose the event in this case because the
// SendStreamChild listens for this event through the WorkerHolder.
// SendStreamChild listens for this event through the Feature.
nsresult rv = mOwningThread->Dispatch(this, nsIThread::DISPATCH_NORMAL);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch stream readable event to owning thread");
@ -117,7 +117,7 @@ public:
{
// Cancel() gets called when the Worker thread is being shutdown. We have
// nothing to do here because SendStreamChild handles this case via
// the WorkerHolder.
// the Feature.
return NS_OK;
}
@ -180,11 +180,11 @@ SendStreamChildImpl::StartDestroy()
}
bool
SendStreamChildImpl::AddAsWorkerHolder(WorkerPrivate* aWorkerPrivate)
SendStreamChildImpl::AddAsWorkerFeature(WorkerPrivate* aWorkerPrivate)
{
NS_ASSERT_OWNINGTHREAD(SendStreamChild);
MOZ_ASSERT(aWorkerPrivate);
bool result = HoldWorker(aWorkerPrivate);
bool result = aWorkerPrivate->AddFeature(this);
if (result) {
mWorkerPrivate = aWorkerPrivate;
}
@ -207,7 +207,7 @@ SendStreamChildImpl::ActorDestroy(ActorDestroyReason aReason)
}
if (mWorkerPrivate) {
ReleaseWorker();
mWorkerPrivate->RemoveFeature(this);
mWorkerPrivate = nullptr;
}
}
@ -405,7 +405,7 @@ SendStreamChild::Create(nsIAsyncInputStream* aInputStream,
SendStreamChildImpl* actor = new SendStreamChildImpl(aInputStream);
if (workerPrivate && !actor->AddAsWorkerHolder(workerPrivate)) {
if (workerPrivate && !actor->AddAsWorkerFeature(workerPrivate)) {
delete actor;
return nullptr;
}