| 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_WRAPPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 public: | 46 public: |
| 47 ServiceWorkerContextWrapper(BrowserContext* browser_context); | 47 ServiceWorkerContextWrapper(BrowserContext* browser_context); |
| 48 | 48 |
| 49 // Init and Shutdown are for use on the UI thread when the profile, | 49 // Init and Shutdown are for use on the UI thread when the profile, |
| 50 // storagepartition is being setup and torn down. | 50 // storagepartition is being setup and torn down. |
| 51 void Init(const base::FilePath& user_data_directory, | 51 void Init(const base::FilePath& user_data_directory, |
| 52 storage::QuotaManagerProxy* quota_manager_proxy, | 52 storage::QuotaManagerProxy* quota_manager_proxy, |
| 53 storage::SpecialStoragePolicy* special_storage_policy); | 53 storage::SpecialStoragePolicy* special_storage_policy); |
| 54 void Shutdown(); | 54 void Shutdown(); |
| 55 | 55 |
| 56 // False before initialization and after shutdown. |
| 57 virtual bool IsAlive() const; |
| 58 |
| 56 // Deletes all files on disk and restarts the system asynchronously. This | 59 // Deletes all files on disk and restarts the system asynchronously. This |
| 57 // leaves the system in a disabled state until it's done. This should be | 60 // leaves the system in a disabled state until it's done. This should be |
| 58 // called on the IO thread. | 61 // called on the IO thread. |
| 59 void DeleteAndStartOver(); | 62 void DeleteAndStartOver(); |
| 60 | 63 |
| 61 // The core context is only for use on the IO thread. | 64 // The core context is only for use on the IO thread. |
| 62 ServiceWorkerContextCore* context(); | 65 ServiceWorkerContextCore* context(); |
| 63 | 66 |
| 64 // The process manager can be used on either UI or IO. | 67 // The process manager can be used on either UI or IO. |
| 65 ServiceWorkerProcessManager* process_manager() { | 68 ServiceWorkerProcessManager* process_manager() { |
| 66 return process_manager_.get(); | 69 return process_manager_.get(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 // ServiceWorkerContext implementation: | 72 // ServiceWorkerContext implementation: |
| 70 virtual void RegisterServiceWorker( | 73 virtual void RegisterServiceWorker( |
| 71 const GURL& pattern, | 74 const GURL& pattern, |
| 72 const GURL& script_url, | 75 const GURL& script_url, |
| 73 const ResultCallback& continuation) override; | 76 const ResultCallback& continuation) override; |
| 74 virtual void UnregisterServiceWorker(const GURL& pattern, | 77 virtual void UnregisterServiceWorker( |
| 75 const ResultCallback& continuation) | 78 const GURL& pattern, |
| 76 override; | 79 const ResultCallback& continuation) override; |
| 77 virtual void Terminate() override; | 80 virtual void Terminate() override; |
| 78 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; | 81 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; |
| 79 virtual void DeleteForOrigin(const GURL& origin_url) override; | 82 virtual void DeleteForOrigin(const GURL& origin_url) override; |
| 80 | 83 |
| 84 // DeleteForOrigin with completion callback. Does not exit early, and returns |
| 85 // false if one or more of the deletions fail. |
| 86 virtual void DeleteForOrigin(const GURL& origin_url, |
| 87 const ResultCallback& done); |
| 88 |
| 81 void AddObserver(ServiceWorkerContextObserver* observer); | 89 void AddObserver(ServiceWorkerContextObserver* observer); |
| 82 void RemoveObserver(ServiceWorkerContextObserver* observer); | 90 void RemoveObserver(ServiceWorkerContextObserver* observer); |
| 83 | 91 |
| 84 bool is_incognito() const { return is_incognito_; } | 92 bool is_incognito() const { return is_incognito_; } |
| 85 | 93 |
| 86 // The URLRequestContext doesn't exist until after the StoragePartition is | 94 // The URLRequestContext doesn't exist until after the StoragePartition is |
| 87 // made (which is after this object is made). This function must be called | 95 // made (which is after this object is made). This function must be called |
| 88 // after this object is created but before any ServiceWorkerCache operations. | 96 // after this object is created but before any ServiceWorkerCache operations. |
| 89 // It must be called on the IO thread. If either parameter is NULL the | 97 // It must be called on the IO thread. If either parameter is NULL the |
| 90 // function immediately returns without forwarding to the | 98 // function immediately returns without forwarding to the |
| 91 // ServiceWorkerCacheStorageManager. | 99 // ServiceWorkerCacheStorageManager. |
| 92 void SetBlobParametersForCache( | 100 void SetBlobParametersForCache( |
| 93 net::URLRequestContextGetter* request_context, | 101 net::URLRequestContextGetter* request_context, |
| 94 ChromeBlobStorageContext* blob_storage_context); | 102 ChromeBlobStorageContext* blob_storage_context); |
| 95 | 103 |
| 96 private: | 104 private: |
| 97 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; | 105 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
| 98 friend class EmbeddedWorkerTestHelper; | 106 friend class EmbeddedWorkerTestHelper; |
| 99 friend class ServiceWorkerProcessManager; | 107 friend class ServiceWorkerProcessManager; |
| 108 friend class MockServiceWorkerContextWrapper; |
| 109 |
| 100 virtual ~ServiceWorkerContextWrapper(); | 110 virtual ~ServiceWorkerContextWrapper(); |
| 101 | 111 |
| 102 void InitInternal( | 112 void InitInternal( |
| 103 const base::FilePath& user_data_directory, | 113 const base::FilePath& user_data_directory, |
| 104 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, | 114 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, |
| 105 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 115 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
| 106 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 116 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 107 storage::QuotaManagerProxy* quota_manager_proxy, | 117 storage::QuotaManagerProxy* quota_manager_proxy, |
| 108 storage::SpecialStoragePolicy* special_storage_policy); | 118 storage::SpecialStoragePolicy* special_storage_policy); |
| 109 void ShutdownOnIO(); | 119 void ShutdownOnIO(); |
| 110 | 120 |
| 111 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); | 121 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); |
| 112 | 122 |
| 113 void DidGetAllRegistrationsForGetAllOrigins( | 123 void DidGetAllRegistrationsForGetAllOrigins( |
| 114 const GetUsageInfoCallback& callback, | 124 const GetUsageInfoCallback& callback, |
| 115 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 125 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
| 116 void DidGetAllRegistrationsForDeleteForOrigin( | |
| 117 const GURL& origin, | |
| 118 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | |
| 119 | 126 |
| 120 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 127 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
| 121 observer_list_; | 128 observer_list_; |
| 122 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; | 129 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; |
| 123 // Cleared in Shutdown(): | 130 // Cleared in Shutdown(): |
| 124 scoped_ptr<ServiceWorkerContextCore> context_core_; | 131 scoped_ptr<ServiceWorkerContextCore> context_core_; |
| 125 | 132 |
| 126 // Initialized in Init(); true if the user data directory is empty. | 133 // Initialized in Init(); true if the user data directory is empty. |
| 127 bool is_incognito_; | 134 bool is_incognito_; |
| 128 }; | 135 }; |
| 129 | 136 |
| 130 } // namespace content | 137 } // namespace content |
| 131 | 138 |
| 132 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 139 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
| OLD | NEW |