Commit 7ba924c0 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions Bindings] Call WillReleaseScriptContext for SW contexts

Call ExtensionBindingsSystem::WillReleaseScriptContext() for extension
service-worker contexts. This fixes
ServiceWorkerTest.EventsToStoppedWorker with extension native bindings.

          --gtest_filter=ServiceWorkerTest.EventsToStoppedWorker
          --native-crx-bindings=1

Bug: 653596
Test: browser_tests \
Change-Id: I97db2bce738f35cd8ca5909017c6c9f48f95b76e
Reviewed-on: https://chromium-review.googlesource.com/596912Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491882}
parent dad72326
...@@ -504,16 +504,28 @@ void Dispatcher::WillDestroyServiceWorkerContextOnWorkerThread( ...@@ -504,16 +504,28 @@ void Dispatcher::WillDestroyServiceWorkerContextOnWorkerThread(
int64_t service_worker_version_id, int64_t service_worker_version_id,
const GURL& service_worker_scope, const GURL& service_worker_scope,
const GURL& script_url) { const GURL& script_url) {
if (script_url.SchemeIs(kExtensionScheme)) { if (!script_url.SchemeIs(kExtensionScheme)) {
// See comment in DidInitializeServiceWorkerContextOnWorkerThread. // See comment in DidInitializeServiceWorkerContextOnWorkerThread.
g_worker_script_context_set.Get().Remove(v8_context, script_url); return;
// TODO(devlin): We're not calling
// ExtensionBindingsSystem::WillReleaseScriptContext() here. This should be
// fine, since the entire bindings system is being destroyed when we
// remove the worker data, but we might want to notify the system anyway.
} }
if (ExtensionsClient::Get()->ExtensionAPIEnabledInExtensionServiceWorkers())
if (ExtensionsClient::Get()->ExtensionAPIEnabledInExtensionServiceWorkers()) {
// TODO(lazyboy/devlin): Should this cleanup happen in a worker class, like
// WorkerThreadDispatcher? If so, we should move the initialization as well.
ScriptContext* script_context = WorkerThreadDispatcher::GetScriptContext();
ExtensionBindingsSystem* worker_bindings_system =
WorkerThreadDispatcher::GetBindingsSystem();
worker_bindings_system->WillReleaseScriptContext(script_context);
// Note: we have to remove the context (and thus perform invalidation on
// the native handlers) prior to removing the worker data, which destroys
// the associated bindings system.
g_worker_script_context_set.Get().Remove(v8_context, script_url);
WorkerThreadDispatcher::Get()->RemoveWorkerData(service_worker_version_id); WorkerThreadDispatcher::Get()->RemoveWorkerData(service_worker_version_id);
} else {
// If extension APIs in service workers aren't enabled, we just need to
// remove the context.
g_worker_script_context_set.Get().Remove(v8_context, script_url);
}
} }
void Dispatcher::DidCreateDocumentElement(blink::WebLocalFrame* frame) { void Dispatcher::DidCreateDocumentElement(blink::WebLocalFrame* frame) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment