| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // database. | 193 // database. |
| 194 Status DeleteUserData(int64 registration_id, | 194 Status DeleteUserData(int64 registration_id, |
| 195 const std::string& user_data_name); | 195 const std::string& user_data_name); |
| 196 | 196 |
| 197 // Reads user data for all registrations that have data with |user_data_name| | 197 // Reads user data for all registrations that have data with |user_data_name| |
| 198 // from the database. Returns OK if they are successfully read or not found. | 198 // from the database. Returns OK if they are successfully read or not found. |
| 199 Status ReadUserDataForAllRegistrations( | 199 Status ReadUserDataForAllRegistrations( |
| 200 const std::string& user_data_name, | 200 const std::string& user_data_name, |
| 201 std::vector<std::pair<int64, std::string>>* user_data); | 201 std::vector<std::pair<int64, std::string>>* user_data); |
| 202 | 202 |
| 203 // As new resources are put into the diskcache, they go into an uncommitted | 203 // Resources should belong to one of following resource lists: uncommitted, |
| 204 // list. When a registration is saved that refers to those ids, they're | 204 // committed and purgeable. |
| 205 // removed from that list. When a resource no longer has any registrations or | 205 // As new resources are put into the diskcache, they go into the uncommitted |
| 206 // list. When a registration is saved that refers to those ids, they're moved |
| 207 // to the committed list. When a resource no longer has any registrations or |
| 206 // caches referring to it, it's added to the purgeable list. Periodically, | 208 // caches referring to it, it's added to the purgeable list. Periodically, |
| 207 // the purgeable list can be purged from the diskcache. At system startup, all | 209 // the purgeable list can be purged from the diskcache. At system startup, all |
| 208 // uncommitted ids are moved to the purgeable list. | 210 // uncommitted ids are moved to the purgeable list. |
| 209 | 211 |
| 210 // Reads uncommitted resource ids from the database. Returns OK on success. | 212 // Reads resource ids from the uncommitted list. Returns OK on success. |
| 211 // Otherwise clears |ids| and returns an error. | 213 // Otherwise clears |ids| and returns an error. |
| 212 Status GetUncommittedResourceIds(std::set<int64>* ids); | 214 Status GetUncommittedResourceIds(std::set<int64>* ids); |
| 213 | 215 |
| 214 // Writes |ids| into the database as uncommitted resources. Returns OK on | 216 // Writes resource ids into the uncommitted list. Returns OK on success. |
| 215 // success. Otherwise writes nothing and returns an error. | 217 // Otherwise writes nothing and returns an error. |
| 216 Status WriteUncommittedResourceIds(const std::set<int64>& ids); | 218 Status WriteUncommittedResourceIds(const std::set<int64>& ids); |
| 217 | 219 |
| 218 // Deletes uncommitted resource ids specified by |ids| from the database. | 220 // Reads resource ids from the purgeable list. Returns OK on success. |
| 219 // Returns OK on success. Otherwise deletes nothing and returns an error. | |
| 220 Status ClearUncommittedResourceIds(const std::set<int64>& ids); | |
| 221 | |
| 222 // Reads purgeable resource ids from the database. Returns OK on success. | |
| 223 // Otherwise clears |ids| and returns an error. | 221 // Otherwise clears |ids| and returns an error. |
| 224 Status GetPurgeableResourceIds(std::set<int64>* ids); | 222 Status GetPurgeableResourceIds(std::set<int64>* ids); |
| 225 | 223 |
| 226 // Writes |ids| into the database as purgeable resources. Returns OK on | 224 // Deletes resource ids from the purgeable list. Returns OK on success. |
| 227 // success. Otherwise writes nothing and returns an error. | 225 // Otherwise deletes nothing and returns an error. |
| 228 Status WritePurgeableResourceIds(const std::set<int64>& ids); | |
| 229 | |
| 230 // Deletes purgeable resource ids specified by |ids| from the database. | |
| 231 // Returns OK on success. Otherwise deletes nothing and returns an error. | |
| 232 Status ClearPurgeableResourceIds(const std::set<int64>& ids); | 226 Status ClearPurgeableResourceIds(const std::set<int64>& ids); |
| 233 | 227 |
| 234 // Moves |ids| from the uncommitted list to the purgeable list. | 228 // Writes resource ids into the purgeable list and removes them from the |
| 235 // Returns OK on success. Otherwise deletes nothing and returns an error. | 229 // uncommitted list. Returns OK on success. Otherwise writes nothing and |
| 230 // returns an error. |
| 236 Status PurgeUncommittedResourceIds(const std::set<int64>& ids); | 231 Status PurgeUncommittedResourceIds(const std::set<int64>& ids); |
| 237 | 232 |
| 238 // Deletes all data for |origins|, namely, unique origin, registrations and | 233 // Deletes all data for |origins|, namely, unique origin, registrations and |
| 239 // resource records. Resources are moved to the purgeable list. Returns OK if | 234 // resource records. Resources are moved to the purgeable list. Returns OK if |
| 240 // they are successfully deleted or not found in the database. Otherwise, | 235 // they are successfully deleted or not found in the database. Otherwise, |
| 241 // returns an error. | 236 // returns an error. |
| 242 Status DeleteAllDataForOrigins(const std::set<GURL>& origins, | 237 Status DeleteAllDataForOrigins(const std::set<GURL>& origins, |
| 243 std::vector<int64>* newly_purgeable_resources); | 238 std::vector<int64>* newly_purgeable_resources); |
| 244 | 239 |
| 245 // Completely deletes the contents of the database. | 240 // Completely deletes the contents of the database. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 288 |
| 294 // Reads resource ids for |id_key_prefix| from the database. Returns OK if | 289 // 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 | 290 // it's successfully read or not found in the database. Otherwise, returns an |
| 296 // error. | 291 // error. |
| 297 Status ReadResourceIds( | 292 Status ReadResourceIds( |
| 298 const char* id_key_prefix, | 293 const char* id_key_prefix, |
| 299 std::set<int64>* ids); | 294 std::set<int64>* ids); |
| 300 | 295 |
| 301 // Write resource ids for |id_key_prefix| into the database. Returns OK on | 296 // Write resource ids for |id_key_prefix| into the database. Returns OK on |
| 302 // success. Otherwise, returns writes nothing and returns an error. | 297 // success. Otherwise, returns writes nothing and returns an error. |
| 303 Status WriteResourceIds( | |
| 304 const char* id_key_prefix, | |
| 305 const std::set<int64>& ids); | |
| 306 Status WriteResourceIdsInBatch( | 298 Status WriteResourceIdsInBatch( |
| 307 const char* id_key_prefix, | 299 const char* id_key_prefix, |
| 308 const std::set<int64>& ids, | 300 const std::set<int64>& ids, |
| 309 leveldb::WriteBatch* batch); | 301 leveldb::WriteBatch* batch); |
| 310 | 302 |
| 311 // Deletes resource ids for |id_key_prefix| from the database. Returns OK if | 303 // 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 | 304 // it's successfully deleted or not found in the database. Otherwise, returns |
| 313 // an error. | 305 // an error. |
| 314 Status DeleteResourceIds( | |
| 315 const char* id_key_prefix, | |
| 316 const std::set<int64>& ids); | |
| 317 Status DeleteResourceIdsInBatch( | 306 Status DeleteResourceIdsInBatch( |
| 318 const char* id_key_prefix, | 307 const char* id_key_prefix, |
| 319 const std::set<int64>& ids, | 308 const std::set<int64>& ids, |
| 320 leveldb::WriteBatch* batch); | 309 leveldb::WriteBatch* batch); |
| 321 | 310 |
| 322 // Deletes all user data for |registration_id| from the database. Returns OK | 311 // Deletes all user data for |registration_id| from the database. Returns OK |
| 323 // if they are successfully deleted or not found in the database. | 312 // if they are successfully deleted or not found in the database. |
| 324 Status DeleteUserDataForRegistration( | 313 Status DeleteUserDataForRegistration( |
| 325 int64 registration_id, | 314 int64 registration_id, |
| 326 leveldb::WriteBatch* batch); | 315 leveldb::WriteBatch* batch); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 MigrateOnDiskCacheAccess); | 389 MigrateOnDiskCacheAccess); |
| 401 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, | 390 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, |
| 402 NotMigrateOnDatabaseAccess); | 391 NotMigrateOnDatabaseAccess); |
| 403 | 392 |
| 404 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); | 393 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); |
| 405 }; | 394 }; |
| 406 | 395 |
| 407 } // namespace content | 396 } // namespace content |
| 408 | 397 |
| 409 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 398 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
| OLD | NEW |