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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 }; | 85 }; |
86 | 86 |
87 // Reads next available ids from the database. Returns OK if they are | 87 // Reads next available ids from the database. Returns OK if they are |
88 // successfully read. Fills the arguments with an initial value and returns | 88 // successfully read. Fills the arguments with an initial value and returns |
89 // OK if they are not found in the database. Otherwise, returns an error. | 89 // OK if they are not found in the database. Otherwise, returns an error. |
90 Status GetNextAvailableIds( | 90 Status GetNextAvailableIds( |
91 int64* next_avail_registration_id, | 91 int64* next_avail_registration_id, |
92 int64* next_avail_version_id, | 92 int64* next_avail_version_id, |
93 int64* next_avail_resource_id); | 93 int64* next_avail_resource_id); |
94 | 94 |
| 95 // Used for diskcache migration (http://crbug.com/487482). Returns true if the |
| 96 // storage needs to migrate a disk cache. |
| 97 Status IsDiskCacheMigrationNeeded(bool* migration_needed); |
| 98 Status SetDiskCacheMigrationNotNeeded(); |
| 99 |
| 100 // Used for diskcache migration (http://crbug.com/487482). Returns true if the |
| 101 // storage needs to delete an old disk cache. |
| 102 Status IsOldDiskCacheDeletionNeeded(bool* deletion_needed); |
| 103 Status SetOldDiskCacheDeletionNotNeeded(); |
| 104 |
95 // Reads origins that have one or more than one registration from the | 105 // Reads origins that have one or more than one registration from the |
96 // database. Returns OK if they are successfully read or not found. | 106 // database. Returns OK if they are successfully read or not found. |
97 // Otherwise, returns an error. | 107 // Otherwise, returns an error. |
98 Status GetOriginsWithRegistrations(std::set<GURL>* origins); | 108 Status GetOriginsWithRegistrations(std::set<GURL>* origins); |
99 | 109 |
100 // Reads registrations for |origin| from the database. Returns OK if they are | 110 // Reads registrations for |origin| from the database. Returns OK if they are |
101 // successfully read or not found. Otherwise, returns an error. | 111 // successfully read or not found. Otherwise, returns an error. |
102 Status GetRegistrationsForOrigin( | 112 Status GetRegistrationsForOrigin( |
103 const GURL& origin, | 113 const GURL& origin, |
104 std::vector<RegistrationData>* registrations, | 114 std::vector<RegistrationData>* registrations, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 int64 next_avail_resource_id_; | 369 int64 next_avail_resource_id_; |
360 int64 next_avail_version_id_; | 370 int64 next_avail_version_id_; |
361 | 371 |
362 enum State { | 372 enum State { |
363 UNINITIALIZED, | 373 UNINITIALIZED, |
364 INITIALIZED, | 374 INITIALIZED, |
365 DISABLED, | 375 DISABLED, |
366 }; | 376 }; |
367 State state_; | 377 State state_; |
368 | 378 |
| 379 void set_skip_writing_diskcache_migration_state_on_init_for_testing() { |
| 380 skip_writing_diskcache_migration_state_on_init_for_testing_ = true; |
| 381 } |
| 382 bool skip_writing_diskcache_migration_state_on_init_for_testing_; |
| 383 |
369 base::SequenceChecker sequence_checker_; | 384 base::SequenceChecker sequence_checker_; |
370 | 385 |
371 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase); | 386 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase); |
372 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory); | 387 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory); |
373 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); | 388 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); |
374 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); | 389 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); |
375 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, | 390 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, |
376 Registration_UninitializedDatabase); | 391 Registration_UninitializedDatabase); |
377 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, | 392 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, |
378 UserData_UninitializedDatabase); | 393 UserData_UninitializedDatabase); |
379 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); | 394 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); |
| 395 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DiskCacheMigrationState); |
380 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2); | 396 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2); |
| 397 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, |
| 398 MigrateOnDiskCacheAccess); |
| 399 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest, |
| 400 NotMigrateOnDatabaseAccess); |
381 | 401 |
382 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); | 402 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); |
383 }; | 403 }; |
384 | 404 |
385 } // namespace content | 405 } // namespace content |
386 | 406 |
387 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 407 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
OLD | NEW |