зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1592488 - P9. Make a DOMCacheThread an AbstractThread. r=baku
This is a step towards bug 1119864. However, at this stage we only need the cache thread to support direct task dispatch so that we can have IPDL MozPromise acting in a similar fashion to JS promise. Differential Revision: https://phabricator.services.mozilla.com/D74637
This commit is contained in:
Родитель
bbe6a0bfb5
Коммит
dde81db3d7
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/cache/Manager.h"
|
||||
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
|
@ -25,7 +26,7 @@
|
|||
#include "nsIInputStream.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsISerialEventTarget.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "QuotaClientImpl.h"
|
||||
|
@ -251,8 +252,11 @@ class Manager::Factory {
|
|||
return Err(rv);
|
||||
}
|
||||
|
||||
ref = MakeSafeRefPtr<Manager>(aManagerId.clonePtr(), ioThread,
|
||||
ConstructorGuard{});
|
||||
ref = MakeSafeRefPtr<Manager>(
|
||||
aManagerId.clonePtr(),
|
||||
AbstractThread::CreateXPCOMThreadWrapper(
|
||||
ioThread, false /* aRequireTailDispatch */),
|
||||
ConstructorGuard{});
|
||||
|
||||
// There may be an old manager for this origin in the process of
|
||||
// cleaning up. We need to tell the new manager about this so
|
||||
|
@ -1887,7 +1891,8 @@ void Manager::ExecutePutAll(
|
|||
pinnedContext->Dispatch(action);
|
||||
}
|
||||
|
||||
Manager::Manager(SafeRefPtr<ManagerId> aManagerId, nsIThread* aIOThread,
|
||||
Manager::Manager(SafeRefPtr<ManagerId> aManagerId,
|
||||
already_AddRefed<nsISerialEventTarget> aIOThread,
|
||||
const ConstructorGuard&)
|
||||
: mManagerId(std::move(aManagerId)),
|
||||
mIOThread(aIOThread),
|
||||
|
@ -1902,14 +1907,6 @@ Manager::~Manager() {
|
|||
NS_ASSERT_OWNINGTHREAD(Manager);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mState == Closing);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mContext);
|
||||
|
||||
nsCOMPtr<nsIThread> ioThread;
|
||||
mIOThread.swap(ioThread);
|
||||
|
||||
// Don't spin the event loop in the destructor waiting for the thread to
|
||||
// shutdown. Defer this to the main thread, instead.
|
||||
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(
|
||||
"nsIThread::AsyncShutdown", ioThread, &nsIThread::AsyncShutdown)));
|
||||
}
|
||||
|
||||
void Manager::Init(Maybe<Manager&> aOldManager) {
|
||||
|
@ -1920,7 +1917,7 @@ void Manager::Init(Maybe<Manager&> aOldManager) {
|
|||
// Context goes away.
|
||||
RefPtr<Action> setupAction = new SetupAction();
|
||||
SafeRefPtr<Context> ref = Context::Create(
|
||||
SafeRefPtrFromThis(), mIOThread->SerialEventTarget(), setupAction,
|
||||
SafeRefPtrFromThis(), mIOThread, setupAction,
|
||||
aOldManager ? SomeRef(*aOldManager->mContext) : Nothing());
|
||||
mContext = ref.unsafeGetRawPtr();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nsTArray.h"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsIThread;
|
||||
class nsISerialEventTarget;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -213,7 +213,7 @@ class Manager final : public SafeRefCounted<Manager> {
|
|||
void MaybeAllowContextToClose();
|
||||
|
||||
SafeRefPtr<ManagerId> mManagerId;
|
||||
nsCOMPtr<nsIThread> mIOThread;
|
||||
nsCOMPtr<nsISerialEventTarget> mIOThread;
|
||||
|
||||
// Weak reference cleared by RemoveContext() in Context destructor.
|
||||
Context* MOZ_NON_OWNING_REF mContext;
|
||||
|
@ -270,7 +270,8 @@ class Manager final : public SafeRefCounted<Manager> {
|
|||
struct ConstructorGuard {};
|
||||
|
||||
public:
|
||||
Manager(SafeRefPtr<ManagerId> aManagerId, nsIThread* aIOThread,
|
||||
Manager(SafeRefPtr<ManagerId> aManagerId,
|
||||
already_AddRefed<nsISerialEventTarget> aIOThread,
|
||||
const ConstructorGuard&);
|
||||
~Manager();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче