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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 1329703004: Revert of Pass the v8::Context through the willDestroyServiceWorkerContextOnWorkerThread event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // so that at the time we send it we can be sure that the 382 // so that at the time we send it we can be sure that the
383 // worker run loop has been started. 383 // worker run loop has been started.
384 worker_task_runner_->PostTask( 384 worker_task_runner_->PostTask(
385 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, 385 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted,
386 GetWeakPtr())); 386 GetWeakPtr()));
387 } 387 }
388 388
389 void ServiceWorkerContextClient::didInitializeWorkerContext( 389 void ServiceWorkerContextClient::didInitializeWorkerContext(
390 v8::Local<v8::Context> context, 390 v8::Local<v8::Context> context,
391 const blink::WebURL& url) { 391 const blink::WebURL& url) {
392 // TODO(annekao): Remove WebURL parameter from Blink, it's at best redundant 392 // TODO(annekao): Remove WebURL parameter from Blink (since url and script_url
393 // given |script_url_|, and may be empty in the future. 393 // are equal). Also remove m_documentURL from ServiceWorkerGlobalScopeProxy.
394 // Also remove m_documentURL from ServiceWorkerGlobalScopeProxy. 394 DCHECK_EQ(script_url_, GURL(url));
395 GetContentClient() 395 GetContentClient()
396 ->renderer() 396 ->renderer()
397 ->DidInitializeServiceWorkerContextOnWorkerThread(context, script_url_); 397 ->DidInitializeServiceWorkerContextOnWorkerThread(context, script_url_);
398 } 398 }
399 399
400 void ServiceWorkerContextClient::willDestroyWorkerContext( 400 void ServiceWorkerContextClient::willDestroyWorkerContext() {
401 v8::Local<v8::Context> context) {
402 // At this point OnWorkerRunLoopStopped is already called, so 401 // At this point OnWorkerRunLoopStopped is already called, so
403 // worker_task_runner_->RunsTasksOnCurrentThread() returns false 402 // worker_task_runner_->RunsTasksOnCurrentThread() returns false
404 // (while we're still on the worker thread). 403 // (while we're still on the worker thread).
405 proxy_ = NULL; 404 proxy_ = NULL;
406 405
407 // We have to clear callbacks now, as they need to be freed on the 406 // We have to clear callbacks now, as they need to be freed on the
408 // same thread. 407 // same thread.
409 context_.reset(); 408 context_.reset();
410 409
411 // This also lets the message filter stop dispatching messages to 410 // This also lets the message filter stop dispatching messages to
412 // this client. 411 // this client.
413 g_worker_client_tls.Pointer()->Set(NULL); 412 g_worker_client_tls.Pointer()->Set(NULL);
414 413
415 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( 414 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread(
416 context, script_url_); 415 script_url_);
417 } 416 }
418 417
419 void ServiceWorkerContextClient::workerContextDestroyed() { 418 void ServiceWorkerContextClient::workerContextDestroyed() {
420 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); 419 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL);
421 420
422 // Now we should be able to free the WebEmbeddedWorker container on the 421 // Now we should be able to free the WebEmbeddedWorker container on the
423 // main thread. 422 // main thread.
424 main_thread_task_runner_->PostTask( 423 main_thread_task_runner_->PostTask(
425 FROM_HERE, 424 FROM_HERE,
426 base::Bind(&CallWorkerContextDestroyedOnMainThread, 425 base::Bind(&CallWorkerContextDestroyedOnMainThread,
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 } 966 }
968 967
969 base::WeakPtr<ServiceWorkerContextClient> 968 base::WeakPtr<ServiceWorkerContextClient>
970 ServiceWorkerContextClient::GetWeakPtr() { 969 ServiceWorkerContextClient::GetWeakPtr() {
971 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 970 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
972 DCHECK(context_); 971 DCHECK(context_);
973 return context_->weak_factory.GetWeakPtr(); 972 return context_->weak_factory.GetWeakPtr();
974 } 973 }
975 974
976 } // namespace content 975 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | extensions/renderer/dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698