| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 worker_task_runner_->PostTask( | 452 worker_task_runner_->PostTask( |
| 453 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, | 453 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, |
| 454 GetWeakPtr())); | 454 GetWeakPtr())); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void ServiceWorkerContextClient::didInitializeWorkerContext( | 457 void ServiceWorkerContextClient::didInitializeWorkerContext( |
| 458 v8::Local<v8::Context> context) { | 458 v8::Local<v8::Context> context) { |
| 459 GetContentClient() | 459 GetContentClient() |
| 460 ->renderer() | 460 ->renderer() |
| 461 ->DidInitializeServiceWorkerContextOnWorkerThread( | 461 ->DidInitializeServiceWorkerContextOnWorkerThread( |
| 462 context, embedded_worker_id_, script_url_); | 462 context, service_worker_version_id_, script_url_); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void ServiceWorkerContextClient::willDestroyWorkerContext( | 465 void ServiceWorkerContextClient::willDestroyWorkerContext( |
| 466 v8::Local<v8::Context> context) { | 466 v8::Local<v8::Context> context) { |
| 467 // At this point WillStopCurrentWorkerThread is already called, so | 467 // At this point WillStopCurrentWorkerThread is already called, so |
| 468 // worker_task_runner_->RunsTasksOnCurrentThread() returns false | 468 // worker_task_runner_->RunsTasksOnCurrentThread() returns false |
| 469 // (while we're still on the worker thread). | 469 // (while we're still on the worker thread). |
| 470 proxy_ = NULL; | 470 proxy_ = NULL; |
| 471 | 471 |
| 472 // Aborts the all pending sync event callbacks. | 472 // Aborts the all pending sync event callbacks. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 485 | 485 |
| 486 // We have to clear callbacks now, as they need to be freed on the | 486 // We have to clear callbacks now, as they need to be freed on the |
| 487 // same thread. | 487 // same thread. |
| 488 context_.reset(); | 488 context_.reset(); |
| 489 | 489 |
| 490 // This also lets the message filter stop dispatching messages to | 490 // This also lets the message filter stop dispatching messages to |
| 491 // this client. | 491 // this client. |
| 492 g_worker_client_tls.Pointer()->Set(NULL); | 492 g_worker_client_tls.Pointer()->Set(NULL); |
| 493 | 493 |
| 494 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( | 494 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( |
| 495 context, embedded_worker_id_, script_url_); | 495 context, service_worker_version_id_, script_url_); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void ServiceWorkerContextClient::workerContextDestroyed() { | 498 void ServiceWorkerContextClient::workerContextDestroyed() { |
| 499 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 499 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 500 | 500 |
| 501 // Check if mojo is enabled | 501 // Check if mojo is enabled |
| 502 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { | 502 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| 503 DCHECK(embedded_worker_client_); | 503 DCHECK(embedded_worker_client_); |
| 504 main_thread_task_runner_->PostTask( | 504 main_thread_task_runner_->PostTask( |
| 505 FROM_HERE, | 505 FROM_HERE, |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 base::WeakPtr<ServiceWorkerContextClient> | 1138 base::WeakPtr<ServiceWorkerContextClient> |
| 1139 ServiceWorkerContextClient::GetWeakPtr() { | 1139 ServiceWorkerContextClient::GetWeakPtr() { |
| 1140 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1140 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1141 DCHECK(context_); | 1141 DCHECK(context_); |
| 1142 return context_->weak_factory.GetWeakPtr(); | 1142 return context_->weak_factory.GetWeakPtr(); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 } // namespace content | 1145 } // namespace content |
| OLD | NEW |