| 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 #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 Loading... |
| 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 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 ServiceWorkerContextWrapper* wrapper() const { return wrapper_; } | 148 ServiceWorkerContextWrapper* wrapper() const { return wrapper_; } |
| 148 ServiceWorkerStorage* storage() { return storage_.get(); } | 149 ServiceWorkerStorage* storage() { return storage_.get(); } |
| 149 ServiceWorkerProcessManager* process_manager(); | 150 ServiceWorkerProcessManager* process_manager(); |
| 150 EmbeddedWorkerRegistry* embedded_worker_registry() { | 151 EmbeddedWorkerRegistry* embedded_worker_registry() { |
| 151 return embedded_worker_registry_.get(); | 152 return embedded_worker_registry_.get(); |
| 152 } | 153 } |
| 153 ServiceWorkerJobCoordinator* job_coordinator() { | 154 ServiceWorkerJobCoordinator* job_coordinator() { |
| 154 return job_coordinator_.get(); | 155 return job_coordinator_.get(); |
| 155 } | 156 } |
| 156 | 157 |
| 158 // Maintains DispatcherHosts to exchange service worker related messages |
| 159 // through them. The DispatcherHosts are not owned by this class. |
| 160 void AddDispatcherHost(int process_id, |
| 161 ServiceWorkerDispatcherHost* dispatcher_host); |
| 162 ServiceWorkerDispatcherHost* GetDispatcherHost(int process_id); |
| 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 ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id); |
| 161 void RemoveProviderHost(int process_id, int provider_id); | 169 void RemoveProviderHost(int process_id, int provider_id); |
| 162 void RemoveAllProviderHostsForProcess(int process_id); | 170 void RemoveAllProviderHostsForProcess(int process_id); |
| 163 std::unique_ptr<ProviderHostIterator> GetProviderHostIterator(); | 171 std::unique_ptr<ProviderHostIterator> GetProviderHostIterator(); |
| 164 | 172 |
| 165 // Returns a ProviderHost iterator for all ServiceWorker clients for | 173 // Returns a ProviderHost iterator for all ServiceWorker clients for |
| 166 // the |origin|. This only returns ProviderHosts that are of CONTROLLEE | 174 // the |origin|. This only returns ProviderHosts that are of CONTROLLEE |
| 167 // and belong to the |origin|. | 175 // and belong to the |origin|. |
| 168 std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator( | 176 std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator( |
| 169 const GURL& origin); | 177 const GURL& origin); |
| 170 | 178 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 ServiceWorkerStatusCode status, | 343 ServiceWorkerStatusCode status, |
| 336 scoped_refptr<ServiceWorkerRegistration> registration); | 344 scoped_refptr<ServiceWorkerRegistration> registration); |
| 337 void OnRegistrationFinishedForCheckHasServiceWorker( | 345 void OnRegistrationFinishedForCheckHasServiceWorker( |
| 338 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, | 346 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, |
| 339 scoped_refptr<ServiceWorkerRegistration> registration); | 347 scoped_refptr<ServiceWorkerRegistration> registration); |
| 340 | 348 |
| 341 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| | 349 // 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 | 350 // 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. | 351 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. |
| 344 ServiceWorkerContextWrapper* wrapper_; | 352 ServiceWorkerContextWrapper* wrapper_; |
| 353 std::map<int /* process_id */, ServiceWorkerDispatcherHost*> |
| 354 dispatcher_hosts_; |
| 345 std::unique_ptr<ProcessToProviderMap> providers_; | 355 std::unique_ptr<ProcessToProviderMap> providers_; |
| 346 std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_; | 356 std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_; |
| 347 std::unique_ptr<ServiceWorkerStorage> storage_; | 357 std::unique_ptr<ServiceWorkerStorage> storage_; |
| 348 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; | 358 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; |
| 349 std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_; | 359 std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_; |
| 350 std::map<int64_t, ServiceWorkerRegistration*> live_registrations_; | 360 std::map<int64_t, ServiceWorkerRegistration*> live_registrations_; |
| 351 std::map<int64_t, ServiceWorkerVersion*> live_versions_; | 361 std::map<int64_t, ServiceWorkerVersion*> live_versions_; |
| 352 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_; | 362 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_; |
| 353 | 363 |
| 354 std::map<int64_t /* version_id */, FailureInfo> failure_counts_; | 364 std::map<int64_t /* version_id */, FailureInfo> failure_counts_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 368 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>> | 378 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>> |
| 369 observer_list_; | 379 observer_list_; |
| 370 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; | 380 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; |
| 371 | 381 |
| 372 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); | 382 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); |
| 373 }; | 383 }; |
| 374 | 384 |
| 375 } // namespace content | 385 } // namespace content |
| 376 | 386 |
| 377 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ | 387 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ |
| OLD | NEW |