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

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

Issue 2819153003: Worklet: Separate Worklet into MainThreadWorklet and ThreadedWorklet (Closed)
Patch Set: update comments Created 3 years, 8 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/MainThreadWorklet.cpp
diff --git a/third_party/WebKit/Source/core/workers/Worklet.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
similarity index 65%
copy from third_party/WebKit/Source/core/workers/Worklet.cpp
copy to third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
index a5f9e2a9956dbb53af533920a85f9558f047f120..d58013c098195d78b2ff592ad093502e8580a90d 100644
--- a/third_party/WebKit/Source/core/workers/Worklet.cpp
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
@@ -1,8 +1,8 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/workers/Worklet.h"
+#include "core/workers/MainThreadWorklet.h"
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/V8Binding.h"
@@ -15,10 +15,10 @@
namespace blink {
-Worklet::Worklet(LocalFrame* frame)
- : ContextLifecycleObserver(frame->GetDocument()), frame_(frame) {}
+MainThreadWorklet::MainThreadWorklet(LocalFrame* frame) : Worklet(frame) {}
-ScriptPromise Worklet::import(ScriptState* script_state, const String& url) {
+ScriptPromise MainThreadWorklet::import(ScriptState* script_state,
+ const String& url) {
DCHECK(IsMainThread());
if (!GetExecutionContext()) {
return ScriptPromise::RejectWithDOMException(
@@ -41,17 +41,17 @@ ScriptPromise Worklet::import(ScriptState* script_state, const String& url) {
WorkletScriptLoader* script_loader =
WorkletScriptLoader::Create(frame_->GetDocument()->Fetcher(), this);
- loader_and_resolvers_.Set(script_loader, resolver);
+ loader_to_resolver_map_.Set(script_loader, resolver);
script_loader->FetchScript(script_url);
return promise;
}
-void Worklet::NotifyWorkletScriptLoadingFinished(
+void MainThreadWorklet::NotifyWorkletScriptLoadingFinished(
WorkletScriptLoader* script_loader,
const ScriptSourceCode& source_code) {
DCHECK(IsMainThread());
- ScriptPromiseResolver* resolver = loader_and_resolvers_.at(script_loader);
- loader_and_resolvers_.erase(script_loader);
+ ScriptPromiseResolver* resolver = loader_to_resolver_map_.at(script_loader);
+ loader_to_resolver_map_.erase(script_loader);
if (!script_loader->WasScriptLoadSuccessful()) {
resolver->Reject(DOMException::Create(kNetworkError));
@@ -62,20 +62,17 @@ void Worklet::NotifyWorkletScriptLoadingFinished(
resolver->Resolve();
}
-void Worklet::ContextDestroyed(ExecutionContext*) {
+void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) {
DCHECK(IsMainThread());
- if (IsInitialized())
- GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope();
- for (const auto& script_loader : loader_and_resolvers_.Keys())
+ for (const auto& script_loader : loader_to_resolver_map_.Keys())
script_loader->Cancel();
- loader_and_resolvers_.Clear();
- frame_ = nullptr;
+ loader_to_resolver_map_.Clear();
+ Worklet::ContextDestroyed(execution_context);
}
-DEFINE_TRACE(Worklet) {
- visitor->Trace(frame_);
- visitor->Trace(loader_and_resolvers_);
- ContextLifecycleObserver::Trace(visitor);
+DEFINE_TRACE(MainThreadWorklet) {
+ visitor->Trace(loader_to_resolver_map_);
+ Worklet::Trace(visitor);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/MainThreadWorklet.h ('k') | third_party/WebKit/Source/core/workers/ThreadedWorklet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698