| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 registration->waiting_version()); | 470 registration->waiting_version()); |
| 471 attrs->active = handle->CreateServiceWorkerHandleAndPass( | 471 attrs->active = handle->CreateServiceWorkerHandleAndPass( |
| 472 registration->active_version()); | 472 registration->active_version()); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void ServiceWorkerDispatcherHost::RegistrationComplete( | 475 void ServiceWorkerDispatcherHost::RegistrationComplete( |
| 476 int thread_id, | 476 int thread_id, |
| 477 int provider_id, | 477 int provider_id, |
| 478 int request_id, | 478 int request_id, |
| 479 ServiceWorkerStatusCode status, | 479 ServiceWorkerStatusCode status, |
| 480 int64 registration_id, | 480 int64 registration_id) { |
| 481 int64 version_id) { | |
| 482 if (!GetContext()) | 481 if (!GetContext()) |
| 483 return; | 482 return; |
| 484 | 483 |
| 485 if (status != SERVICE_WORKER_OK) { | 484 if (status != SERVICE_WORKER_OK) { |
| 486 SendRegistrationError(thread_id, request_id, status); | 485 SendRegistrationError(thread_id, request_id, status); |
| 487 return; | 486 return; |
| 488 } | 487 } |
| 489 | 488 |
| 490 ServiceWorkerRegistration* registration = | 489 ServiceWorkerRegistration* registration = |
| 491 GetContext()->GetLiveRegistration(registration_id); | 490 GetContext()->GetLiveRegistration(registration_id); |
| 492 DCHECK(registration); | 491 DCHECK(registration); |
| 493 | 492 |
| 494 ServiceWorkerRegistrationObjectInfo info; | 493 ServiceWorkerRegistrationObjectInfo info; |
| 495 ServiceWorkerVersionAttributes attrs; | 494 ServiceWorkerVersionAttributes attrs; |
| 496 GetRegistrationObjectInfoAndVersionAttributes( | 495 GetRegistrationObjectInfoAndVersionAttributes( |
| 497 provider_id, registration, &info, &attrs); | 496 provider_id, registration, &info, &attrs); |
| 498 | 497 |
| 499 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( | 498 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
| 500 thread_id, request_id, info, attrs)); | 499 thread_id, request_id, info, attrs)); |
| 501 TRACE_EVENT_ASYNC_END2("ServiceWorker", | 500 TRACE_EVENT_ASYNC_END1("ServiceWorker", |
| 502 "ServiceWorkerDispatcherHost::RegisterServiceWorker", | 501 "ServiceWorkerDispatcherHost::RegisterServiceWorker", |
| 503 request_id, | 502 request_id, |
| 504 "Registration ID", registration_id, | 503 "Registration ID", |
| 505 "Version ID", version_id); | 504 registration_id); |
| 506 } | 505 } |
| 507 | 506 |
| 508 void ServiceWorkerDispatcherHost::OnWorkerReadyForInspection( | 507 void ServiceWorkerDispatcherHost::OnWorkerReadyForInspection( |
| 509 int embedded_worker_id) { | 508 int embedded_worker_id) { |
| 510 TRACE_EVENT0("ServiceWorker", | 509 TRACE_EVENT0("ServiceWorker", |
| 511 "ServiceWorkerDispatcherHost::OnWorkerReadyForInspection"); | 510 "ServiceWorkerDispatcherHost::OnWorkerReadyForInspection"); |
| 512 if (!GetContext()) | 511 if (!GetContext()) |
| 513 return; | 512 return; |
| 514 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 513 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
| 515 if (!registry->CanHandle(embedded_worker_id)) | 514 if (!registry->CanHandle(embedded_worker_id)) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 status, &error_type, &error_message); | 750 status, &error_type, &error_message); |
| 752 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 751 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
| 753 thread_id, request_id, error_type, error_message)); | 752 thread_id, request_id, error_type, error_message)); |
| 754 } | 753 } |
| 755 | 754 |
| 756 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { | 755 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { |
| 757 return context_wrapper_->context(); | 756 return context_wrapper_->context(); |
| 758 } | 757 } |
| 759 | 758 |
| 760 } // namespace content | 759 } // namespace content |
| OLD | NEW |