| OLD | NEW |
| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 worker_task_runner_->PostTask( | 409 worker_task_runner_->PostTask( |
| 410 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, | 410 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, |
| 411 GetWeakPtr())); | 411 GetWeakPtr())); |
| 412 } | 412 } |
| 413 | 413 |
| 414 void ServiceWorkerContextClient::didInitializeWorkerContext( | 414 void ServiceWorkerContextClient::didInitializeWorkerContext( |
| 415 v8::Local<v8::Context> context) { | 415 v8::Local<v8::Context> context) { |
| 416 GetContentClient() | 416 GetContentClient() |
| 417 ->renderer() | 417 ->renderer() |
| 418 ->DidInitializeServiceWorkerContextOnWorkerThread( | 418 ->DidInitializeServiceWorkerContextOnWorkerThread( |
| 419 context, embedded_worker_id_, script_url_); | 419 context, service_worker_version_id_, script_url_); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void ServiceWorkerContextClient::willDestroyWorkerContext( | 422 void ServiceWorkerContextClient::willDestroyWorkerContext( |
| 423 v8::Local<v8::Context> context) { | 423 v8::Local<v8::Context> context) { |
| 424 // At this point WillStopCurrentWorkerThread is already called, so | 424 // At this point WillStopCurrentWorkerThread is already called, so |
| 425 // worker_task_runner_->RunsTasksOnCurrentThread() returns false | 425 // worker_task_runner_->RunsTasksOnCurrentThread() returns false |
| 426 // (while we're still on the worker thread). | 426 // (while we're still on the worker thread). |
| 427 proxy_ = NULL; | 427 proxy_ = NULL; |
| 428 | 428 |
| 429 // We have to clear callbacks now, as they need to be freed on the | 429 // We have to clear callbacks now, as they need to be freed on the |
| 430 // same thread. | 430 // same thread. |
| 431 context_.reset(); | 431 context_.reset(); |
| 432 | 432 |
| 433 // This also lets the message filter stop dispatching messages to | 433 // This also lets the message filter stop dispatching messages to |
| 434 // this client. | 434 // this client. |
| 435 g_worker_client_tls.Pointer()->Set(NULL); | 435 g_worker_client_tls.Pointer()->Set(NULL); |
| 436 | 436 |
| 437 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( | 437 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( |
| 438 context, embedded_worker_id_, script_url_); | 438 context, service_worker_version_id_, script_url_); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void ServiceWorkerContextClient::workerContextDestroyed() { | 441 void ServiceWorkerContextClient::workerContextDestroyed() { |
| 442 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 442 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 443 | 443 |
| 444 // Now we should be able to free the WebEmbeddedWorker container on the | 444 // Now we should be able to free the WebEmbeddedWorker container on the |
| 445 // main thread. | 445 // main thread. |
| 446 main_thread_task_runner_->PostTask( | 446 main_thread_task_runner_->PostTask( |
| 447 FROM_HERE, | 447 FROM_HERE, |
| 448 base::Bind(&CallWorkerContextDestroyedOnMainThread, | 448 base::Bind(&CallWorkerContextDestroyedOnMainThread, |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 base::WeakPtr<ServiceWorkerContextClient> | 1057 base::WeakPtr<ServiceWorkerContextClient> |
| 1058 ServiceWorkerContextClient::GetWeakPtr() { | 1058 ServiceWorkerContextClient::GetWeakPtr() { |
| 1059 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1059 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1060 DCHECK(context_); | 1060 DCHECK(context_); |
| 1061 return context_->weak_factory.GetWeakPtr(); | 1061 return context_->weak_factory.GetWeakPtr(); |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 } // namespace content | 1064 } // namespace content |
| OLD | NEW |