| 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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 public: | 55 public: |
| 56 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; | 56 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; |
| 57 typedef base::Callback<void(ServiceWorkerStatusCode status, | 57 typedef base::Callback<void(ServiceWorkerStatusCode status, |
| 58 int64 registration_id, | 58 int64 registration_id, |
| 59 int64 version_id)> RegistrationCallback; | 59 int64 version_id)> RegistrationCallback; |
| 60 typedef base::Callback< | 60 typedef base::Callback< |
| 61 void(ServiceWorkerStatusCode status)> UnregistrationCallback; | 61 void(ServiceWorkerStatusCode status)> UnregistrationCallback; |
| 62 typedef IDMap<ServiceWorkerProviderHost, IDMapOwnPointer> ProviderMap; | 62 typedef IDMap<ServiceWorkerProviderHost, IDMapOwnPointer> ProviderMap; |
| 63 typedef IDMap<ProviderMap, IDMapOwnPointer> ProcessToProviderMap; | 63 typedef IDMap<ProviderMap, IDMapOwnPointer> ProcessToProviderMap; |
| 64 | 64 |
| 65 // Directory for ServiceWorkerStorage and ServiceWorkerFetchStores. | 65 // Directory for ServiceWorkerStorage and ServiceWorkerCacheManager. |
| 66 static const base::FilePath::CharType kServiceWorkerDirectory[]; | 66 static const base::FilePath::CharType kServiceWorkerDirectory[]; |
| 67 | 67 |
| 68 // Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap. | 68 // Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap. |
| 69 class ProviderHostIterator { | 69 class ProviderHostIterator { |
| 70 public: | 70 public: |
| 71 ~ProviderHostIterator(); | 71 ~ProviderHostIterator(); |
| 72 ServiceWorkerProviderHost* GetProviderHost(); | 72 ServiceWorkerProviderHost* GetProviderHost(); |
| 73 void Advance(); | 73 void Advance(); |
| 74 bool IsAtEnd(); | 74 bool IsAtEnd(); |
| 75 | 75 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // This is owned by the StoragePartition, which will supply it with | 88 // This is owned by the StoragePartition, which will supply it with |
| 89 // the local path on disk. Given an empty |user_data_directory|, | 89 // the local path on disk. Given an empty |user_data_directory|, |
| 90 // nothing will be stored on disk. |observer_list| is created in | 90 // nothing will be stored on disk. |observer_list| is created in |
| 91 // ServiceWorkerContextWrapper. When Notify() of |observer_list| is called in | 91 // ServiceWorkerContextWrapper. When Notify() of |observer_list| is called in |
| 92 // ServiceWorkerContextCore, the methods of ServiceWorkerContextObserver will | 92 // ServiceWorkerContextCore, the methods of ServiceWorkerContextObserver will |
| 93 // be called on the thread which called AddObserver() of |observer_list|. | 93 // be called on the thread which called AddObserver() of |observer_list|. |
| 94 ServiceWorkerContextCore( | 94 ServiceWorkerContextCore( |
| 95 const base::FilePath& user_data_directory, | 95 const base::FilePath& user_data_directory, |
| 96 base::SequencedTaskRunner* stores_task_runner, | 96 base::SequencedTaskRunner* cache_task_runner, |
| 97 base::SequencedTaskRunner* database_task_runner, | 97 base::SequencedTaskRunner* database_task_runner, |
| 98 base::MessageLoopProxy* disk_cache_thread, | 98 base::MessageLoopProxy* disk_cache_thread, |
| 99 quota::QuotaManagerProxy* quota_manager_proxy, | 99 quota::QuotaManagerProxy* quota_manager_proxy, |
| 100 ObserverListThreadSafe<ServiceWorkerContextObserver>* observer_list, | 100 ObserverListThreadSafe<ServiceWorkerContextObserver>* observer_list, |
| 101 ServiceWorkerContextWrapper* wrapper); | 101 ServiceWorkerContextWrapper* wrapper); |
| 102 ServiceWorkerContextCore( | 102 ServiceWorkerContextCore( |
| 103 ServiceWorkerContextCore* old_context, | 103 ServiceWorkerContextCore* old_context, |
| 104 ServiceWorkerContextWrapper* wrapper); | 104 ServiceWorkerContextWrapper* wrapper); |
| 105 virtual ~ServiceWorkerContextCore(); | 105 virtual ~ServiceWorkerContextCore(); |
| 106 | 106 |
| 107 // ServiceWorkerVersion::Listener overrides. | 107 // ServiceWorkerVersion::Listener overrides. |
| 108 virtual void OnWorkerStarted(ServiceWorkerVersion* version) OVERRIDE; | 108 virtual void OnWorkerStarted(ServiceWorkerVersion* version) OVERRIDE; |
| 109 virtual void OnWorkerStopped(ServiceWorkerVersion* version) OVERRIDE; | 109 virtual void OnWorkerStopped(ServiceWorkerVersion* version) OVERRIDE; |
| 110 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) OVERRIDE; | 110 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) OVERRIDE; |
| 111 virtual void OnErrorReported(ServiceWorkerVersion* version, | 111 virtual void OnErrorReported(ServiceWorkerVersion* version, |
| 112 const base::string16& error_message, | 112 const base::string16& error_message, |
| 113 int line_number, | 113 int line_number, |
| 114 int column_number, | 114 int column_number, |
| 115 const GURL& source_url) OVERRIDE; | 115 const GURL& source_url) OVERRIDE; |
| 116 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 116 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
| 117 int source_identifier, | 117 int source_identifier, |
| 118 int message_level, | 118 int message_level, |
| 119 const base::string16& message, | 119 const base::string16& message, |
| 120 int line_number, | 120 int line_number, |
| 121 const GURL& source_url) OVERRIDE; | 121 const GURL& source_url) OVERRIDE; |
| 122 | 122 |
| 123 ServiceWorkerStorage* storage() { return storage_.get(); } | 123 ServiceWorkerStorage* storage() { return storage_.get(); } |
| 124 ServiceWorkerCacheStorageManager* fetch_stores_manager() { | 124 ServiceWorkerCacheStorageManager* cache_manager() { |
| 125 return fetch_stores_manager_.get(); | 125 return cache_manager_.get(); |
| 126 } | 126 } |
| 127 ServiceWorkerProcessManager* process_manager(); | 127 ServiceWorkerProcessManager* process_manager(); |
| 128 EmbeddedWorkerRegistry* embedded_worker_registry() { | 128 EmbeddedWorkerRegistry* embedded_worker_registry() { |
| 129 return embedded_worker_registry_.get(); | 129 return embedded_worker_registry_.get(); |
| 130 } | 130 } |
| 131 ServiceWorkerJobCoordinator* job_coordinator() { | 131 ServiceWorkerJobCoordinator* job_coordinator() { |
| 132 return job_coordinator_.get(); | 132 return job_coordinator_.get(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // The context class owns the set of ProviderHosts. | 135 // The context class owns the set of ProviderHosts. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 const UnregistrationCallback& callback, | 195 const UnregistrationCallback& callback, |
| 196 ServiceWorkerStatusCode status); | 196 ServiceWorkerStatusCode status); |
| 197 | 197 |
| 198 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; | 198 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; |
| 199 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| | 199 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| |
| 200 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses | 200 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses |
| 201 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. | 201 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. |
| 202 ServiceWorkerContextWrapper* wrapper_; | 202 ServiceWorkerContextWrapper* wrapper_; |
| 203 scoped_ptr<ProcessToProviderMap> providers_; | 203 scoped_ptr<ProcessToProviderMap> providers_; |
| 204 scoped_ptr<ServiceWorkerStorage> storage_; | 204 scoped_ptr<ServiceWorkerStorage> storage_; |
| 205 scoped_ptr<ServiceWorkerCacheStorageManager> fetch_stores_manager_; | 205 scoped_ptr<ServiceWorkerCacheStorageManager> cache_manager_; |
| 206 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; | 206 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; |
| 207 scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; | 207 scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; |
| 208 std::map<int64, ServiceWorkerRegistration*> live_registrations_; | 208 std::map<int64, ServiceWorkerRegistration*> live_registrations_; |
| 209 std::map<int64, ServiceWorkerVersion*> live_versions_; | 209 std::map<int64, ServiceWorkerVersion*> live_versions_; |
| 210 int next_handle_id_; | 210 int next_handle_id_; |
| 211 scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 211 scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
| 212 observer_list_; | 212 observer_list_; |
| 213 | 213 |
| 214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); | 214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 } // namespace content | 217 } // namespace content |
| 218 | 218 |
| 219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ | 219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ |
| OLD | NEW |