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

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

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, 7 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // worker run loop has been started. 401 // worker run loop has been started.
402 worker_task_runner_->PostTask( 402 worker_task_runner_->PostTask(
403 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, 403 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted,
404 GetWeakPtr())); 404 GetWeakPtr()));
405 } 405 }
406 406
407 void ServiceWorkerContextClient::didInitializeWorkerContext( 407 void ServiceWorkerContextClient::didInitializeWorkerContext(
408 v8::Local<v8::Context> context) { 408 v8::Local<v8::Context> context) {
409 GetContentClient() 409 GetContentClient()
410 ->renderer() 410 ->renderer()
411 ->DidInitializeServiceWorkerContextOnWorkerThread(context, script_url_); 411 ->DidInitializeServiceWorkerContextOnWorkerThread(
412 context, embedded_worker_id_, script_url_);
412 } 413 }
413 414
414 void ServiceWorkerContextClient::willDestroyWorkerContext( 415 void ServiceWorkerContextClient::willDestroyWorkerContext(
415 v8::Local<v8::Context> context) { 416 v8::Local<v8::Context> context) {
416 // At this point WillStopCurrentWorkerThread is already called, so 417 // At this point WillStopCurrentWorkerThread is already called, so
417 // worker_task_runner_->RunsTasksOnCurrentThread() returns false 418 // worker_task_runner_->RunsTasksOnCurrentThread() returns false
418 // (while we're still on the worker thread). 419 // (while we're still on the worker thread).
419 proxy_ = NULL; 420 proxy_ = NULL;
420 421
421 // We have to clear callbacks now, as they need to be freed on the 422 // We have to clear callbacks now, as they need to be freed on the
422 // same thread. 423 // same thread.
423 context_.reset(); 424 context_.reset();
424 425
425 // This also lets the message filter stop dispatching messages to 426 // This also lets the message filter stop dispatching messages to
426 // this client. 427 // this client.
427 g_worker_client_tls.Pointer()->Set(NULL); 428 g_worker_client_tls.Pointer()->Set(NULL);
428 429
429 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( 430 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread(
430 context, script_url_); 431 context, embedded_worker_id_, script_url_);
431 } 432 }
432 433
433 void ServiceWorkerContextClient::workerContextDestroyed() { 434 void ServiceWorkerContextClient::workerContextDestroyed() {
434 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); 435 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL);
435 436
436 // Now we should be able to free the WebEmbeddedWorker container on the 437 // Now we should be able to free the WebEmbeddedWorker container on the
437 // main thread. 438 // main thread.
438 main_thread_task_runner_->PostTask( 439 main_thread_task_runner_->PostTask(
439 FROM_HERE, 440 FROM_HERE,
440 base::Bind(&CallWorkerContextDestroyedOnMainThread, 441 base::Bind(&CallWorkerContextDestroyedOnMainThread,
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 } 1014 }
1014 1015
1015 base::WeakPtr<ServiceWorkerContextClient> 1016 base::WeakPtr<ServiceWorkerContextClient>
1016 ServiceWorkerContextClient::GetWeakPtr() { 1017 ServiceWorkerContextClient::GetWeakPtr() {
1017 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1018 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1018 DCHECK(context_); 1019 DCHECK(context_);
1019 return context_->weak_factory.GetWeakPtr(); 1020 return context_->weak_factory.GetWeakPtr();
1020 } 1021 }
1021 1022
1022 } // namespace content 1023 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/content_renderer_client.h ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698