зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1181577 Delay creation of QuotaInitRunnable until Cache Context actually started. r=ehsan
This commit is contained in:
Родитель
10bac27e88
Коммит
7d441b2d5c
|
@ -786,19 +786,21 @@ already_AddRefed<Context>
|
||||||
Context::Create(Manager* aManager, nsIThread* aTarget,
|
Context::Create(Manager* aManager, nsIThread* aTarget,
|
||||||
Action* aInitAction, Context* aOldContext)
|
Action* aInitAction, Context* aOldContext)
|
||||||
{
|
{
|
||||||
nsRefPtr<Context> context = new Context(aManager, aTarget);
|
nsRefPtr<Context> context = new Context(aManager, aTarget, aInitAction);
|
||||||
context->Init(aInitAction, aOldContext);
|
context->Init(aOldContext);
|
||||||
return context.forget();
|
return context.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::Context(Manager* aManager, nsIThread* aTarget)
|
Context::Context(Manager* aManager, nsIThread* aTarget, Action* aInitAction)
|
||||||
: mManager(aManager)
|
: mManager(aManager)
|
||||||
, mTarget(aTarget)
|
, mTarget(aTarget)
|
||||||
, mData(new Data(aTarget))
|
, mData(new Data(aTarget))
|
||||||
, mState(STATE_CONTEXT_PREINIT)
|
, mState(STATE_CONTEXT_PREINIT)
|
||||||
, mOrphanedData(false)
|
, mOrphanedData(false)
|
||||||
|
, mInitAction(aInitAction)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mManager);
|
MOZ_ASSERT(mManager);
|
||||||
|
MOZ_ASSERT(mTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -826,10 +828,11 @@ Context::CancelAll()
|
||||||
{
|
{
|
||||||
NS_ASSERT_OWNINGTHREAD(Context);
|
NS_ASSERT_OWNINGTHREAD(Context);
|
||||||
|
|
||||||
// In PREINIT state we have not dispatch the init runnable yet. Just
|
// In PREINIT state we have not dispatch the init action yet. Just
|
||||||
// forget it.
|
// forget it.
|
||||||
if (mState == STATE_CONTEXT_PREINIT) {
|
if (mState == STATE_CONTEXT_PREINIT) {
|
||||||
mInitRunnable = nullptr;
|
MOZ_ASSERT(!mInitRunnable);
|
||||||
|
mInitAction = nullptr;
|
||||||
|
|
||||||
// In INIT state we have dispatched the runnable, but not received the
|
// In INIT state we have dispatched the runnable, but not received the
|
||||||
// async completion yet. Cancel the runnable, but don't forget about it
|
// async completion yet. Cancel the runnable, but don't forget about it
|
||||||
|
@ -918,14 +921,9 @@ Context::~Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Context::Init(Action* aInitAction, Context* aOldContext)
|
Context::Init(Context* aOldContext)
|
||||||
{
|
{
|
||||||
NS_ASSERT_OWNINGTHREAD(Context);
|
NS_ASSERT_OWNINGTHREAD(Context);
|
||||||
MOZ_ASSERT(!mInitRunnable);
|
|
||||||
|
|
||||||
// Do this here to avoid doing an AddRef() in the constructor
|
|
||||||
mInitRunnable = new QuotaInitRunnable(this, mManager, mData, mTarget,
|
|
||||||
aInitAction);
|
|
||||||
|
|
||||||
if (aOldContext) {
|
if (aOldContext) {
|
||||||
aOldContext->SetNextContext(this);
|
aOldContext->SetNextContext(this);
|
||||||
|
@ -944,10 +942,17 @@ Context::Start()
|
||||||
// In this case, just do nothing here.
|
// In this case, just do nothing here.
|
||||||
if (mState == STATE_CONTEXT_CANCELED) {
|
if (mState == STATE_CONTEXT_CANCELED) {
|
||||||
MOZ_ASSERT(!mInitRunnable);
|
MOZ_ASSERT(!mInitRunnable);
|
||||||
|
MOZ_ASSERT(!mInitAction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(mState == STATE_CONTEXT_PREINIT);
|
MOZ_ASSERT(mState == STATE_CONTEXT_PREINIT);
|
||||||
|
MOZ_ASSERT(!mInitRunnable);
|
||||||
|
|
||||||
|
mInitRunnable = new QuotaInitRunnable(this, mManager, mData, mTarget,
|
||||||
|
mInitAction);
|
||||||
|
mInitAction = nullptr;
|
||||||
|
|
||||||
mState = STATE_CONTEXT_INIT;
|
mState = STATE_CONTEXT_INIT;
|
||||||
|
|
||||||
nsresult rv = mInitRunnable->Dispatch();
|
nsresult rv = mInitRunnable->Dispatch();
|
||||||
|
|
|
@ -184,9 +184,9 @@ private:
|
||||||
nsRefPtr<Action> mAction;
|
nsRefPtr<Action> mAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
Context(Manager* aManager, nsIThread* aTarget);
|
Context(Manager* aManager, nsIThread* aTarget, Action* aInitAction);
|
||||||
~Context();
|
~Context();
|
||||||
void Init(Action* aInitAction, Context* aOldContext);
|
void Init(Context* aOldContext);
|
||||||
void Start();
|
void Start();
|
||||||
void DispatchAction(Action* aAction, bool aDoomData = false);
|
void DispatchAction(Action* aAction, bool aDoomData = false);
|
||||||
void OnQuotaInit(nsresult aRv, const QuotaInfo& aQuotaInfo,
|
void OnQuotaInit(nsresult aRv, const QuotaInfo& aQuotaInfo,
|
||||||
|
@ -208,6 +208,7 @@ private:
|
||||||
bool mOrphanedData;
|
bool mOrphanedData;
|
||||||
QuotaInfo mQuotaInfo;
|
QuotaInfo mQuotaInfo;
|
||||||
nsRefPtr<QuotaInitRunnable> mInitRunnable;
|
nsRefPtr<QuotaInitRunnable> mInitRunnable;
|
||||||
|
nsRefPtr<Action> mInitAction;
|
||||||
nsTArray<PendingAction> mPendingActions;
|
nsTArray<PendingAction> mPendingActions;
|
||||||
|
|
||||||
// Weak refs since activites must remove themselves from this list before
|
// Weak refs since activites must remove themselves from this list before
|
||||||
|
|
Загрузка…
Ссылка в новой задаче