Bug 1008338 - Add WorkerScriptExecutedSuccessfully(). r=bent

This commit is contained in:
Nikhil Marathe 2014-05-29 09:33:04 -07:00
parent 46913d3906
commit b2949dbebd
2 changed files with 25 additions and 2 deletions

View File

@ -879,7 +879,11 @@ private:
} }
JSAutoCompartment ac(aCx, global); JSAutoCompartment ac(aCx, global);
return scriptloader::LoadWorkerScript(aCx); bool result = scriptloader::LoadWorkerScript(aCx);
if (result) {
aWorkerPrivate->SetWorkerScriptExecutedSuccessfully();
}
return result;
} }
}; };
@ -3558,7 +3562,8 @@ WorkerPrivate::WorkerPrivate(JSContext* aCx,
mRunningExpiredTimeouts(false), mCloseHandlerStarted(false), mRunningExpiredTimeouts(false), mCloseHandlerStarted(false),
mCloseHandlerFinished(false), mMemoryReporterRunning(false), mCloseHandlerFinished(false), mMemoryReporterRunning(false),
mBlockedForMemoryReporter(false), mCancelAllPendingRunnables(false), mBlockedForMemoryReporter(false), mCancelAllPendingRunnables(false),
mPeriodicGCTimerRunning(false), mIdleGCTimerRunning(false) mPeriodicGCTimerRunning(false), mIdleGCTimerRunning(false),
mWorkerScriptExecutedSuccessfully(false)
#ifdef DEBUG #ifdef DEBUG
, mPRThread(nullptr) , mPRThread(nullptr)
#endif #endif

View File

@ -785,6 +785,7 @@ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
bool mCancelAllPendingRunnables; bool mCancelAllPendingRunnables;
bool mPeriodicGCTimerRunning; bool mPeriodicGCTimerRunning;
bool mIdleGCTimerRunning; bool mIdleGCTimerRunning;
bool mWorkerScriptExecutedSuccessfully;
#ifdef DEBUG #ifdef DEBUG
PRThread* mPRThread; PRThread* mPRThread;
@ -1068,6 +1069,23 @@ public:
{ } { }
#endif #endif
void
SetWorkerScriptExecutedSuccessfully()
{
AssertIsOnWorkerThread();
// Should only be called once!
MOZ_ASSERT(!mWorkerScriptExecutedSuccessfully);
mWorkerScriptExecutedSuccessfully = true;
}
// Only valid after CompileScriptRunnable has finished running!
bool
WorkerScriptExecutedSuccessfully() const
{
AssertIsOnWorkerThread();
return mWorkerScriptExecutedSuccessfully;
}
private: private:
WorkerPrivate(JSContext* aCx, WorkerPrivate* aParent, WorkerPrivate(JSContext* aCx, WorkerPrivate* aParent,
const nsAString& aScriptURL, bool aIsChromeWorker, const nsAString& aScriptURL, bool aIsChromeWorker,