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

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: remove needs_disk_cache_migration 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 // Reads the current diskcache version from the database. If the database
96 // hasn't been written anything yet, sets |disk_cache_version| to 0 and
97 // returns OK.
98 Status ReadDiskCacheVersion(int64* disk_cache_version);
99
100 // Writes the current diskcache version into the database.
101 Status WriteDiskCacheVersion(int64 disk_cache_version);
102
95 // Reads origins that have one or more than one registration from the 103 // Reads origins that have one or more than one registration from the
96 // database. Returns OK if they are successfully read or not found. 104 // database. Returns OK if they are successfully read or not found.
97 // Otherwise, returns an error. 105 // Otherwise, returns an error.
98 Status GetOriginsWithRegistrations(std::set<GURL>* origins); 106 Status GetOriginsWithRegistrations(std::set<GURL>* origins);
99 107
100 // Reads registrations for |origin| from the database. Returns OK if they are 108 // Reads registrations for |origin| from the database. Returns OK if they are
101 // successfully read or not found. Otherwise, returns an error. 109 // successfully read or not found. Otherwise, returns an error.
102 Status GetRegistrationsForOrigin( 110 Status GetRegistrationsForOrigin(
103 const GURL& origin, 111 const GURL& origin,
104 std::vector<RegistrationData>* registrations); 112 std::vector<RegistrationData>* registrations);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 Status WritePurgeableResourceIds(const std::set<int64>& ids); 225 Status WritePurgeableResourceIds(const std::set<int64>& ids);
218 226
219 // Deletes purgeable resource ids specified by |ids| from the database. 227 // Deletes purgeable resource ids specified by |ids| from the database.
220 // Returns OK on success. Otherwise deletes nothing and returns an error. 228 // Returns OK on success. Otherwise deletes nothing and returns an error.
221 Status ClearPurgeableResourceIds(const std::set<int64>& ids); 229 Status ClearPurgeableResourceIds(const std::set<int64>& ids);
222 230
223 // Moves |ids| from the uncommitted list to the purgeable list. 231 // Moves |ids| from the uncommitted list to the purgeable list.
224 // Returns OK on success. Otherwise deletes nothing and returns an error. 232 // Returns OK on success. Otherwise deletes nothing and returns an error.
225 Status PurgeUncommittedResourceIds(const std::set<int64>& ids); 233 Status PurgeUncommittedResourceIds(const std::set<int64>& ids);
226 234
235 // These *PurgeableFile functions are used for tracking purgeable files placed
236 // under the service worker directory (ie. kServiceWorkerDirectory defined in
237 // ServiceWorkerContextCore). The files should be deletable on the diskcache
238 // thread.
239
240 // Reads filenames of purgeable files from the database. Returns OK on success
241 // even if there are no purgeable files in the database.
242 Status GetPurgeableFiles(std::vector<std::string>* filenames);
243
244 // Writes |filename| into the database as a purgeable file. Returns OK on
245 // success.
246 Status WritePurgeableFile(const std::string& filename);
247
248 // Deletes a purgeable file specified by |filename| from the database. Returns
249 // OK on success.
250 Status ClearPurgeableFile(const std::string& filename);
251
227 // Deletes all data for |origins|, namely, unique origin, registrations and 252 // Deletes all data for |origins|, namely, unique origin, registrations and
228 // resource records. Resources are moved to the purgeable list. Returns OK if 253 // resource records. Resources are moved to the purgeable list. Returns OK if
229 // they are successfully deleted or not found in the database. Otherwise, 254 // they are successfully deleted or not found in the database. Otherwise,
230 // returns an error. 255 // returns an error.
231 Status DeleteAllDataForOrigins(const std::set<GURL>& origins, 256 Status DeleteAllDataForOrigins(const std::set<GURL>& origins,
232 std::vector<int64>* newly_purgeable_resources); 257 std::vector<int64>* newly_purgeable_resources);
233 258
234 // Completely deletes the contents of the database. 259 // Completely deletes the contents of the database.
235 // Be careful using this function. 260 // Be careful using this function.
236 Status DestroyDatabase(); 261 Status DestroyDatabase();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 INITIALIZED, 388 INITIALIZED,
364 DISABLED, 389 DISABLED,
365 }; 390 };
366 State state_; 391 State state_;
367 392
368 base::SequenceChecker sequence_checker_; 393 base::SequenceChecker sequence_checker_;
369 394
370 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase); 395 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase);
371 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory); 396 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory);
372 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); 397 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion);
398 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DiskCacheVersion);
373 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); 399 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
374 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, 400 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest,
375 Registration_UninitializedDatabase); 401 Registration_UninitializedDatabase);
376 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, 402 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest,
377 UserData_UninitializedDatabase); 403 UserData_UninitializedDatabase);
378 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); 404 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase);
379 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2); 405 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2);
380 406
381 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 407 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
382 }; 408 };
383 409
384 } // namespace content 410 } // namespace content
385 411
386 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 412 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698