Chromium Code Reviews| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 ServiceWorkerContextClient::ThreadSpecificInstance() { | 464 ServiceWorkerContextClient::ThreadSpecificInstance() { |
| 465 return g_worker_client_tls.Pointer()->Get(); | 465 return g_worker_client_tls.Pointer()->Get(); |
| 466 } | 466 } |
| 467 | 467 |
| 468 ServiceWorkerContextClient::ServiceWorkerContextClient( | 468 ServiceWorkerContextClient::ServiceWorkerContextClient( |
| 469 int embedded_worker_id, | 469 int embedded_worker_id, |
| 470 int64_t service_worker_version_id, | 470 int64_t service_worker_version_id, |
| 471 const GURL& service_worker_scope, | 471 const GURL& service_worker_scope, |
| 472 const GURL& script_url, | 472 const GURL& script_url, |
| 473 mojom::ServiceWorkerEventDispatcherRequest dispatcher_request, | 473 mojom::ServiceWorkerEventDispatcherRequest dispatcher_request, |
| 474 mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host, | |
| 474 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client) | 475 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client) |
| 475 : embedded_worker_id_(embedded_worker_id), | 476 : embedded_worker_id_(embedded_worker_id), |
| 476 service_worker_version_id_(service_worker_version_id), | 477 service_worker_version_id_(service_worker_version_id), |
| 477 service_worker_scope_(service_worker_scope), | 478 service_worker_scope_(service_worker_scope), |
| 478 script_url_(script_url), | 479 script_url_(script_url), |
| 479 sender_(ChildThreadImpl::current()->thread_safe_sender()), | 480 sender_(ChildThreadImpl::current()->thread_safe_sender()), |
| 480 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 481 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 481 proxy_(nullptr), | 482 proxy_(nullptr), |
| 482 pending_dispatcher_request_(std::move(dispatcher_request)), | 483 pending_dispatcher_request_(std::move(dispatcher_request)), |
| 483 embedded_worker_client_(std::move(embedded_worker_client)) { | 484 embedded_worker_client_(std::move(embedded_worker_client)) { |
| 485 instance_host_.Bind(std::move(instance_host)); | |
| 484 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", | 486 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", |
| 485 "ServiceWorkerContextClient::StartingWorkerContext", | 487 "ServiceWorkerContextClient::StartingWorkerContext", |
| 486 this); | 488 this); |
| 487 TRACE_EVENT_ASYNC_STEP_INTO0( | 489 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 488 "ServiceWorker", | 490 "ServiceWorker", |
| 489 "ServiceWorkerContextClient::StartingWorkerContext", | 491 "ServiceWorkerContextClient::StartingWorkerContext", |
| 490 this, | 492 this, |
| 491 "PrepareWorker"); | 493 "PrepareWorker"); |
| 492 } | 494 } |
| 493 | 495 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 std::vector<char> copy(data, data + size); | 563 std::vector<char> copy(data, data + size); |
| 562 Send(new ServiceWorkerHostMsg_SetCachedMetadata(GetRoutingID(), url, copy)); | 564 Send(new ServiceWorkerHostMsg_SetCachedMetadata(GetRoutingID(), url, copy)); |
| 563 } | 565 } |
| 564 | 566 |
| 565 void ServiceWorkerContextClient::clearCachedMetadata( | 567 void ServiceWorkerContextClient::clearCachedMetadata( |
| 566 const blink::WebURL& url) { | 568 const blink::WebURL& url) { |
| 567 Send(new ServiceWorkerHostMsg_ClearCachedMetadata(GetRoutingID(), url)); | 569 Send(new ServiceWorkerHostMsg_ClearCachedMetadata(GetRoutingID(), url)); |
| 568 } | 570 } |
| 569 | 571 |
| 570 void ServiceWorkerContextClient::workerReadyForInspection() { | 572 void ServiceWorkerContextClient::workerReadyForInspection() { |
| 571 Send(new EmbeddedWorkerHostMsg_WorkerReadyForInspection(embedded_worker_id_)); | 573 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 574 instance_host_->OnReadyForInspection(); | |
|
leonhsl(Using Gerrit)
2017/03/31 06:28:02
Some IPCs like OnScriptEvaluated are triggered on
shimazu
2017/03/31 09:56:22
Yeah and you can use ThreadSafeAssociatedInterface
leonhsl(Using Gerrit)
2017/04/04 07:14:04
Done. Thanks a lot for pointing out this class!
| |
| 572 } | 575 } |
| 573 | 576 |
| 574 void ServiceWorkerContextClient::workerContextFailedToStart() { | 577 void ServiceWorkerContextClient::workerContextFailedToStart() { |
| 575 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 578 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 576 DCHECK(!proxy_); | 579 DCHECK(!proxy_); |
| 577 | 580 |
| 578 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); | 581 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); |
| 579 | 582 |
| 580 RenderThreadImpl::current()->embedded_worker_dispatcher()-> | 583 RenderThreadImpl::current()->embedded_worker_dispatcher()-> |
| 581 WorkerContextDestroyed(embedded_worker_id_); | 584 WorkerContextDestroyed(embedded_worker_id_); |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1503 } | 1506 } |
| 1504 | 1507 |
| 1505 base::WeakPtr<ServiceWorkerContextClient> | 1508 base::WeakPtr<ServiceWorkerContextClient> |
| 1506 ServiceWorkerContextClient::GetWeakPtr() { | 1509 ServiceWorkerContextClient::GetWeakPtr() { |
| 1507 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1510 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1508 DCHECK(context_); | 1511 DCHECK(context_); |
| 1509 return context_->weak_factory.GetWeakPtr(); | 1512 return context_->weak_factory.GetWeakPtr(); |
| 1510 } | 1513 } |
| 1511 | 1514 |
| 1512 } // namespace content | 1515 } // namespace content |
| OLD | NEW |