OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Writes |ids| into the database as purgeable resources. Returns OK on | 226 // Writes |ids| into the database as purgeable resources. Returns OK on |
227 // success. Otherwise writes nothing and returns an error. | 227 // success. Otherwise writes nothing and returns an error. |
228 Status WritePurgeableResourceIds(const std::set<int64>& ids); | 228 Status WritePurgeableResourceIds(const std::set<int64>& ids); |
229 | 229 |
230 // Deletes purgeable resource ids specified by |ids| from the database. | 230 // Deletes purgeable resource ids specified by |ids| from the database. |
231 // Returns OK on success. Otherwise deletes nothing and returns an error. | 231 // Returns OK on success. Otherwise deletes nothing and returns an error. |
232 Status ClearPurgeableResourceIds(const std::set<int64>& ids); | 232 Status ClearPurgeableResourceIds(const std::set<int64>& ids); |
233 | 233 |
234 // Moves |ids| from the uncommitted list to the purgeable list. | 234 // Moves |ids| from the uncommitted list to the purgeable list. |
235 // Returns OK on success. Otherwise deletes nothing and returns an error. | 235 // Returns OK on success. Otherwise deletes nothing and returns an error. |
236 Status PurgeUncommittedResourceIds(const std::set<int64>& ids); | 236 Status MoveResourceIdsFromUncommittedToPurgeable(const std::set<int64>& ids); |
237 | 237 |
238 // Deletes all data for |origins|, namely, unique origin, registrations and | 238 // Deletes all data for |origins|, namely, unique origin, registrations and |
239 // resource records. Resources are moved to the purgeable list. Returns OK if | 239 // resource records. Resources are moved to the purgeable list. Returns OK if |
240 // they are successfully deleted or not found in the database. Otherwise, | 240 // they are successfully deleted or not found in the database. Otherwise, |
241 // returns an error. | 241 // returns an error. |
242 Status DeleteAllDataForOrigins(const std::set<GURL>& origins, | 242 Status DeleteAllDataForOrigins(const std::set<GURL>& origins, |
243 std::vector<int64>* newly_purgeable_resources); | 243 std::vector<int64>* newly_purgeable_resources); |
244 | 244 |
245 // Completely deletes the contents of the database. | 245 // Completely deletes the contents of the database. |
246 // Be careful using this function. | 246 // Be careful using this function. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 std::vector<int64>* newly_purgeable_resources, | 291 std::vector<int64>* newly_purgeable_resources, |
292 leveldb::WriteBatch* batch); | 292 leveldb::WriteBatch* batch); |
293 | 293 |
294 // Reads resource ids for |id_key_prefix| from the database. Returns OK if | 294 // Reads resource ids for |id_key_prefix| from the database. Returns OK if |
295 // it's successfully read or not found in the database. Otherwise, returns an | 295 // it's successfully read or not found in the database. Otherwise, returns an |
296 // error. | 296 // error. |
297 Status ReadResourceIds( | 297 Status ReadResourceIds( |
298 const char* id_key_prefix, | 298 const char* id_key_prefix, |
299 std::set<int64>* ids); | 299 std::set<int64>* ids); |
300 | 300 |
301 // Write resource ids for |id_key_prefix| into the database. Returns OK on | 301 // Write resource ids for |id_key_prefix| into the database and bumps the next |
302 // success. Otherwise, returns writes nothing and returns an error. | 302 // available resource id if needed. Returns OK on success. Otherwise, returns |
| 303 // writes nothing and returns an error. |
303 Status WriteResourceIds( | 304 Status WriteResourceIds( |
304 const char* id_key_prefix, | 305 const char* id_key_prefix, |
305 const std::set<int64>& ids); | 306 const std::set<int64>& ids); |
306 Status WriteResourceIdsInBatch( | 307 Status WriteResourceIdsInBatch( |
307 const char* id_key_prefix, | 308 const char* id_key_prefix, |
308 const std::set<int64>& ids, | 309 const std::set<int64>& ids, |
309 leveldb::WriteBatch* batch); | 310 leveldb::WriteBatch* batch); |
310 | 311 |
311 // Deletes resource ids for |id_key_prefix| from the database. Returns OK if | 312 // Deletes resource ids for |id_key_prefix| from the database. Returns OK if |
312 // it's successfully deleted or not found in the database. Otherwise, returns | 313 // it's successfully deleted or not found in the database. Otherwise, returns |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 MigrateOnDiskCacheAccess); | 401 MigrateOnDiskCacheAccess); |
401 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, | 402 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, |
402 NotMigrateOnDatabaseAccess); | 403 NotMigrateOnDatabaseAccess); |
403 | 404 |
404 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); | 405 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); |
405 }; | 406 }; |
406 | 407 |
407 } // namespace content | 408 } // namespace content |
408 | 409 |
409 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 410 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
OLD | NEW |