Bug 1432963 - Fixing workers headers - part 10 - ScriptLoader into a workerinternals namespace, r=smaug

This commit is contained in:
Andrea Marchesini 2018-01-31 08:22:03 +01:00
Родитель 8df05ffda6
Коммит 6757fa2f75
5 изменённых файлов: 41 добавлений и 39 удалений

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

@ -75,12 +75,15 @@
USING_WORKERS_NAMESPACE
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::dom::cache::Cache;
using mozilla::dom::cache::CacheStorage;
using mozilla::ipc::PrincipalInfo;
namespace mozilla {
namespace dom {
using namespace workers;
namespace {
nsIURI*
@ -1921,17 +1924,17 @@ public:
clientInfo.emplace(mClientInfo);
nsCOMPtr<nsIChannel> channel;
mResult =
scriptloader::ChannelFromScriptURLMainThread(mLoadInfo.mLoadingPrincipal,
baseURI, parentDoc,
mLoadInfo.mLoadGroup,
mScriptURL,
clientInfo,
// Nested workers are always dedicated.
nsIContentPolicy::TYPE_INTERNAL_WORKER,
// Nested workers use default uri encoding.
true,
getter_AddRefs(channel));
mResult = workerinternals::
ChannelFromScriptURLMainThread(mLoadInfo.mLoadingPrincipal,
baseURI, parentDoc,
mLoadInfo.mLoadGroup,
mScriptURL,
clientInfo,
// Nested workers are always dedicated.
nsIContentPolicy::TYPE_INTERNAL_WORKER,
// Nested workers use default uri encoding.
true,
getter_AddRefs(channel));
NS_ENSURE_SUCCESS(mResult, true);
mResult = mLoadInfo.SetPrincipalFromChannel(channel);
@ -2048,8 +2051,8 @@ 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(mScriptLoader.mRv,
loadInfo.mLoadResult, loadInfo.mURL);
workerinternals::ReportLoadError(mScriptLoader.mRv,
loadInfo.mLoadResult, loadInfo.mURL);
// Top level scripts only!
if (mIsWorkerScript) {
aWorkerPrivate->MaybeDispatchLoadFailedRunnable();
@ -2255,9 +2258,7 @@ LoadAllScripts(WorkerPrivate* aWorkerPrivate,
} /* anonymous namespace */
BEGIN_WORKERS_NAMESPACE
namespace scriptloader {
namespace workerinternals {
nsresult
ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
@ -2404,6 +2405,7 @@ Load(WorkerPrivate* aWorkerPrivate,
LoadAllScripts(aWorkerPrivate, loadInfos, false, aWorkerScriptType, aRv);
}
} // namespace scriptloader
} // namespace workerinternals
END_WORKERS_NAMESPACE
} // dom namespace
} // mozilla namespace

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

@ -23,19 +23,18 @@ class ErrorResult;
namespace dom {
namespace workers {
class WorkerPrivate;
}
struct WorkerLoadInfo;
} // dom namespace
} // namespace mozilla
BEGIN_WORKERS_NAMESPACE
enum WorkerScriptType {
WorkerScript,
DebuggerScript
};
namespace scriptloader {
namespace workerinternals {
nsresult
ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
@ -50,25 +49,26 @@ ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
nsresult
ChannelFromScriptURLWorkerThread(JSContext* aCx,
WorkerPrivate* aParent,
workers::WorkerPrivate* aParent,
const nsAString& aScriptURL,
WorkerLoadInfo& aLoadInfo);
void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
const nsAString& aScriptURL);
void LoadMainScript(WorkerPrivate* aWorkerPrivate,
void LoadMainScript(workers::WorkerPrivate* aWorkerPrivate,
const nsAString& aScriptURL,
WorkerScriptType aWorkerScriptType,
ErrorResult& aRv);
void Load(WorkerPrivate* aWorkerPrivate,
void Load(workers::WorkerPrivate* aWorkerPrivate,
const nsTArray<nsString>& aScriptURLs,
WorkerScriptType aWorkerScriptType,
mozilla::ErrorResult& aRv);
ErrorResult& aRv);
} // namespace scriptloader
} // namespace workerinternals
END_WORKERS_NAMESPACE
} // dom namespace
} // namespace mozilla
#endif /* mozilla_dom_workers_scriptloader_h__ */

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

@ -103,8 +103,8 @@ private:
ErrorResult rv;
JSAutoCompartment ac(aCx, global);
scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL,
DebuggerScript, rv);
workerinternals::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

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

@ -435,7 +435,7 @@ private:
}
ErrorResult rv;
scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL, WorkerScript, rv);
workerinternals::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
@ -3076,7 +3076,7 @@ WorkerPrivate::Constructor(JSContext* aCx,
aWorkerType, stackLoadInfo.ptr());
aRv.MightThrowJSException();
if (NS_FAILED(rv)) {
scriptloader::ReportLoadError(aRv, rv, aScriptURL);
workerinternals::ReportLoadError(aRv, rv, aScriptURL);
return nullptr;
}
@ -3148,7 +3148,7 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
WorkerType aWorkerType,
WorkerLoadInfo* aLoadInfo)
{
using namespace mozilla::dom::workers::scriptloader;
using namespace mozilla::dom::workerinternals;
MOZ_ASSERT(aCx);
MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());

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

@ -254,7 +254,7 @@ WorkerGlobalScope::ImportScripts(const Sequence<nsString>& aScriptURLs,
ErrorResult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
scriptloader::Load(mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
workerinternals::Load(mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
}
int32_t
@ -995,7 +995,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx,
nsTArray<nsString> urls;
urls.AppendElement(aURL);
scriptloader::Load(mWorkerPrivate, urls, DebuggerScript, aRv);
workerinternals::Load(mWorkerPrivate, urls, DebuggerScript, aRv);
}
void