Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/MainThreadWorklet.h" | 5 #include "core/workers/MainThreadWorklet.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
| 9 #include "bindings/core/v8/V8BindingForCore.h" | 9 #include "bindings/core/v8/V8BindingForCore.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "core/workers/WorkletGlobalScopeProxy.h" | 11 #include "core/workers/WorkletGlobalScopeProxy.h" |
| 12 #include "core/workers/WorkletPendingTasks.h" | 12 #include "core/workers/WorkletPendingTasks.h" |
| 13 #include "platform/WebTaskRunner.h" | |
| 13 #include "platform/wtf/WTF.h" | 14 #include "platform/wtf/WTF.h" |
| 14 #include "public/platform/WebURLRequest.h" | 15 #include "public/platform/WebURLRequest.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 WebURLRequest::FetchCredentialsMode ParseCredentialsOption( | 21 WebURLRequest::FetchCredentialsMode ParseCredentialsOption( |
| 21 const String& credentials_option) { | 22 const String& credentials_option) { |
| 22 if (credentials_option == "omit") | 23 if (credentials_option == "omit") |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 49 DCHECK(IsMainThread()); | 50 DCHECK(IsMainThread()); |
| 50 if (!GetExecutionContext()) | 51 if (!GetExecutionContext()) |
| 51 return; | 52 return; |
| 52 | 53 |
| 53 // Step 6: "Let credentialOptions be the credentials member of options." | 54 // Step 6: "Let credentialOptions be the credentials member of options." |
| 54 // TODO(nhiroki): Add tests for credentialOptions (https://crbug.com/710837). | 55 // TODO(nhiroki): Add tests for credentialOptions (https://crbug.com/710837). |
| 55 WebURLRequest::FetchCredentialsMode credentials_mode = | 56 WebURLRequest::FetchCredentialsMode credentials_mode = |
| 56 ParseCredentialsOption(options.credentials()); | 57 ParseCredentialsOption(options.credentials()); |
| 57 | 58 |
| 58 // Step 7: "Let outsideSettings be the relevant settings object of this." | 59 // Step 7: "Let outsideSettings be the relevant settings object of this." |
| 59 // TODO(nhiroki): outsideSettings will be used for posting a task to the | 60 // In the specification, outsideSettings is used for posting a task to the |
| 60 // document's responsible event loop. We could use a task runner for the | 61 // document's responsible event loop. In our implementation, WebTaskRunner |
| 61 // purpose. | 62 // does this. |
|
kinuko
2017/05/30 04:38:52
Now the last part of this comment reads a bit weir
nhiroki
2017/05/30 05:25:30
Done.
| |
| 63 RefPtr<WebTaskRunner> parent_frame_task_runner = | |
| 64 TaskRunnerHelper::Get(TaskType::kUnspecedLoading, GetExecutionContext()); | |
| 62 | 65 |
| 63 // Step 8: "Let moduleResponsesMap be worklet's module responses map." | 66 // Step 8: "Let moduleResponsesMap be worklet's module responses map." |
| 64 // TODO(nhiroki): Implement moduleResponsesMap (https://crbug.com/627945). | 67 // TODO(nhiroki): Implement moduleResponsesMap (https://crbug.com/627945). |
| 65 | 68 |
| 66 // Step 9: "Let workletGlobalScopeType be worklet's worklet global scope | 69 // Step 9: "Let workletGlobalScopeType be worklet's worklet global scope |
| 67 // type." | 70 // type." |
| 68 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet). | 71 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet). |
| 69 | 72 |
| 70 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following | 73 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following |
| 71 // steps:" | 74 // steps:" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 84 new WorkletPendingTasks(GetNumberOfGlobalScopes(), resolver); | 87 new WorkletPendingTasks(GetNumberOfGlobalScopes(), resolver); |
| 85 | 88 |
| 86 // Step 12: "For each workletGlobalScope in the worklet's | 89 // Step 12: "For each workletGlobalScope in the worklet's |
| 87 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and | 90 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and |
| 88 // invoke a worklet script given workletGlobalScope, moduleURLRecord, | 91 // invoke a worklet script given workletGlobalScope, moduleURLRecord, |
| 89 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct, | 92 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct, |
| 90 // and promise." | 93 // and promise." |
| 91 // TODO(nhiroki): Queue a task instead of executing this here. | 94 // TODO(nhiroki): Queue a task instead of executing this here. |
| 92 for (const auto& proxy : proxies_) { | 95 for (const auto& proxy : proxies_) { |
| 93 proxy->FetchAndInvokeScript(module_url_record, credentials_mode, | 96 proxy->FetchAndInvokeScript(module_url_record, credentials_mode, |
| 94 pending_tasks); | 97 parent_frame_task_runner, pending_tasks); |
| 95 } | 98 } |
| 96 } | 99 } |
| 97 | 100 |
| 98 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) { | 101 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) { |
| 99 DCHECK(IsMainThread()); | 102 DCHECK(IsMainThread()); |
| 100 for (const auto& proxy : proxies_) | 103 for (const auto& proxy : proxies_) |
| 101 proxy->TerminateWorkletGlobalScope(); | 104 proxy->TerminateWorkletGlobalScope(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 DEFINE_TRACE(MainThreadWorklet) { | 107 DEFINE_TRACE(MainThreadWorklet) { |
| 105 Worklet::Trace(visitor); | 108 Worklet::Trace(visitor); |
| 106 } | 109 } |
| 107 | 110 |
| 108 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |