Chromium Code Reviews| 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_context_core.h" | 5 #include "content/browser/service_worker/service_worker_context_core.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 25 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 26 #include "content/browser/service_worker/service_worker_database_task_manager.h" | 26 #include "content/browser/service_worker/service_worker_database_task_manager.h" |
| 27 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 27 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 28 #include "content/browser/service_worker/service_worker_info.h" | 28 #include "content/browser/service_worker/service_worker_info.h" |
| 29 #include "content/browser/service_worker/service_worker_job_coordinator.h" | 29 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 30 #include "content/browser/service_worker/service_worker_process_manager.h" | 30 #include "content/browser/service_worker/service_worker_process_manager.h" |
| 31 #include "content/browser/service_worker/service_worker_provider_host.h" | 31 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 32 #include "content/browser/service_worker/service_worker_register_job.h" | 32 #include "content/browser/service_worker/service_worker_register_job.h" |
| 33 #include "content/browser/service_worker/service_worker_registration.h" | 33 #include "content/browser/service_worker/service_worker_registration.h" |
| 34 #include "content/browser/service_worker/service_worker_storage.h" | 34 #include "content/browser/service_worker/service_worker_storage.h" |
| 35 #include "content/browser/service_worker/service_worker_version.h" | |
| 35 #include "content/common/service_worker/service_worker_utils.h" | 36 #include "content/common/service_worker/service_worker_utils.h" |
| 36 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 37 #include "ipc/ipc_message.h" | 38 #include "ipc/ipc_message.h" |
| 38 #include "net/http/http_response_headers.h" | 39 #include "net/http/http_response_headers.h" |
| 39 #include "net/http/http_response_info.h" | 40 #include "net/http/http_response_info.h" |
| 40 #include "storage/browser/quota/quota_manager_proxy.h" | 41 #include "storage/browser/quota/quota_manager_proxy.h" |
| 41 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 42 | 43 |
| 43 namespace content { | 44 namespace content { |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 47 void CheckFetchHandlerOfInstalledServiceWorker( | |
| 48 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, | |
| 49 scoped_refptr<ServiceWorkerRegistration> registration) { | |
| 50 // Waiting Service Worker is a newer version, prefer that if available; | |
|
falken
2017/03/21 01:53:24
nit: trailing semi-colon :)
piotrs
2017/03/21 02:12:49
Done.
| |
| 51 ServiceWorkerVersion* preferred_version = | |
| 52 registration->waiting_version() ? registration->waiting_version() | |
| 53 : registration->active_version(); | |
| 54 | |
| 55 DCHECK(preferred_version); | |
| 56 | |
| 57 ServiceWorkerVersion::FetchHandlerExistence existence = | |
| 58 preferred_version->fetch_handler_existence(); | |
| 59 | |
| 60 DCHECK_NE(existence, ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); | |
| 61 | |
| 62 callback.Run(existence == ServiceWorkerVersion::FetchHandlerExistence::EXISTS | |
| 63 ? ServiceWorkerCapability::SERVICE_WORKER_WITH_FETCH_HANDLER | |
| 64 : ServiceWorkerCapability::SERVICE_WORKER_NO_FETCH_HANDLER); | |
| 65 } | |
| 66 | |
| 46 void SuccessCollectorCallback(const base::Closure& done_closure, | 67 void SuccessCollectorCallback(const base::Closure& done_closure, |
| 47 bool* overall_success, | 68 bool* overall_success, |
| 48 ServiceWorkerStatusCode status) { | 69 ServiceWorkerStatusCode status) { |
| 49 if (status != ServiceWorkerStatusCode::SERVICE_WORKER_OK) { | 70 if (status != ServiceWorkerStatusCode::SERVICE_WORKER_OK) { |
| 50 *overall_success = false; | 71 *overall_success = false; |
| 51 } | 72 } |
| 52 done_closure.Run(); | 73 done_closure.Run(); |
| 53 } | 74 } |
| 54 | 75 |
| 55 void SuccessReportingCallback( | 76 void SuccessReportingCallback( |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { | 870 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { |
| 850 return wrapper_->process_manager(); | 871 return wrapper_->process_manager(); |
| 851 } | 872 } |
| 852 | 873 |
| 853 void ServiceWorkerContextCore::DidFindRegistrationForCheckHasServiceWorker( | 874 void ServiceWorkerContextCore::DidFindRegistrationForCheckHasServiceWorker( |
| 854 const GURL& other_url, | 875 const GURL& other_url, |
| 855 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, | 876 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, |
| 856 ServiceWorkerStatusCode status, | 877 ServiceWorkerStatusCode status, |
| 857 scoped_refptr<ServiceWorkerRegistration> registration) { | 878 scoped_refptr<ServiceWorkerRegistration> registration) { |
| 858 if (status != SERVICE_WORKER_OK) { | 879 if (status != SERVICE_WORKER_OK) { |
| 859 callback.Run(false); | 880 callback.Run(ServiceWorkerCapability::NO_SERVICE_WORKER); |
| 860 return; | 881 return; |
| 861 } | 882 } |
| 862 | 883 |
| 863 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), other_url)) { | 884 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), other_url)) { |
| 864 callback.Run(false); | 885 callback.Run(ServiceWorkerCapability::NO_SERVICE_WORKER); |
| 865 return; | 886 return; |
| 866 } | 887 } |
| 867 | 888 |
| 868 if (registration->is_uninstalling() || registration->is_uninstalled()) { | 889 if (registration->is_uninstalling() || registration->is_uninstalled()) { |
| 869 callback.Run(false); | 890 callback.Run(ServiceWorkerCapability::NO_SERVICE_WORKER); |
| 870 return; | 891 return; |
| 871 } | 892 } |
| 872 | 893 |
| 873 if (!registration->active_version() && !registration->waiting_version()) { | 894 if (!registration->active_version() && !registration->waiting_version()) { |
| 874 registration->RegisterRegistrationFinishedCallback( | 895 registration->RegisterRegistrationFinishedCallback( |
| 875 base::Bind(&ServiceWorkerContextCore:: | 896 base::Bind(&ServiceWorkerContextCore:: |
| 876 OnRegistrationFinishedForCheckHasServiceWorker, | 897 OnRegistrationFinishedForCheckHasServiceWorker, |
| 877 AsWeakPtr(), callback, registration)); | 898 AsWeakPtr(), callback, registration)); |
| 878 return; | 899 return; |
| 879 } | 900 } |
| 880 | 901 |
| 881 callback.Run(true); | 902 CheckFetchHandlerOfInstalledServiceWorker(callback, registration); |
| 882 } | 903 } |
| 883 | 904 |
| 884 void ServiceWorkerContextCore::OnRegistrationFinishedForCheckHasServiceWorker( | 905 void ServiceWorkerContextCore::OnRegistrationFinishedForCheckHasServiceWorker( |
| 885 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, | 906 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, |
| 886 scoped_refptr<ServiceWorkerRegistration> registration) { | 907 scoped_refptr<ServiceWorkerRegistration> registration) { |
| 887 callback.Run(registration->active_version() || | 908 if (!registration->active_version() && !registration->waiting_version()) { |
| 888 registration->waiting_version()); | 909 callback.Run(ServiceWorkerCapability::NO_SERVICE_WORKER); |
| 910 return; | |
| 911 } | |
| 912 | |
| 913 CheckFetchHandlerOfInstalledServiceWorker(callback, registration); | |
| 889 } | 914 } |
| 890 | 915 |
| 891 } // namespace content | 916 } // namespace content |
| OLD | NEW |