| 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_STORAGE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 ServiceWorkerRegistration* registration, | 103 ServiceWorkerRegistration* registration, |
| 104 const StatusCallback& callback); | 104 const StatusCallback& callback); |
| 105 | 105 |
| 106 // Deletes the registration data for |registration_id|, the | 106 // Deletes the registration data for |registration_id|, the |
| 107 // script resources for the registration's stored version | 107 // script resources for the registration's stored version |
| 108 // will remain available until either a browser restart or | 108 // will remain available until either a browser restart or |
| 109 // DeleteVersionResources is called. | 109 // DeleteVersionResources is called. |
| 110 void DeleteRegistration(int64 registration_id, | 110 void DeleteRegistration(int64 registration_id, |
| 111 const GURL& origin, | 111 const GURL& origin, |
| 112 const StatusCallback& callback); | 112 const StatusCallback& callback); |
| 113 void DeleteVersionResources(int64 version_id, const StatusCallback& callback); |
| 113 | 114 |
| 114 scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( | 115 scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( |
| 115 int64 response_id); | 116 int64 response_id); |
| 116 scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( | 117 scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( |
| 117 int64 response_id); | 118 int64 response_id); |
| 118 | 119 |
| 119 // Adds |id| to the set of resources ids that are in the disk | 120 // Adds |id| to the set of resources ids that are in the disk |
| 120 // cache but not yet stored with a registration. | 121 // cache but not yet stored with a registration. |
| 121 void StoreUncommittedReponseId(int64 id); | 122 void StoreUncommittedReponseId(int64 id); |
| 122 | 123 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 RegistrationRefsById; | 164 RegistrationRefsById; |
| 164 typedef base::Callback<void( | 165 typedef base::Callback<void( |
| 165 InitialData* data, | 166 InitialData* data, |
| 166 ServiceWorkerDatabase::Status status)> InitializeCallback; | 167 ServiceWorkerDatabase::Status status)> InitializeCallback; |
| 167 typedef base::Callback<void( | 168 typedef base::Callback<void( |
| 168 const GURL& origin, | 169 const GURL& origin, |
| 169 const std::vector<int64>& newly_purgeable_resources, | 170 const std::vector<int64>& newly_purgeable_resources, |
| 170 ServiceWorkerDatabase::Status status)> WriteRegistrationCallback; | 171 ServiceWorkerDatabase::Status status)> WriteRegistrationCallback; |
| 171 typedef base::Callback<void( | 172 typedef base::Callback<void( |
| 172 bool origin_is_deletable, | 173 bool origin_is_deletable, |
| 173 const std::vector<int64>& newly_purgeable_resources, | |
| 174 ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback; | 174 ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback; |
| 175 typedef base::Callback<void( | 175 typedef base::Callback<void( |
| 176 const ServiceWorkerDatabase::RegistrationData& data, | 176 const std::vector<int64>& newly_purgeable_resources, |
| 177 const ResourceList& resources, | 177 ServiceWorkerDatabase::Status status)> DeleteVersionResourcesCallback; |
| 178 ServiceWorkerDatabase::Status status)> FindInDBCallback; | 178 typedef base::Callback< |
| 179 void(const ServiceWorkerDatabase::RegistrationData& data, |
| 180 const ResourceList& resources, |
| 181 ServiceWorkerDatabase::Status status)> FindInDBCallback; |
| 179 | 182 |
| 180 ServiceWorkerStorage(const base::FilePath& path, | 183 ServiceWorkerStorage(const base::FilePath& path, |
| 181 base::WeakPtr<ServiceWorkerContextCore> context, | 184 base::WeakPtr<ServiceWorkerContextCore> context, |
| 182 base::SequencedTaskRunner* database_task_runner, | 185 base::SequencedTaskRunner* database_task_runner, |
| 183 base::MessageLoopProxy* disk_cache_thread, | 186 base::MessageLoopProxy* disk_cache_thread, |
| 184 quota::QuotaManagerProxy* quota_manager_proxy); | 187 quota::QuotaManagerProxy* quota_manager_proxy); |
| 185 | 188 |
| 186 base::FilePath GetDatabasePath(); | 189 base::FilePath GetDatabasePath(); |
| 187 base::FilePath GetDiskCachePath(); | 190 base::FilePath GetDiskCachePath(); |
| 188 | 191 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 213 RegistrationList* registrations, | 216 RegistrationList* registrations, |
| 214 ServiceWorkerDatabase::Status status); | 217 ServiceWorkerDatabase::Status status); |
| 215 void DidStoreRegistration( | 218 void DidStoreRegistration( |
| 216 const StatusCallback& callback, | 219 const StatusCallback& callback, |
| 217 const GURL& origin, | 220 const GURL& origin, |
| 218 const std::vector<int64>& newly_purgeable_resources, | 221 const std::vector<int64>& newly_purgeable_resources, |
| 219 ServiceWorkerDatabase::Status status); | 222 ServiceWorkerDatabase::Status status); |
| 220 void DidUpdateToActiveState( | 223 void DidUpdateToActiveState( |
| 221 const StatusCallback& callback, | 224 const StatusCallback& callback, |
| 222 ServiceWorkerDatabase::Status status); | 225 ServiceWorkerDatabase::Status status); |
| 223 void DidDeleteRegistration( | 226 void DidDeleteRegistration(const GURL& origin, |
| 224 const GURL& origin, | 227 const StatusCallback& callback, |
| 228 bool origin_is_deletable, |
| 229 ServiceWorkerDatabase::Status status); |
| 230 void DidDeleteVersionResources( |
| 225 const StatusCallback& callback, | 231 const StatusCallback& callback, |
| 226 bool origin_is_deletable, | |
| 227 const std::vector<int64>& newly_purgeable_resources, | 232 const std::vector<int64>& newly_purgeable_resources, |
| 228 ServiceWorkerDatabase::Status status); | 233 ServiceWorkerDatabase::Status status); |
| 229 | 234 |
| 230 scoped_refptr<ServiceWorkerRegistration> GetOrCreateRegistration( | 235 scoped_refptr<ServiceWorkerRegistration> GetOrCreateRegistration( |
| 231 const ServiceWorkerDatabase::RegistrationData& data, | 236 const ServiceWorkerDatabase::RegistrationData& data, |
| 232 const ResourceList& resources); | 237 const ResourceList& resources); |
| 233 ServiceWorkerRegistration* FindInstallingRegistrationForDocument( | 238 ServiceWorkerRegistration* FindInstallingRegistrationForDocument( |
| 234 const GURL& document_url); | 239 const GURL& document_url); |
| 235 ServiceWorkerRegistration* FindInstallingRegistrationForPattern( | 240 ServiceWorkerRegistration* FindInstallingRegistrationForPattern( |
| 236 const GURL& scope); | 241 const GURL& scope); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 251 static void ReadInitialDataFromDB( | 256 static void ReadInitialDataFromDB( |
| 252 ServiceWorkerDatabase* database, | 257 ServiceWorkerDatabase* database, |
| 253 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 258 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 254 const InitializeCallback& callback); | 259 const InitializeCallback& callback); |
| 255 static void DeleteRegistrationFromDB( | 260 static void DeleteRegistrationFromDB( |
| 256 ServiceWorkerDatabase* database, | 261 ServiceWorkerDatabase* database, |
| 257 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 262 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 258 int64 registration_id, | 263 int64 registration_id, |
| 259 const GURL& origin, | 264 const GURL& origin, |
| 260 const DeleteRegistrationCallback& callback); | 265 const DeleteRegistrationCallback& callback); |
| 266 static void DeleteVersionResourcesFromDB( |
| 267 ServiceWorkerDatabase* database, |
| 268 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 269 int64 version_id, |
| 270 const DeleteVersionResourcesCallback& callback); |
| 261 static void WriteRegistrationInDB( | 271 static void WriteRegistrationInDB( |
| 262 ServiceWorkerDatabase* database, | 272 ServiceWorkerDatabase* database, |
| 263 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 273 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 264 const ServiceWorkerDatabase::RegistrationData& registration, | 274 const ServiceWorkerDatabase::RegistrationData& registration, |
| 265 const ResourceList& resources, | 275 const ResourceList& resources, |
| 266 const WriteRegistrationCallback& callback); | 276 const WriteRegistrationCallback& callback); |
| 267 static void FindForDocumentInDB( | 277 static void FindForDocumentInDB( |
| 268 ServiceWorkerDatabase* database, | 278 ServiceWorkerDatabase* database, |
| 269 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 279 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 270 const GURL& document_url, | 280 const GURL& document_url, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 base::FilePath path_; | 323 base::FilePath path_; |
| 314 base::WeakPtr<ServiceWorkerContextCore> context_; | 324 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 315 | 325 |
| 316 // Only accessed on |database_task_runner_|. | 326 // Only accessed on |database_task_runner_|. |
| 317 scoped_ptr<ServiceWorkerDatabase> database_; | 327 scoped_ptr<ServiceWorkerDatabase> database_; |
| 318 | 328 |
| 319 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; | 329 scoped_refptr<base::SequencedTaskRunner> database_task_runner_; |
| 320 scoped_refptr<base::MessageLoopProxy> disk_cache_thread_; | 330 scoped_refptr<base::MessageLoopProxy> disk_cache_thread_; |
| 321 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 331 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 322 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; | 332 scoped_ptr<ServiceWorkerDiskCache> disk_cache_; |
| 323 std::deque<int64> purgeable_reource_ids_; | 333 std::deque<int64> purgeable_resource_ids_; |
| 324 bool is_purge_pending_; | 334 bool is_purge_pending_; |
| 325 | 335 |
| 326 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 336 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
| 327 | 337 |
| 328 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 338 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
| 329 }; | 339 }; |
| 330 | 340 |
| 331 } // namespace content | 341 } // namespace content |
| 332 | 342 |
| 333 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 343 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
| OLD | NEW |