Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 2166523003: Add ref count to service workers for extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from Devlin Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_status.h"
25 #include "content/browser/service_worker/service_worker_context_core.h" 26 #include "content/browser/service_worker/service_worker_context_core.h"
26 #include "content/browser/service_worker/service_worker_context_observer.h" 27 #include "content/browser/service_worker/service_worker_context_observer.h"
27 #include "content/browser/service_worker/service_worker_process_manager.h" 28 #include "content/browser/service_worker/service_worker_process_manager.h"
28 #include "content/browser/service_worker/service_worker_quota_client.h" 29 #include "content/browser/service_worker/service_worker_quota_client.h"
29 #include "content/browser/service_worker/service_worker_version.h" 30 #include "content/browser/service_worker/service_worker_version.h"
30 #include "content/browser/storage_partition_impl.h" 31 #include "content/browser/storage_partition_impl.h"
31 #include "content/common/service_worker/service_worker_utils.h" 32 #include "content/common/service_worker/service_worker_utils.h"
32 #include "content/public/browser/browser_context.h" 33 #include "content/public/browser/browser_context.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 user_data_directory, std::move(database_task_manager), disk_cache_thread, 826 user_data_directory, std::move(database_task_manager), disk_cache_thread,
826 quota_manager_proxy, special_storage_policy, observer_list_.get(), this)); 827 quota_manager_proxy, special_storage_policy, observer_list_.get(), this));
827 } 828 }
828 829
829 void ServiceWorkerContextWrapper::ShutdownOnIO() { 830 void ServiceWorkerContextWrapper::ShutdownOnIO() {
830 DCHECK_CURRENTLY_ON(BrowserThread::IO); 831 DCHECK_CURRENTLY_ON(BrowserThread::IO);
831 resource_context_ = nullptr; 832 resource_context_ = nullptr;
832 context_core_.reset(); 833 context_core_.reset();
833 } 834 }
834 835
836 bool ServiceWorkerContextWrapper::IncrementPendingActivity(
837 int64_t service_worker_version_id,
838 const std::string& request_uuid) {
839 DCHECK_CURRENTLY_ON(BrowserThread::IO);
840 ServiceWorkerVersion* version =
841 context()->GetLiveVersion(service_worker_version_id);
842 if (!version)
843 return false;
844
michaeln 2016/10/06 19:22:31 whitespace nit: blank line not needed + might as w
lazyboy 2016/10/07 06:00:57 Done.
845 return version->StartExternalRequest(request_uuid);
846 }
847
848 bool ServiceWorkerContextWrapper::DecrementPendingActivity(
849 int64_t service_worker_version_id,
850 const std::string& request_uuid) {
851 DCHECK_CURRENTLY_ON(BrowserThread::IO);
852
853 ServiceWorkerVersion* version =
854 context()->GetLiveVersion(service_worker_version_id);
855
856 if (!version)
857 return false;
858
859 return version->FinishExternalRequest(request_uuid);
860 }
861
835 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( 862 void ServiceWorkerContextWrapper::DidDeleteAndStartOver(
836 ServiceWorkerStatusCode status) { 863 ServiceWorkerStatusCode status) {
837 DCHECK_CURRENTLY_ON(BrowserThread::IO); 864 DCHECK_CURRENTLY_ON(BrowserThread::IO);
838 if (status != SERVICE_WORKER_OK) { 865 if (status != SERVICE_WORKER_OK) {
839 context_core_.reset(); 866 context_core_.reset();
840 return; 867 return;
841 } 868 }
842 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); 869 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this));
843 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; 870 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully.";
844 871
845 observer_list_->Notify(FROM_HERE, 872 observer_list_->Notify(FROM_HERE,
846 &ServiceWorkerContextObserver::OnStorageWiped); 873 &ServiceWorkerContextObserver::OnStorageWiped);
847 } 874 }
848 875
849 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 876 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
850 DCHECK_CURRENTLY_ON(BrowserThread::IO); 877 DCHECK_CURRENTLY_ON(BrowserThread::IO);
851 return context_core_.get(); 878 return context_core_.get();
852 } 879 }
853 880
854 } // namespace content 881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698