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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 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
« no previous file with comments | « ipc/ipc_message_start.h ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 31 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
32 32
33 #include "bindings/core/v8/ScriptCallStack.h" 33 #include "bindings/core/v8/ScriptCallStack.h"
34 #include "bindings/core/v8/ScriptController.h"
34 #include "bindings/core/v8/ScriptSourceCode.h" 35 #include "bindings/core/v8/ScriptSourceCode.h"
35 #include "bindings/core/v8/ScriptValue.h" 36 #include "bindings/core/v8/ScriptValue.h"
36 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" 37 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h"
37 #include "bindings/core/v8/V8ErrorHandler.h" 38 #include "bindings/core/v8/V8ErrorHandler.h"
38 #include "bindings/core/v8/V8Initializer.h" 39 #include "bindings/core/v8/V8Initializer.h"
39 #include "bindings/core/v8/V8ObjectConstructor.h" 40 #include "bindings/core/v8/V8ObjectConstructor.h"
40 #include "bindings/core/v8/V8ScriptRunner.h" 41 #include "bindings/core/v8/V8ScriptRunner.h"
41 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" 42 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h"
42 #include "bindings/core/v8/V8WorkerGlobalScope.h" 43 #include "bindings/core/v8/V8WorkerGlobalScope.h"
43 #include "bindings/core/v8/WrapperTypeInfo.h" 44 #include "bindings/core/v8/WrapperTypeInfo.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Create a new v8::Context with the worker/worklet as the global object 159 // Create a new v8::Context with the worker/worklet as the global object
159 // (aka the inner global). 160 // (aka the inner global).
160 ScriptWrappable* scriptWrappable = m_globalScope->getScriptWrappable(); 161 ScriptWrappable* scriptWrappable = m_globalScope->getScriptWrappable();
161 const WrapperTypeInfo* wrapperTypeInfo = scriptWrappable->wrapperTypeInfo(); 162 const WrapperTypeInfo* wrapperTypeInfo = scriptWrappable->wrapperTypeInfo();
162 v8::Local<v8::FunctionTemplate> globalInterfaceTemplate = wrapperTypeInfo->d omTemplate(m_isolate, *m_world); 163 v8::Local<v8::FunctionTemplate> globalInterfaceTemplate = wrapperTypeInfo->d omTemplate(m_isolate, *m_world);
163 if (globalInterfaceTemplate.IsEmpty()) 164 if (globalInterfaceTemplate.IsEmpty())
164 return false; 165 return false;
165 v8::Local<v8::ObjectTemplate> globalTemplate = globalInterfaceTemplate->Inst anceTemplate(); 166 v8::Local<v8::ObjectTemplate> globalTemplate = globalInterfaceTemplate->Inst anceTemplate();
166 v8::Local<v8::Context> context; 167 v8::Local<v8::Context> context;
167 { 168 {
169 // Initialize V8 extensions before creating the context.
170 Vector<const char*> extensionNames;
171 if (m_globalScope->isServiceWorkerGlobalScope() && Platform::current()-> allowScriptExtensionForServiceWorker(toWorkerGlobalScope(m_globalScope.get())->u rl())) {
172 const V8Extensions& extensions = ScriptController::registeredExtensi ons();
173 extensionNames.reserveInitialCapacity(extensions.size());
174 for (const auto* extension : extensions)
175 extensionNames.append(extension->name());
176 }
177 v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), extensionNames.data());
178
168 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolat eData::from(m_isolate)); 179 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolat eData::from(m_isolate));
169 context = v8::Context::New(m_isolate, nullptr, globalTemplate); 180 context = v8::Context::New(m_isolate, &extensionConfiguration, globalTem plate);
170 } 181 }
171 if (context.IsEmpty()) 182 if (context.IsEmpty())
172 return false; 183 return false;
173 184
174 m_scriptState = ScriptState::create(context, m_world); 185 m_scriptState = ScriptState::create(context, m_world);
175 186
176 ScriptState::Scope scope(m_scriptState.get()); 187 ScriptState::Scope scope(m_scriptState.get());
177 188
178 // Name new context for debugging. For main thread worklet global scopes 189 // Name new context for debugging. For main thread worklet global scopes
179 // this is done once the context is initialized. 190 // this is done once the context is initialized.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 m_executionState->m_errorEventFromImportedScript = errorEvent; 330 m_executionState->m_errorEventFromImportedScript = errorEvent;
320 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso late, errorMessage)); 331 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso late, errorMessage));
321 } 332 }
322 333
323 DEFINE_TRACE(WorkerOrWorkletScriptController) 334 DEFINE_TRACE(WorkerOrWorkletScriptController)
324 { 335 {
325 visitor->trace(m_globalScope); 336 visitor->trace(m_globalScope);
326 } 337 }
327 338
328 } // namespace blink 339 } // namespace blink
OLDNEW
« no previous file with comments | « ipc/ipc_message_start.h ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698