Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: content/browser/service_worker/service_worker_database.h

Issue 1152543002: ServiceWorker: Migrate the script cache backend from BlockFile to Simple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remake Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 enum DiskCacheMigrationState {
96 // A diskcache has not been used yet.
97 DISKCACHE_NOT_USED,
98
99 // A diskcache needs to be migrated.
100 DISKCACHE_NEEDS_TO_MIGRATE,
101
102 // A diskcache was migrated but an old diskcache still exists.
103 DISKCACHE_NEEDS_TO_DELETE_OLD,
104
105 // A diskcache was migrated and an old diskcache was deleted.
106 DISKCACHE_MIGRATED,
michaeln 2015/06/12 01:55:45 Can MIGRATED and NOT_USED be merged into MIGRATION
107
108 DISKCACHE_UNKNOWN_STATE,
109 };
110
111 // Reads a diskcache migration state from the database.
112 Status ReadDiskCacheMigrationState(DiskCacheMigrationState* state);
113
114 // Writes a diskcache migration state in the database. |state| should be
115 // DISKCACHE_MIGRATED or DISKCACHE_NEEDS_TO_DELETE_OLD.
116 Status WriteDiskCacheMigrationState(DiskCacheMigrationState state);
117
95 // Reads origins that have one or more than one registration from the 118 // Reads origins that have one or more than one registration from the
96 // database. Returns OK if they are successfully read or not found. 119 // database. Returns OK if they are successfully read or not found.
97 // Otherwise, returns an error. 120 // Otherwise, returns an error.
98 Status GetOriginsWithRegistrations(std::set<GURL>* origins); 121 Status GetOriginsWithRegistrations(std::set<GURL>* origins);
99 122
100 // Reads registrations for |origin| from the database. Returns OK if they are 123 // Reads registrations for |origin| from the database. Returns OK if they are
101 // successfully read or not found. Otherwise, returns an error. 124 // successfully read or not found. Otherwise, returns an error.
102 Status GetRegistrationsForOrigin( 125 Status GetRegistrationsForOrigin(
103 const GURL& origin, 126 const GURL& origin,
104 std::vector<RegistrationData>* registrations, 127 std::vector<RegistrationData>* registrations,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 INITIALIZED, 387 INITIALIZED,
365 DISABLED, 388 DISABLED,
366 }; 389 };
367 State state_; 390 State state_;
368 391
369 base::SequenceChecker sequence_checker_; 392 base::SequenceChecker sequence_checker_;
370 393
371 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase); 394 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase);
372 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory); 395 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory);
373 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); 396 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion);
397 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DiskCacheMigrationState);
374 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); 398 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
375 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, 399 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest,
376 Registration_UninitializedDatabase); 400 Registration_UninitializedDatabase);
377 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, 401 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest,
378 UserData_UninitializedDatabase); 402 UserData_UninitializedDatabase);
379 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); 403 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase);
380 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2); 404 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2);
381 405
382 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 406 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
383 }; 407 };
384 408
385 } // namespace content 409 } // namespace content
386 410
387 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 411 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698