| 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_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/barrier_closure.h" | 13 #include "base/barrier_closure.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "content/browser/renderer_host/render_process_host_impl.h" | 24 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 25 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 25 #include "content/browser/service_worker/embedded_worker_status.h" | 26 #include "content/browser/service_worker/embedded_worker_status.h" |
| 26 #include "content/browser/service_worker/service_worker_context_core.h" | 27 #include "content/browser/service_worker/service_worker_context_core.h" |
| 27 #include "content/browser/service_worker/service_worker_context_observer.h" | 28 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 28 #include "content/browser/service_worker/service_worker_process_manager.h" | 29 #include "content/browser/service_worker/service_worker_process_manager.h" |
| 29 #include "content/browser/service_worker/service_worker_quota_client.h" | 30 #include "content/browser/service_worker/service_worker_quota_client.h" |
| 30 #include "content/browser/service_worker/service_worker_version.h" | 31 #include "content/browser/service_worker/service_worker_version.h" |
| 31 #include "content/browser/storage_partition_impl.h" | 32 #include "content/browser/storage_partition_impl.h" |
| 32 #include "content/common/service_worker/service_worker_utils.h" | 33 #include "content/common/service_worker/service_worker_utils.h" |
| 33 #include "content/public/browser/browser_context.h" | 34 #include "content/public/browser/browser_context.h" |
| 34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 int64_t service_worker_version_id, | 889 int64_t service_worker_version_id, |
| 889 const std::string& request_uuid) { | 890 const std::string& request_uuid) { |
| 890 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 891 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 891 ServiceWorkerVersion* version = | 892 ServiceWorkerVersion* version = |
| 892 context()->GetLiveVersion(service_worker_version_id); | 893 context()->GetLiveVersion(service_worker_version_id); |
| 893 if (!version) | 894 if (!version) |
| 894 return false; | 895 return false; |
| 895 return version->FinishExternalRequest(request_uuid); | 896 return version->FinishExternalRequest(request_uuid); |
| 896 } | 897 } |
| 897 | 898 |
| 899 bool ServiceWorkerContextWrapper::IsServiceWorkerExistsOnProcess( |
| 900 int render_process_id) { |
| 901 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 902 return context()->embedded_worker_registry()->IsWorkerExists( |
| 903 render_process_id); |
| 904 } |
| 905 |
| 898 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( | 906 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( |
| 899 ServiceWorkerStatusCode status) { | 907 ServiceWorkerStatusCode status) { |
| 900 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 908 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 901 if (status != SERVICE_WORKER_OK) { | 909 if (status != SERVICE_WORKER_OK) { |
| 902 context_core_.reset(); | 910 context_core_.reset(); |
| 903 return; | 911 return; |
| 904 } | 912 } |
| 905 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); | 913 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); |
| 906 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; | 914 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; |
| 907 | 915 |
| 908 observer_list_->Notify(FROM_HERE, | 916 observer_list_->Notify(FROM_HERE, |
| 909 &ServiceWorkerContextObserver::OnStorageWiped); | 917 &ServiceWorkerContextObserver::OnStorageWiped); |
| 910 } | 918 } |
| 911 | 919 |
| 912 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 920 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 913 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 921 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 914 return context_core_.get(); | 922 return context_core_.get(); |
| 915 } | 923 } |
| 916 | 924 |
| 917 } // namespace content | 925 } // namespace content |
| OLD | NEW |