Bug 1252123. Remove some unnecessary JSContext arguments from worker ScriptLoader methods. r=khuey

This commit is contained in:
Boris Zbarsky 2016-02-29 14:52:42 -05:00
parent 663b9bd562
commit 69924c14ce
8 changed files with 24 additions and 28 deletions

View File

@ -742,7 +742,7 @@ FileReader::Shutdown()
}
if (mWorkerPrivate && mBusyCount != 0) {
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
mWorkerPrivate->RemoveFeature(this);
mWorkerPrivate = nullptr;
mBusyCount = 0;
}

View File

@ -1604,7 +1604,7 @@ DOMInterfaces = {
'workers': True,
'concrete': False,
'implicitJSContext': [
'close', 'importScripts',
'close',
],
# Rename a few things so we don't have both classes and methods
# with the same name

View File

@ -1776,7 +1776,7 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
MOZ_ASSERT(!mScriptLoader.mRv.Failed(), "Who failed it and why?");
mScriptLoader.mRv.MightThrowJSException();
if (NS_FAILED(loadInfo.mLoadResult)) {
scriptloader::ReportLoadError(aCx, mScriptLoader.mRv,
scriptloader::ReportLoadError(mScriptLoader.mRv,
loadInfo.mLoadResult, loadInfo.mURL);
// Top level scripts only!
if (mIsWorkerScript) {
@ -1933,7 +1933,7 @@ ScriptExecutorRunnable::LogExceptionToConsole(JSContext* aCx,
}
void
LoadAllScripts(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
LoadAllScripts(WorkerPrivate* aWorkerPrivate,
nsTArray<ScriptLoadInfo>& aLoadInfos, bool aIsMainScript,
WorkerScriptType aWorkerScriptType, ErrorResult& aRv)
{
@ -2019,7 +2019,7 @@ ChannelFromScriptURLWorkerThread(JSContext* aCx,
return getter->GetResult();
}
void ReportLoadError(JSContext* aCx, ErrorResult& aRv, nsresult aLoadResult,
void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
const nsAString& aScriptURL)
{
MOZ_ASSERT(!aRv.Failed());
@ -2072,23 +2072,21 @@ void ReportLoadError(JSContext* aCx, ErrorResult& aRv, nsresult aLoadResult,
}
void
LoadMainScript(JSContext* aCx, const nsAString& aScriptURL,
LoadMainScript(WorkerPrivate* aWorkerPrivate,
const nsAString& aScriptURL,
WorkerScriptType aWorkerScriptType,
ErrorResult& aRv)
{
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
NS_ASSERTION(worker, "This should never be null!");
nsTArray<ScriptLoadInfo> loadInfos;
ScriptLoadInfo* info = loadInfos.AppendElement();
info->mURL = aScriptURL;
LoadAllScripts(aCx, worker, loadInfos, true, aWorkerScriptType, aRv);
LoadAllScripts(aWorkerPrivate, loadInfos, true, aWorkerScriptType, aRv);
}
void
Load(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
Load(WorkerPrivate* aWorkerPrivate,
const nsTArray<nsString>& aScriptURLs, WorkerScriptType aWorkerScriptType,
ErrorResult& aRv)
{
@ -2110,7 +2108,7 @@ Load(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
loadInfos[index].mURL = aScriptURLs[index];
}
LoadAllScripts(aCx, aWorkerPrivate, loadInfos, false, aWorkerScriptType, aRv);
LoadAllScripts(aWorkerPrivate, loadInfos, false, aWorkerScriptType, aRv);
}
} // namespace scriptloader

View File

@ -47,15 +47,15 @@ ChannelFromScriptURLWorkerThread(JSContext* aCx,
const nsAString& aScriptURL,
nsIChannel** aChannel);
void ReportLoadError(JSContext* aCx, ErrorResult& aRv, nsresult aLoadResult,
void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
const nsAString& aScriptURL);
void LoadMainScript(JSContext* aCx, const nsAString& aScriptURL,
void LoadMainScript(WorkerPrivate* aWorkerPrivate,
const nsAString& aScriptURL,
WorkerScriptType aWorkerScriptType,
ErrorResult& aRv);
void Load(JSContext* aCx,
WorkerPrivate* aWorkerPrivate,
void Load(WorkerPrivate* aWorkerPrivate,
const nsTArray<nsString>& aScriptURLs,
WorkerScriptType aWorkerScriptType,
mozilla::ErrorResult& aRv);

View File

@ -390,8 +390,7 @@ class LifeCycleEventWatcher final : public PromiseNativeHandler,
// the resulting Promise.all will be cycle collected and it will drop its
// native handlers (including this object). Instead of waiting for a timeout
// we report the failure now.
JSContext* cx = mWorkerPrivate->GetJSContext();
ReportResult(cx, false);
ReportResult(false);
}
public:

View File

@ -504,7 +504,7 @@ private:
aWorkerPrivate->AssertIsOnWorkerThread();
ErrorResult rv;
scriptloader::LoadMainScript(aCx, mScriptURL, WorkerScript, rv);
scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL, WorkerScript, rv);
rv.WouldReportJSException();
// Explicitly ignore NS_BINDING_ABORTED on rv. Or more precisely, still
// return false and don't SetWorkerScriptExecutedSuccessfully() in that
@ -563,7 +563,8 @@ private:
ErrorResult rv;
JSAutoCompartment ac(aCx, global);
scriptloader::LoadMainScript(aCx, mScriptURL, DebuggerScript, rv);
scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL,
DebuggerScript, rv);
rv.WouldReportJSException();
// Explicitly ignore NS_BINDING_ABORTED on rv. Or more precisely, still
// return false and don't SetWorkerScriptExecutedSuccessfully() in that
@ -574,7 +575,7 @@ private:
return false;
}
// Make sure to propagate exceptions from rv onto aCx, so that our PostRun
// can report it. We do this for alll failures on rv, because now we're
// can report it. We do this for all failures on rv, because now we're
// using rv to track all the state we care about.
if (rv.MaybeSetPendingException(aCx)) {
return false;
@ -4031,7 +4032,7 @@ WorkerPrivate::Constructor(JSContext* aCx,
aWorkerType, stackLoadInfo.ptr());
aRv.MightThrowJSException();
if (NS_FAILED(rv)) {
scriptloader::ReportLoadError(aCx, aRv, rv, aScriptURL);
scriptloader::ReportLoadError(aRv, rv, aScriptURL);
return nullptr;
}

View File

@ -213,12 +213,11 @@ WorkerGlobalScope::SetOnerror(OnErrorEventHandlerNonNull* aHandler)
}
void
WorkerGlobalScope::ImportScripts(JSContext* aCx,
const Sequence<nsString>& aScriptURLs,
WorkerGlobalScope::ImportScripts(const Sequence<nsString>& aScriptURLs,
ErrorResult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
scriptloader::Load(aCx, mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
scriptloader::Load(mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
}
int32_t
@ -887,7 +886,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx,
nsTArray<nsString> urls;
urls.AppendElement(aURL);
scriptloader::Load(aCx, mWorkerPrivate, urls, DebuggerScript, aRv);
scriptloader::Load(mWorkerPrivate, urls, DebuggerScript, aRv);
}
void

View File

@ -105,8 +105,7 @@ public:
SetOnerror(OnErrorEventHandlerNonNull* aHandler);
void
ImportScripts(JSContext* aCx, const Sequence<nsString>& aScriptURLs,
ErrorResult& aRv);
ImportScripts(const Sequence<nsString>& aScriptURLs, ErrorResult& aRv);
int32_t
SetTimeout(JSContext* aCx, Function& aHandler, const int32_t aTimeout,