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

Side by Side Diff: third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp

Issue 2910953002: Worklet: Enqueue tasks into outsideSetting's event loop (Closed)
Patch Set: fix Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/workers/MainThreadWorkletGlobalScope.h" 5 #include "core/workers/MainThreadWorkletGlobalScope.h"
6 6
7 #include "bindings/core/v8/ScriptSourceCode.h" 7 #include "bindings/core/v8/ScriptSourceCode.h"
8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Modulator.h" 10 #include "core/dom/Modulator.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 Deprecation::CountDeprecation(GetFrame(), feature); 45 Deprecation::CountDeprecation(GetFrame(), feature);
46 } 46 }
47 47
48 WorkerThread* MainThreadWorkletGlobalScope::GetThread() const { 48 WorkerThread* MainThreadWorkletGlobalScope::GetThread() const {
49 NOTREACHED(); 49 NOTREACHED();
50 return nullptr; 50 return nullptr;
51 } 51 }
52 52
53 // Implementation of the first half of the "fetch and invoke a worklet script" 53 // Implementation of the first half of the "fetch and invoke a worklet script"
54 // algorithm: 54 // algorithm:
55 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script 55 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
falken 2017/05/30 01:33:23 Not sure if this documentation is better on the im
nhiroki 2017/05/30 02:14:23 Yeah, it makes sense. Added a comment on the heade
56 void MainThreadWorkletGlobalScope::FetchAndInvokeScript( 56 void MainThreadWorkletGlobalScope::FetchAndInvokeScript(
57 const KURL& module_url_record, 57 const KURL& module_url_record,
58 WebURLRequest::FetchCredentialsMode credentials_mode, 58 WebURLRequest::FetchCredentialsMode credentials_mode,
59 ParentFrameTaskRunners* task_runners,
59 WorkletPendingTasks* pending_tasks) { 60 WorkletPendingTasks* pending_tasks) {
60 DCHECK(IsMainThread()); 61 DCHECK(IsMainThread());
61 // Step 1: "Let insideSettings be the workletGlobalScope's associated 62 // Step 1: "Let insideSettings be the workletGlobalScope's associated
62 // environment settings object." 63 // environment settings object."
63 // Step 2: "Let script by the result of fetch a worklet script given 64 // Step 2: "Let script by the result of fetch a worklet script given
64 // moduleURLRecord, moduleResponsesMap, credentialOptions, outsideSettings, 65 // moduleURLRecord, moduleResponsesMap, credentialOptions, outsideSettings,
65 // and insideSettings when it asynchronously completes." 66 // and insideSettings when it asynchronously completes."
66 String nonce = ""; 67 String nonce = "";
67 ParserDisposition parser_state = kNotParserInserted; 68 ParserDisposition parser_state = kNotParserInserted;
68 Modulator* modulator = Modulator::From(ScriptController()->GetScriptState()); 69 Modulator* modulator = Modulator::From(ScriptController()->GetScriptState());
69 ModuleScriptFetchRequest module_request(module_url_record, nonce, 70 ModuleScriptFetchRequest module_request(module_url_record, nonce,
70 parser_state, credentials_mode); 71 parser_state, credentials_mode);
71 72
72 // Step 3 to 5 are implemented in 73 // Step 3 to 5 are implemented in
73 // WorkletModuleTreeClient::NotifyModuleTreeLoadFinished. 74 // WorkletModuleTreeClient::NotifyModuleTreeLoadFinished.
74 WorkletModuleTreeClient* client = 75 WorkletModuleTreeClient* client =
75 new WorkletModuleTreeClient(modulator, pending_tasks); 76 new WorkletModuleTreeClient(modulator, task_runners, pending_tasks);
76 modulator->FetchTree(module_request, client); 77 modulator->FetchTree(module_request, client);
77 } 78 }
78 79
79 // TODO(nhiroki): Add tests for termination. 80 // TODO(nhiroki): Add tests for termination.
80 void MainThreadWorkletGlobalScope::Terminate() { 81 void MainThreadWorkletGlobalScope::Terminate() {
81 Dispose(); 82 Dispose();
82 } 83 }
83 84
84 void MainThreadWorkletGlobalScope::AddConsoleMessage( 85 void MainThreadWorkletGlobalScope::AddConsoleMessage(
85 ConsoleMessage* console_message) { 86 ConsoleMessage* console_message) {
86 GetFrame()->Console().AddMessage(console_message); 87 GetFrame()->Console().AddMessage(console_message);
87 } 88 }
88 89
89 void MainThreadWorkletGlobalScope::ExceptionThrown(ErrorEvent* event) { 90 void MainThreadWorkletGlobalScope::ExceptionThrown(ErrorEvent* event) {
90 MainThreadDebugger::Instance()->ExceptionThrown(this, event); 91 MainThreadDebugger::Instance()->ExceptionThrown(this, event);
91 } 92 }
92 93
93 CoreProbeSink* MainThreadWorkletGlobalScope::GetProbeSink() { 94 CoreProbeSink* MainThreadWorkletGlobalScope::GetProbeSink() {
94 return probe::ToCoreProbeSink(GetFrame()); 95 return probe::ToCoreProbeSink(GetFrame());
95 } 96 }
96 97
97 DEFINE_TRACE(MainThreadWorkletGlobalScope) { 98 DEFINE_TRACE(MainThreadWorkletGlobalScope) {
98 WorkletGlobalScope::Trace(visitor); 99 WorkletGlobalScope::Trace(visitor);
99 ContextClient::Trace(visitor); 100 ContextClient::Trace(visitor);
100 } 101 }
101 102
102 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698