| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", | 390 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", |
| 391 "ServiceWorkerContextClient::StartingWorkerContext", | 391 "ServiceWorkerContextClient::StartingWorkerContext", |
| 392 this); | 392 this); |
| 393 TRACE_EVENT_ASYNC_STEP_INTO0( | 393 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 394 "ServiceWorker", | 394 "ServiceWorker", |
| 395 "ServiceWorkerContextClient::StartingWorkerContext", | 395 "ServiceWorkerContextClient::StartingWorkerContext", |
| 396 this, | 396 this, |
| 397 "PrepareWorker"); | 397 "PrepareWorker"); |
| 398 } | 398 } |
| 399 | 399 |
| 400 ServiceWorkerContextClient::ServiceWorkerContextClient( | |
| 401 int embedded_worker_id, | |
| 402 int64_t service_worker_version_id, | |
| 403 const GURL& service_worker_scope, | |
| 404 const GURL& script_url) | |
| 405 : ServiceWorkerContextClient::ServiceWorkerContextClient( | |
| 406 embedded_worker_id, | |
| 407 service_worker_version_id, | |
| 408 service_worker_scope, | |
| 409 script_url, | |
| 410 mojom::ServiceWorkerEventDispatcherRequest(), | |
| 411 nullptr) {} | |
| 412 | |
| 413 ServiceWorkerContextClient::~ServiceWorkerContextClient() {} | 400 ServiceWorkerContextClient::~ServiceWorkerContextClient() {} |
| 414 | 401 |
| 415 void ServiceWorkerContextClient::OnMessageReceived( | 402 void ServiceWorkerContextClient::OnMessageReceived( |
| 416 int thread_id, | 403 int thread_id, |
| 417 int embedded_worker_id, | 404 int embedded_worker_id, |
| 418 const IPC::Message& message) { | 405 const IPC::Message& message) { |
| 419 CHECK_EQ(embedded_worker_id_, embedded_worker_id); | 406 CHECK_EQ(embedded_worker_id_, embedded_worker_id); |
| 420 bool handled = true; | 407 bool handled = true; |
| 421 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerContextClient, message) | 408 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerContextClient, message) |
| 422 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent) | 409 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // willDestroyWorkerContext. | 521 // willDestroyWorkerContext. |
| 535 context_.reset(new WorkerContextData(this)); | 522 context_.reset(new WorkerContextData(this)); |
| 536 | 523 |
| 537 ServiceWorkerRegistrationObjectInfo registration_info; | 524 ServiceWorkerRegistrationObjectInfo registration_info; |
| 538 ServiceWorkerVersionAttributes version_attrs; | 525 ServiceWorkerVersionAttributes version_attrs; |
| 539 provider_context_->GetAssociatedRegistration(®istration_info, | 526 provider_context_->GetAssociatedRegistration(®istration_info, |
| 540 &version_attrs); | 527 &version_attrs); |
| 541 DCHECK_NE(registration_info.registration_id, | 528 DCHECK_NE(registration_info.registration_id, |
| 542 kInvalidServiceWorkerRegistrationId); | 529 kInvalidServiceWorkerRegistrationId); |
| 543 | 530 |
| 544 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { | 531 DCHECK(pending_dispatcher_request_.is_pending()); |
| 545 DCHECK(pending_dispatcher_request_.is_pending()); | 532 DCHECK(!context_->event_dispatcher_binding.is_bound()); |
| 546 BindEventDispatcher(std::move(pending_dispatcher_request_)); | 533 context_->event_dispatcher_binding.Bind( |
| 547 } | 534 std::move(pending_dispatcher_request_)); |
| 548 | 535 |
| 549 SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs); | 536 SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs); |
| 550 | 537 |
| 551 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted( | 538 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted( |
| 552 embedded_worker_id_, WorkerThread::GetCurrentId(), | 539 embedded_worker_id_, WorkerThread::GetCurrentId(), |
| 553 provider_context_->provider_id())); | 540 provider_context_->provider_id())); |
| 554 | 541 |
| 555 TRACE_EVENT_ASYNC_STEP_INTO0( | 542 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 556 "ServiceWorker", | 543 "ServiceWorker", |
| 557 "ServiceWorkerContextClient::StartingWorkerContext", | 544 "ServiceWorkerContextClient::StartingWorkerContext", |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 proxy_->onNavigationPreloadResponse(fetch_event_id, std::move(response), | 1251 proxy_->onNavigationPreloadResponse(fetch_event_id, std::move(response), |
| 1265 std::move(data_consumer_handle)); | 1252 std::move(data_consumer_handle)); |
| 1266 } | 1253 } |
| 1267 | 1254 |
| 1268 void ServiceWorkerContextClient::OnNavigationPreloadError( | 1255 void ServiceWorkerContextClient::OnNavigationPreloadError( |
| 1269 int fetch_event_id, | 1256 int fetch_event_id, |
| 1270 std::unique_ptr<blink::WebServiceWorkerError> error) { | 1257 std::unique_ptr<blink::WebServiceWorkerError> error) { |
| 1271 proxy_->onNavigationPreloadError(fetch_event_id, std::move(error)); | 1258 proxy_->onNavigationPreloadError(fetch_event_id, std::move(error)); |
| 1272 } | 1259 } |
| 1273 | 1260 |
| 1274 void ServiceWorkerContextClient::BindEventDispatcher( | |
| 1275 mojom::ServiceWorkerEventDispatcherRequest request) { | |
| 1276 DCHECK(context_); | |
| 1277 DCHECK(!context_->event_dispatcher_binding.is_bound()); | |
| 1278 context_->event_dispatcher_binding.Bind(std::move(request)); | |
| 1279 } | |
| 1280 | |
| 1281 base::WeakPtr<ServiceWorkerContextClient> | 1261 base::WeakPtr<ServiceWorkerContextClient> |
| 1282 ServiceWorkerContextClient::GetWeakPtr() { | 1262 ServiceWorkerContextClient::GetWeakPtr() { |
| 1283 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1263 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1284 DCHECK(context_); | 1264 DCHECK(context_); |
| 1285 return context_->weak_factory.GetWeakPtr(); | 1265 return context_->weak_factory.GetWeakPtr(); |
| 1286 } | 1266 } |
| 1287 | 1267 |
| 1288 } // namespace content | 1268 } // namespace content |
| OLD | NEW |