Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1897)

Unified Diff: third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp

Issue 2878833002: Worklet: Move common code of addModule from Main/ThreadedWorklet to Worklet (Closed)
Patch Set: fix crashes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp
diff --git a/third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp b/third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp
index 21b26cfe696d0f87ebdb3f833e741ddd89e6c6a1..972f81a1f8debb19248df22512a22646109a0ec1 100644
--- a/third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp
+++ b/third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp
@@ -15,35 +15,22 @@
namespace blink {
-ThreadedWorklet::ThreadedWorklet(LocalFrame* frame) : Worklet(frame) {}
+ThreadedWorklet::ThreadedWorklet(LocalFrame* frame)
+ : Worklet(frame), frame_(frame) {}
-ScriptPromise ThreadedWorklet::addModule(ScriptState* script_state,
- const String& url) {
+void ThreadedWorklet::FetchAndInvokeScript(const KURL& module_url_record,
+ ScriptPromiseResolver* resolver) {
DCHECK(IsMainThread());
- if (!GetExecutionContext()) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(kInvalidStateError,
- "This frame is already detached"));
- }
-
- KURL script_url = GetExecutionContext()->CompleteURL(url);
- if (!script_url.IsValid()) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(
- kSyntaxError, "'" + url + "' is not a valid URL."));
- }
+ if (!GetExecutionContext())
+ return;
if (!IsInitialized())
Initialize();
- ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
- ScriptPromise promise = resolver->Promise();
-
WorkletScriptLoader* script_loader =
WorkletScriptLoader::Create(frame_->GetDocument()->Fetcher(), this);
loader_to_resolver_map_.Set(script_loader, resolver);
- script_loader->FetchScript(script_url);
- return promise;
+ script_loader->FetchScript(module_url_record);
}
void ThreadedWorklet::NotifyWorkletScriptLoadingFinished(
@@ -69,10 +56,11 @@ void ThreadedWorklet::ContextDestroyed(ExecutionContext* execution_context) {
loader_to_resolver_map_.clear();
if (IsInitialized())
GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope();
- Worklet::ContextDestroyed(execution_context);
+ frame_ = nullptr;
}
DEFINE_TRACE(ThreadedWorklet) {
+ visitor->Trace(frame_);
visitor->Trace(loader_to_resolver_map_);
Worklet::Trace(visitor);
}
« no previous file with comments | « third_party/WebKit/Source/core/workers/ThreadedWorklet.h ('k') | third_party/WebKit/Source/core/workers/Worklet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698