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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // The process manager can be used on either UI or IO. | 64 // The process manager can be used on either UI or IO. |
65 ServiceWorkerProcessManager* process_manager() { | 65 ServiceWorkerProcessManager* process_manager() { |
66 return process_manager_.get(); | 66 return process_manager_.get(); |
67 } | 67 } |
68 | 68 |
69 // ServiceWorkerContext implementation: | 69 // ServiceWorkerContext implementation: |
70 virtual void RegisterServiceWorker( | 70 virtual void RegisterServiceWorker( |
71 const GURL& pattern, | 71 const GURL& pattern, |
72 const GURL& script_url, | 72 const GURL& script_url, |
73 const ResultCallback& continuation) override; | 73 const ResultCallback& continuation) override; |
74 virtual void UnregisterServiceWorker(const GURL& pattern, | 74 virtual void UnregisterServiceWorker( |
75 const ResultCallback& continuation) | 75 const GURL& pattern, |
76 override; | 76 const ResultCallback& continuation) override; |
77 virtual void Terminate() override; | 77 virtual void Terminate() override; |
78 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; | 78 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; |
79 virtual void DeleteForOrigin(const GURL& origin_url) override; | 79 virtual void DeleteForOrigin(const GURL& origin_url) override; |
80 | 80 |
| 81 // DeleteForOrigin with completion callback. Does not exit early, and returns |
| 82 // false if one or more of the deletions fail. |
| 83 virtual void DeleteForOrigin(const GURL& origin_url, |
| 84 const ResultCallback& done); |
| 85 |
81 void AddObserver(ServiceWorkerContextObserver* observer); | 86 void AddObserver(ServiceWorkerContextObserver* observer); |
82 void RemoveObserver(ServiceWorkerContextObserver* observer); | 87 void RemoveObserver(ServiceWorkerContextObserver* observer); |
83 | 88 |
84 bool is_incognito() const { return is_incognito_; } | 89 bool is_incognito() const { return is_incognito_; } |
85 | 90 |
86 // The URLRequestContext doesn't exist until after the StoragePartition is | 91 // The URLRequestContext doesn't exist until after the StoragePartition is |
87 // made (which is after this object is made). This function must be called | 92 // made (which is after this object is made). This function must be called |
88 // after this object is created but before any ServiceWorkerCache operations. | 93 // 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 | 94 // It must be called on the IO thread. If either parameter is NULL the |
90 // function immediately returns without forwarding to the | 95 // function immediately returns without forwarding to the |
91 // ServiceWorkerCacheStorageManager. | 96 // ServiceWorkerCacheStorageManager. |
92 void SetBlobParametersForCache( | 97 void SetBlobParametersForCache( |
93 net::URLRequestContextGetter* request_context, | 98 net::URLRequestContextGetter* request_context, |
94 ChromeBlobStorageContext* blob_storage_context); | 99 ChromeBlobStorageContext* blob_storage_context); |
95 | 100 |
96 private: | 101 private: |
97 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; | 102 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
98 friend class EmbeddedWorkerTestHelper; | 103 friend class EmbeddedWorkerTestHelper; |
99 friend class ServiceWorkerProcessManager; | 104 friend class ServiceWorkerProcessManager; |
| 105 friend class MockServiceWorkerContextWrapper; |
| 106 |
100 virtual ~ServiceWorkerContextWrapper(); | 107 virtual ~ServiceWorkerContextWrapper(); |
101 | 108 |
102 void InitInternal( | 109 void InitInternal( |
103 const base::FilePath& user_data_directory, | 110 const base::FilePath& user_data_directory, |
104 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, | 111 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, |
105 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 112 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
106 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 113 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
107 storage::QuotaManagerProxy* quota_manager_proxy, | 114 storage::QuotaManagerProxy* quota_manager_proxy, |
108 storage::SpecialStoragePolicy* special_storage_policy); | 115 storage::SpecialStoragePolicy* special_storage_policy); |
109 void ShutdownOnIO(); | 116 void ShutdownOnIO(); |
110 | 117 |
111 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); | 118 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); |
112 | 119 |
113 void DidGetAllRegistrationsForGetAllOrigins( | 120 void DidGetAllRegistrationsForGetAllOrigins( |
114 const GetUsageInfoCallback& callback, | 121 const GetUsageInfoCallback& callback, |
115 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 122 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
116 void DidGetAllRegistrationsForDeleteForOrigin( | |
117 const GURL& origin, | |
118 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | |
119 | 123 |
120 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 124 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
121 observer_list_; | 125 observer_list_; |
122 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; | 126 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; |
123 // Cleared in Shutdown(): | 127 // Cleared in Shutdown(): |
124 scoped_ptr<ServiceWorkerContextCore> context_core_; | 128 scoped_ptr<ServiceWorkerContextCore> context_core_; |
125 | 129 |
126 // Initialized in Init(); true if the user data directory is empty. | 130 // Initialized in Init(); true if the user data directory is empty. |
127 bool is_incognito_; | 131 bool is_incognito_; |
128 }; | 132 }; |
129 | 133 |
130 } // namespace content | 134 } // namespace content |
131 | 135 |
132 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 136 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
OLD | NEW |