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

Side by Side Diff: content/browser/service_worker/service_worker_context_core.h

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Add a newline Created 3 years, 10 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 26 matching lines...) Expand all
37 class QuotaManagerProxy; 37 class QuotaManagerProxy;
38 class SpecialStoragePolicy; 38 class SpecialStoragePolicy;
39 } 39 }
40 40
41 namespace content { 41 namespace content {
42 42
43 class EmbeddedWorkerRegistry; 43 class EmbeddedWorkerRegistry;
44 class ServiceWorkerContextObserver; 44 class ServiceWorkerContextObserver;
45 class ServiceWorkerContextWrapper; 45 class ServiceWorkerContextWrapper;
46 class ServiceWorkerDatabaseTaskManager; 46 class ServiceWorkerDatabaseTaskManager;
47 class ServiceWorkerDispatcherHost;
47 class ServiceWorkerJobCoordinator; 48 class ServiceWorkerJobCoordinator;
48 class ServiceWorkerNavigationHandleCore; 49 class ServiceWorkerNavigationHandleCore;
49 class ServiceWorkerProviderHost; 50 class ServiceWorkerProviderHost;
50 class ServiceWorkerRegistration; 51 class ServiceWorkerRegistration;
51 class ServiceWorkerStorage; 52 class ServiceWorkerStorage;
52 53
53 // This class manages data associated with service workers. 54 // This class manages data associated with service workers.
54 // The class is single threaded and should only be used on the IO thread. 55 // The class is single threaded and should only be used on the IO thread.
55 // In chromium, there is one instance per storagepartition. This class 56 // In chromium, there is one instance per storagepartition. This class
56 // is the root of the containment hierarchy for service worker data 57 // is the root of the containment hierarchy for service worker data
57 // associated with a particular partition. 58 // associated with a particular partition.
58 class CONTENT_EXPORT ServiceWorkerContextCore 59 class CONTENT_EXPORT ServiceWorkerContextCore
59 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { 60 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) {
60 public: 61 public:
61 using BoolCallback = base::Callback<void(bool)>; 62 using BoolCallback = base::Callback<void(bool)>;
62 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; 63 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>;
63 using RegistrationCallback = 64 using RegistrationCallback =
64 base::Callback<void(ServiceWorkerStatusCode status, 65 base::Callback<void(ServiceWorkerStatusCode status,
65 const std::string& status_message, 66 const std::string& status_message,
66 int64_t registration_id)>; 67 int64_t registration_id)>;
67 using UpdateCallback = base::Callback<void(ServiceWorkerStatusCode status, 68 using UpdateCallback = base::Callback<void(ServiceWorkerStatusCode status,
68 const std::string& status_message, 69 const std::string& status_message,
69 int64_t registration_id)>; 70 int64_t registration_id)>;
70 using UnregistrationCallback = 71 using UnregistrationCallback =
71 base::Callback<void(ServiceWorkerStatusCode status)>; 72 base::Callback<void(ServiceWorkerStatusCode status)>;
73 using DispatcherHostMap = IDMap<ServiceWorkerDispatcherHost*>;
falken 2017/01/26 05:15:43 It feels misleading that the other *Map types here
shimazu 2017/01/26 09:27:22 Makes sense. Done.
72 using ProviderMap = IDMap<std::unique_ptr<ServiceWorkerProviderHost>>; 74 using ProviderMap = IDMap<std::unique_ptr<ServiceWorkerProviderHost>>;
73 using ProcessToProviderMap = IDMap<std::unique_ptr<ProviderMap>>; 75 using ProcessToProviderMap = IDMap<std::unique_ptr<ProviderMap>>;
74 76
75 using ProviderByClientUUIDMap = 77 using ProviderByClientUUIDMap =
76 std::map<std::string, ServiceWorkerProviderHost*>; 78 std::map<std::string, ServiceWorkerProviderHost*>;
77 79
78 // Directory for ServiceWorkerStorage and ServiceWorkerCacheManager. 80 // Directory for ServiceWorkerStorage and ServiceWorkerCacheManager.
79 static const base::FilePath::CharType kServiceWorkerDirectory[]; 81 static const base::FilePath::CharType kServiceWorkerDirectory[];
80 82
81 // Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap. 83 // Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ServiceWorkerContextWrapper* wrapper() const { return wrapper_; } 149 ServiceWorkerContextWrapper* wrapper() const { return wrapper_; }
148 ServiceWorkerStorage* storage() { return storage_.get(); } 150 ServiceWorkerStorage* storage() { return storage_.get(); }
149 ServiceWorkerProcessManager* process_manager(); 151 ServiceWorkerProcessManager* process_manager();
150 EmbeddedWorkerRegistry* embedded_worker_registry() { 152 EmbeddedWorkerRegistry* embedded_worker_registry() {
151 return embedded_worker_registry_.get(); 153 return embedded_worker_registry_.get();
152 } 154 }
153 ServiceWorkerJobCoordinator* job_coordinator() { 155 ServiceWorkerJobCoordinator* job_coordinator() {
154 return job_coordinator_.get(); 156 return job_coordinator_.get();
155 } 157 }
156 158
159 // Maintains DispatcherHosts to exchange service worker related messages
160 // through them.
falken 2017/01/26 05:15:43 It's a bit inconsistent that AddDispatcherHost doe
shimazu 2017/01/26 09:27:22 Done.
161 void AddDispatcherHost(int process_id,
162 ServiceWorkerDispatcherHost* dispatcher_host);
163 void RemoveDispatcherHost(int process_id);
164
157 // The context class owns the set of ProviderHosts. 165 // The context class owns the set of ProviderHosts.
158 ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id);
159 void AddProviderHost( 166 void AddProviderHost(
160 std::unique_ptr<ServiceWorkerProviderHost> provider_host); 167 std::unique_ptr<ServiceWorkerProviderHost> provider_host);
168 void AddProviderHost(int process_id,
169 ServiceWorkerProviderHostInfo provider_host_info);
falken 2017/01/26 05:15:42 nit: Consider removing the function overloading by
shimazu 2017/01/26 09:27:22 Done.
170 ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id);
161 void RemoveProviderHost(int process_id, int provider_id); 171 void RemoveProviderHost(int process_id, int provider_id);
162 void RemoveAllProviderHostsForProcess(int process_id); 172 void RemoveAllProviderHostsForProcess(int process_id);
163 std::unique_ptr<ProviderHostIterator> GetProviderHostIterator(); 173 std::unique_ptr<ProviderHostIterator> GetProviderHostIterator();
164 174
165 // Returns a ProviderHost iterator for all ServiceWorker clients for 175 // Returns a ProviderHost iterator for all ServiceWorker clients for
166 // the |origin|. This only returns ProviderHosts that are of CONTROLLEE 176 // the |origin|. This only returns ProviderHosts that are of CONTROLLEE
167 // and belong to the |origin|. 177 // and belong to the |origin|.
168 std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator( 178 std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator(
169 const GURL& origin); 179 const GURL& origin);
170 180
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 ServiceWorkerStatusCode status, 345 ServiceWorkerStatusCode status,
336 scoped_refptr<ServiceWorkerRegistration> registration); 346 scoped_refptr<ServiceWorkerRegistration> registration);
337 void OnRegistrationFinishedForCheckHasServiceWorker( 347 void OnRegistrationFinishedForCheckHasServiceWorker(
338 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, 348 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback,
339 scoped_refptr<ServiceWorkerRegistration> registration); 349 scoped_refptr<ServiceWorkerRegistration> registration);
340 350
341 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| 351 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_|
342 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses 352 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses
343 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. 353 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed.
344 ServiceWorkerContextWrapper* wrapper_; 354 ServiceWorkerContextWrapper* wrapper_;
355 std::unique_ptr<DispatcherHostMap> dispatcher_hosts_;
345 std::unique_ptr<ProcessToProviderMap> providers_; 356 std::unique_ptr<ProcessToProviderMap> providers_;
346 std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_; 357 std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_;
347 std::unique_ptr<ServiceWorkerStorage> storage_; 358 std::unique_ptr<ServiceWorkerStorage> storage_;
348 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; 359 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_;
349 std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_; 360 std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_;
350 std::map<int64_t, ServiceWorkerRegistration*> live_registrations_; 361 std::map<int64_t, ServiceWorkerRegistration*> live_registrations_;
351 std::map<int64_t, ServiceWorkerVersion*> live_versions_; 362 std::map<int64_t, ServiceWorkerVersion*> live_versions_;
352 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_; 363 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_;
353 364
354 std::map<int64_t /* version_id */, FailureInfo> failure_counts_; 365 std::map<int64_t /* version_id */, FailureInfo> failure_counts_;
(...skipping 13 matching lines...) Expand all
368 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>> 379 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>>
369 observer_list_; 380 observer_list_;
370 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; 381 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_;
371 382
372 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); 383 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore);
373 }; 384 };
374 385
375 } // namespace content 386 } // namespace content
376 387
377 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ 388 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698