| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 ServiceWorkerProviderHost* provider_host = | 545 ServiceWorkerProviderHost* provider_host = |
| 546 GetContext()->GetProviderHost(render_process_id_, provider_id); | 546 GetContext()->GetProviderHost(render_process_id_, provider_id); |
| 547 if (!provider_host) { | 547 if (!provider_host) { |
| 548 BadMessageReceived(); | 548 BadMessageReceived(); |
| 549 return; | 549 return; |
| 550 } | 550 } |
| 551 if (!provider_host->IsContextAlive()) | 551 if (!provider_host->IsContextAlive()) |
| 552 return; | 552 return; |
| 553 if (!provider_host->SetHostedVersionId(version_id)) | 553 if (!provider_host->SetHostedVersionId(version_id)) |
| 554 BadMessageReceived(); | 554 BadMessageReceived(); |
| 555 |
| 556 // Retrieve the registration associated with |version_id|. |
| 557 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); |
| 558 if (!version) |
| 559 return; |
| 560 ServiceWorkerRegistration* registration = |
| 561 GetContext()->GetLiveRegistration(version->registration_id()); |
| 562 DCHECK(registration); |
| 563 |
| 564 ServiceWorkerRegistrationObjectInfo info; |
| 565 ServiceWorkerVersionAttributes attrs; |
| 566 GetRegistrationObjectInfoAndVersionAttributes( |
| 567 provider_id, registration, &info, &attrs); |
| 568 |
| 569 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker( |
| 570 kDocumentMainThreadId, provider_id, info, attrs)); |
| 555 } | 571 } |
| 556 | 572 |
| 557 ServiceWorkerRegistrationHandle* | 573 ServiceWorkerRegistrationHandle* |
| 558 ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id, | 574 ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id, |
| 559 int64 registration_id) { | 575 int64 registration_id) { |
| 560 for (IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>::iterator | 576 for (IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>::iterator |
| 561 iter(®istration_handles_); | 577 iter(®istration_handles_); |
| 562 !iter.IsAtEnd(); | 578 !iter.IsAtEnd(); |
| 563 iter.Advance()) { | 579 iter.Advance()) { |
| 564 ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue(); | 580 ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue(); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 handles_.AddWithID(handle.release(), handle_id); | 930 handles_.AddWithID(handle.release(), handle_id); |
| 915 } | 931 } |
| 916 | 932 |
| 917 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( | 933 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( |
| 918 scoped_ptr<ServiceWorkerRegistrationHandle> handle) { | 934 scoped_ptr<ServiceWorkerRegistrationHandle> handle) { |
| 919 int handle_id = handle->handle_id(); | 935 int handle_id = handle->handle_id(); |
| 920 registration_handles_.AddWithID(handle.release(), handle_id); | 936 registration_handles_.AddWithID(handle.release(), handle_id); |
| 921 } | 937 } |
| 922 | 938 |
| 923 } // namespace content | 939 } // namespace content |
| OLD | NEW |