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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 GetContext()->GetProviderHost(render_process_id_, provider_id); | 587 GetContext()->GetProviderHost(render_process_id_, provider_id); |
588 if (!provider_host) { | 588 if (!provider_host) { |
589 BadMessageReceived(); | 589 BadMessageReceived(); |
590 return; | 590 return; |
591 } | 591 } |
592 if (!provider_host->IsContextAlive()) | 592 if (!provider_host->IsContextAlive()) |
593 return; | 593 return; |
594 if (!provider_host->SetHostedVersionId(version_id)) | 594 if (!provider_host->SetHostedVersionId(version_id)) |
595 BadMessageReceived(); | 595 BadMessageReceived(); |
596 | 596 |
597 // Retrieve the registration associated with |version_id|. | |
598 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); | 597 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); |
599 if (!version) | 598 if (!version) |
600 return; | 599 return; |
| 600 |
| 601 // Retrieve the registration associated with |version|. The registration |
| 602 // must be alive because the version keeps it during starting worker. |
601 ServiceWorkerRegistration* registration = | 603 ServiceWorkerRegistration* registration = |
602 GetContext()->GetLiveRegistration(version->registration_id()); | 604 GetContext()->GetLiveRegistration(version->registration_id()); |
603 DCHECK(registration); | 605 DCHECK(registration); |
604 // TODO(ksakamoto): This is a quick fix for crbug.com/459916. | 606 // TODO(ksakamoto): This is a quick fix for crbug.com/459916. |
605 if (!registration) | 607 if (!registration) |
606 return; | 608 return; |
607 | 609 |
608 // Set the document URL to the script url in order to allow | 610 // Set the document URL to the script url in order to allow |
609 // register/unregister/getRegistration on ServiceWorkerGlobalScope. | 611 // register/unregister/getRegistration on ServiceWorkerGlobalScope. |
610 provider_host->SetDocumentUrl(version->script_url()); | 612 provider_host->SetDocumentUrl(version->script_url()); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 1016 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
1015 if (!handle) { | 1017 if (!handle) { |
1016 BadMessageReceived(); | 1018 BadMessageReceived(); |
1017 return; | 1019 return; |
1018 } | 1020 } |
1019 handle->version()->StopWorker( | 1021 handle->version()->StopWorker( |
1020 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1022 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1021 } | 1023 } |
1022 | 1024 |
1023 } // namespace content | 1025 } // namespace content |
OLD | NEW |