Index: content/browser/service_worker/service_worker_database.h |
diff --git a/content/browser/service_worker/service_worker_database.h b/content/browser/service_worker/service_worker_database.h |
index 6e368da65f7f0a6a7607153ad886a4a6df05e49b..d91e3c4ba112f72f28bbbb01bc60117a32573966 100644 |
--- a/content/browser/service_worker/service_worker_database.h |
+++ b/content/browser/service_worker/service_worker_database.h |
@@ -97,20 +97,44 @@ class CONTENT_EXPORT ServiceWorkerDatabase { |
// (resource ids will be added/removed from the uncommitted/purgeable |
// lists as needed) |
- bool ReadRegistration(int64 registration_id, |
- const GURL& origin, |
- RegistrationData* registration, |
- std::vector<ResourceRecord>* resources); |
- bool WriteRegistration(const RegistrationData& registration, |
- const std::vector<ResourceRecord>& resources); |
- |
- bool UpdateVersionToActive(int64 registration_id, |
- const GURL& origin); |
- bool UpdateLastCheckTime(int64 registration_id, |
- const GURL& origin, |
- const base::Time& time); |
- bool DeleteRegistration(int64 registration_id, |
- const GURL& origin); |
+ // Reads a registration for |registration_id| and resource records associated |
+ // with it from the database. Returns OK if they are successfully read. |
+ // Otherwise, returns an error. |
+ ServiceWorkerStatusCode ReadRegistration( |
+ int64 registration_id, |
+ const GURL& origin, |
+ RegistrationData* registration, |
+ std::vector<ResourceRecord>* resources); |
+ |
+ // Writes |registration| and |resources| into the database and does following |
+ // things: |
+ // - Deletes an old version of the registration if exists. |
+ // - Bumps the next registration id and the next version id if needed. |
+ // - Removes |resources| from the uncommitted list if exist. |
+ // Returns OK they are successfully written. Otherwise, returns an error. |
+ ServiceWorkerStatusCode WriteRegistration( |
+ const RegistrationData& registration, |
+ const std::vector<ResourceRecord>& resources); |
+ |
+ // Updates a registration for |registration_id| to an active state. Returns OK |
+ // if it's successfully updated. Otherwise, returns an error. |
+ ServiceWorkerStatusCode UpdateVersionToActive( |
+ int64 registration_id, |
+ const GURL& origin); |
+ |
+ // Updates last check time of a registration for |registration_id| by |time|. |
+ // Returns OK if it's successfully updated. Otherwise, returns an error. |
+ ServiceWorkerStatusCode UpdateLastCheckTime( |
+ int64 registration_id, |
+ const GURL& origin, |
+ const base::Time& time); |
+ |
+ // Deletes a registration for |registration_id| and moves resource records |
+ // associated with it into the purgeable list. Returns OK if it's successfully |
+ // deleted or not found in the database. Otherwise, returns an error. |
+ ServiceWorkerStatusCode DeleteRegistration( |
+ int64 registration_id, |
+ const GURL& origin); |
// As new resources are put into the diskcache, they go into an uncommitted |
// list. When a registration is saved that refers to those ids, they're |
@@ -143,9 +167,11 @@ class CONTENT_EXPORT ServiceWorkerDatabase { |
// Returns true on success. Otherwise deletes nothing and returns false. |
bool ClearPurgeableResourceIds(const std::set<int64>& ids); |
- // Delete all data for |origin|, namely, unique origin, registrations and |
- // resource records. Resources are moved to the purgeable list. |
- bool DeleteAllDataForOrigin(const GURL& origin); |
+ // Deletes all data for |origin|, namely, unique origin, registrations and |
+ // resource records. Resources are moved to the purgeable list. Returns OK if |
+ // they are successfully deleted or not found in the database. Otherwise, |
+ // returns an error. |
+ ServiceWorkerStatusCode DeleteAllDataForOrigin(const GURL& origin); |
bool is_disabled() const { return is_disabled_; } |
bool was_corruption_detected() const { return was_corruption_detected_; } |
@@ -164,13 +190,27 @@ class CONTENT_EXPORT ServiceWorkerDatabase { |
const char* id_key, |
int64* next_avail_id); |
- bool ReadRegistrationData(int64 registration_id, |
- const GURL& origin, |
- RegistrationData* registration); |
- bool ReadResourceRecords(int64 version_id, |
- std::vector<ResourceRecord>* resources); |
- bool DeleteResourceRecords(int64 version_id, |
- leveldb::WriteBatch* batch); |
+ // Reads registration data for |registration_id| from the database. Returns OK |
+ // if successfully reads. Otherwise, returns an error. |
+ ServiceWorkerStatusCode ReadRegistrationData( |
+ int64 registration_id, |
+ const GURL& origin, |
+ RegistrationData* registration); |
+ |
+ // Reads resource records for |version_id| from the database. Returns OK if |
+ // it's successfully read or not found in the database. Otherwise, returns an |
+ // error. |
+ ServiceWorkerStatusCode ReadResourceRecords( |
+ int64 version_id, |
+ std::vector<ResourceRecord>* resources); |
+ |
+ // Deletes resource records for |version_id| from the database. Returns OK if |
+ // they are successfully deleted or not found in the database. Otherwise, |
+ // returns an error. |
+ ServiceWorkerStatusCode DeleteResourceRecords( |
+ int64 version_id, |
+ leveldb::WriteBatch* batch); |
+ |
bool ReadResourceIds(const char* id_key_prefix, |
std::set<int64>* ids); |
bool WriteResourceIds(const char* id_key_prefix, |
@@ -182,10 +222,10 @@ class CONTENT_EXPORT ServiceWorkerDatabase { |
// been written anything yet, sets |db_version| to 0 and returns OK. |
ServiceWorkerStatusCode ReadDatabaseVersion(int64* db_version); |
- // Write a batch into the database. |
+ // Writes a batch into the database. |
// NOTE: You must call this when you want to put something into the database |
// because this initializes the database if needed. |
- bool WriteBatch(leveldb::WriteBatch* batch); |
+ ServiceWorkerStatusCode WriteBatch(leveldb::WriteBatch* batch); |
// Bumps the next available id if |used_id| is greater than or equal to the |
// cached one. |