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

Unified 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: Use ScriptController::registerExtensions Created 4 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
« no previous file with comments | « ipc/ipc_message_start.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
index 5d73eba912b751c4202c91332a6d521c214e076a..f1060f5f6f011d5be07c52fa0545d8cb479329f8 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
@@ -31,6 +31,7 @@
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "bindings/core/v8/ScriptCallStack.h"
+#include "bindings/core/v8/ScriptController.h"
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h"
@@ -165,8 +166,21 @@ bool WorkerOrWorkletScriptController::initializeContextIfNeeded()
v8::Local<v8::ObjectTemplate> globalTemplate = globalInterfaceTemplate->InstanceTemplate();
v8::Local<v8::Context> context;
{
+ // Initialize V8 extensions before creating the context.
+ Vector<const char*> extensionNames;
+ if (m_globalScope->isServiceWorkerGlobalScope()) {
+ // TODO(lazyboy): Should we add V8Extensions to all service worker
+ // contexts, when we actually don't care about them in non extension
+ // service worker contexts?
+ const V8Extensions& extensions = ScriptController::registeredExtensions();
haraken 2016/04/22 18:33:21 Nit: Now it doesn't make sense to put the register
lazyboy 2016/04/22 20:45:19 OK, I'll move it in a separate CL, I've also fixed
+ extensionNames.reserveInitialCapacity(extensions.size());
+ for (const auto* extension : extensions)
+ extensionNames.append(extension->name());
+ }
+ v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), extensionNames.data());
+
V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolateData::from(m_isolate));
- context = v8::Context::New(m_isolate, nullptr, globalTemplate);
+ context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate);
}
if (context.IsEmpty())
return false;
« no previous file with comments | « ipc/ipc_message_start.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698