зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1247687 - Add WorkerModuleLoader skeleton; r=jonco
Initial Skeleton for module loader work. Depends on D134052 Differential Revision: https://phabricator.services.mozilla.com/D147324
This commit is contained in:
Родитель
445cbc45f5
Коммит
8c2e39f053
|
@ -0,0 +1,66 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
||||
#include "WorkerModuleLoader.h"
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla::dom::workerinternals::loader {
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// WorkerModuleLoader
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(WorkerModuleLoader, JS::loader::ModuleLoaderBase)
|
||||
NS_IMPL_RELEASE_INHERITED(WorkerModuleLoader, JS::loader::ModuleLoaderBase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(WorkerModuleLoader,
|
||||
JS::loader::ModuleLoaderBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkerModuleLoader)
|
||||
NS_INTERFACE_MAP_END_INHERITING(JS::loader::ModuleLoaderBase)
|
||||
|
||||
WorkerModuleLoader::WorkerModuleLoader(WorkerScriptLoader* aScriptLoader,
|
||||
nsIGlobalObject* aGlobalObject,
|
||||
nsISerialEventTarget* aEventTarget)
|
||||
: ModuleLoaderBase(aScriptLoader, aGlobalObject, aEventTarget) {}
|
||||
|
||||
already_AddRefed<ModuleLoadRequest> WorkerModuleLoader::CreateStaticImport(
|
||||
nsIURI* aURI, ModuleLoadRequest* aParent) {
|
||||
MOZ_CRASH("Not implemented yet");
|
||||
}
|
||||
|
||||
already_AddRefed<ModuleLoadRequest> WorkerModuleLoader::CreateDynamicImport(
|
||||
JSContext* aCx, nsIURI* aURI, LoadedScript* aMaybeActiveScript,
|
||||
JS::Handle<JS::Value> aReferencingPrivate, JS::Handle<JSString*> aSpecifier,
|
||||
JS::Handle<JSObject*> aPromise) {
|
||||
// TODO: Implement for Dedicated workers. Not supported for Service Workers.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool WorkerModuleLoader::CanStartLoad(ModuleLoadRequest* aRequest,
|
||||
nsresult* aRvOut) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult WorkerModuleLoader::StartFetch(ModuleLoadRequest* aRequest) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult WorkerModuleLoader::CompileFetchedModule(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::CompileOptions& aOptions,
|
||||
ModuleLoadRequest* aRequest, JS::MutableHandle<JSObject*> aModuleScript) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
WorkerScriptLoader* WorkerModuleLoader::GetScriptLoader() {
|
||||
return static_cast<WorkerScriptLoader*>(mLoader.get());
|
||||
}
|
||||
|
||||
void WorkerModuleLoader::OnModuleLoadComplete(ModuleLoadRequest* aRequest) {}
|
||||
|
||||
} // namespace mozilla::dom::workerinternals::loader
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_loader_WorkerModuleLoader_h
|
||||
#define mozilla_loader_WorkerModuleLoader_h
|
||||
|
||||
#include "js/loader/ModuleLoaderBase.h"
|
||||
|
||||
namespace mozilla::dom::workerinternals::loader {
|
||||
class WorkerScriptLoader;
|
||||
|
||||
// alias common classes
|
||||
using ScriptFetchOptions = JS::loader::ScriptFetchOptions;
|
||||
using ScriptKind = JS::loader::ScriptKind;
|
||||
using ScriptLoadRequest = JS::loader::ScriptLoadRequest;
|
||||
using ScriptLoadRequestList = JS::loader::ScriptLoadRequestList;
|
||||
using ModuleLoadRequest = JS::loader::ModuleLoadRequest;
|
||||
|
||||
class WorkerModuleLoader : public JS::loader::ModuleLoaderBase {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WorkerModuleLoader,
|
||||
JS::loader::ModuleLoaderBase)
|
||||
|
||||
WorkerModuleLoader(WorkerScriptLoader* aScriptLoader,
|
||||
nsIGlobalObject* aGlobalObject,
|
||||
nsISerialEventTarget* aEventTarget);
|
||||
|
||||
private:
|
||||
~WorkerModuleLoader() = default;
|
||||
|
||||
WorkerScriptLoader* GetScriptLoader();
|
||||
|
||||
already_AddRefed<ModuleLoadRequest> CreateStaticImport(
|
||||
nsIURI* aURI, ModuleLoadRequest* aParent) override;
|
||||
|
||||
already_AddRefed<ModuleLoadRequest> CreateDynamicImport(
|
||||
JSContext* aCx, nsIURI* aURI, LoadedScript* aMaybeActiveScript,
|
||||
JS::Handle<JS::Value> aReferencingPrivate,
|
||||
JS::Handle<JSString*> aSpecifier,
|
||||
JS::Handle<JSObject*> aPromise) override;
|
||||
|
||||
bool CanStartLoad(ModuleLoadRequest* aRequest, nsresult* aRvOut) override;
|
||||
|
||||
nsresult StartFetch(ModuleLoadRequest* aRequest) override;
|
||||
|
||||
nsresult CompileFetchedModule(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aGlobal,
|
||||
JS::CompileOptions& aOptions, ModuleLoadRequest* aRequest,
|
||||
JS::MutableHandle<JSObject*> aModuleScript) override;
|
||||
|
||||
void OnModuleLoadComplete(ModuleLoadRequest* aRequest) override;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom::workerinternals::loader
|
||||
#endif // mozilla_loader_WorkerModuleLoader_h
|
|
@ -17,6 +17,7 @@ EXPORTS.mozilla.dom.workerinternals += [
|
|||
"CacheLoadHandler.h",
|
||||
"NetworkLoadHandler.h",
|
||||
"ScriptResponseHeaderProcessor.h",
|
||||
"WorkerModuleLoader.h",
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -24,6 +25,7 @@ UNIFIED_SOURCES += [
|
|||
"NetworkLoadHandler.cpp",
|
||||
"ScriptResponseHeaderProcessor.cpp",
|
||||
"WorkerLoadContext.cpp",
|
||||
"WorkerModuleLoader.cpp",
|
||||
]
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче