| 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 57654ca2ebe24d2f5ed1568231f8336483245e59..5f3f0339d42733f20c2fc98eb3f1c4421ae7c8f0 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.
|
| + Status 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.
|
| + Status 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.
|
| + Status 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.
|
| + Status 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.
|
| + Status 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
|
| @@ -119,33 +143,35 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
|
| // the purgeable list can be purged from the diskcache. At system startup, all
|
| // uncommitted ids are moved to the purgeable list.
|
|
|
| - // Reads uncommitted resource ids from the database. Returns true on success.
|
| - // Otherwise clears |ids| and returns false.
|
| - bool GetUncommittedResourceIds(std::set<int64>* ids);
|
| + // Reads uncommitted resource ids from the database. Returns OK on success.
|
| + // Otherwise clears |ids| and returns an error.
|
| + Status GetUncommittedResourceIds(std::set<int64>* ids);
|
|
|
| - // Writes |ids| into the database as uncommitted resources. Returns true on
|
| - // success. Otherwise writes nothing and returns false.
|
| - bool WriteUncommittedResourceIds(const std::set<int64>& ids);
|
| + // Writes |ids| into the database as uncommitted resources. Returns OK on
|
| + // success. Otherwise writes nothing and returns an error.
|
| + Status WriteUncommittedResourceIds(const std::set<int64>& ids);
|
|
|
| // Deletes uncommitted resource ids specified by |ids| from the database.
|
| - // Returns true on success. Otherwise deletes nothing and returns false.
|
| - bool ClearUncommittedResourceIds(const std::set<int64>& ids);
|
| + // Returns OK on success. Otherwise deletes nothing and returns an error.
|
| + Status ClearUncommittedResourceIds(const std::set<int64>& ids);
|
|
|
| - // Reads purgeable resource ids from the database. Returns true on success.
|
| - // Otherwise clears |ids| and returns false.
|
| - bool GetPurgeableResourceIds(std::set<int64>* ids);
|
| + // Reads purgeable resource ids from the database. Returns OK on success.
|
| + // Otherwise clears |ids| and returns an error.
|
| + Status GetPurgeableResourceIds(std::set<int64>* ids);
|
|
|
| - // Writes |ids| into the database as purgeable resources. Returns true on
|
| - // success. Otherwise writes nothing and returns false.
|
| - bool WritePurgeableResourceIds(const std::set<int64>& ids);
|
| + // Writes |ids| into the database as purgeable resources. Returns OK on
|
| + // success. Otherwise writes nothing and returns an error.
|
| + Status WritePurgeableResourceIds(const std::set<int64>& ids);
|
|
|
| // Deletes purgeable resource ids specified by |ids| from the database.
|
| - // Returns true on success. Otherwise deletes nothing and returns false.
|
| - bool ClearPurgeableResourceIds(const std::set<int64>& ids);
|
| + // Returns OK on success. Otherwise deletes nothing and returns an error.
|
| + Status 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.
|
| + Status DeleteAllDataForOrigin(const GURL& origin);
|
|
|
| bool is_disabled() const { return is_disabled_; }
|
| bool was_corruption_detected() const { return was_corruption_detected_; }
|
| @@ -169,40 +195,70 @@ 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);
|
| - bool ReadResourceIds(const char* id_key_prefix,
|
| - std::set<int64>* ids);
|
| - bool WriteResourceIds(const char* id_key_prefix,
|
| - const std::set<int64>& ids);
|
| - bool DeleteResourceIds(const char* id_key_prefix,
|
| - const std::set<int64>& ids);
|
| + // Reads registration data for |registration_id| from the database. Returns OK
|
| + // if successfully reads. Otherwise, returns an error.
|
| + Status 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.
|
| + Status 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.
|
| + Status DeleteResourceRecords(
|
| + int64 version_id,
|
| + leveldb::WriteBatch* batch);
|
| +
|
| + // Reads resource ids for |id_key_prefix| from the database. Returns OK if
|
| + // it's successfully read or not found in the database. Otherwise, returns an
|
| + // error.
|
| + Status ReadResourceIds(
|
| + const char* id_key_prefix,
|
| + std::set<int64>* ids);
|
| +
|
| + // Write resource ids for |id_key_prefix| into the database. Returns OK on
|
| + // success. Otherwise, returns writes nothing and returns an error.
|
| + Status WriteResourceIds(
|
| + const char* id_key_prefix,
|
| + const std::set<int64>& ids);
|
| +
|
| + // Deletes resource ids for |id_key_prefix| from the database. Returns OK if
|
| + // it's successfully deleted or not found in the database. Otherwise, returns
|
| + // an error.
|
| + Status DeleteResourceIds(
|
| + const char* id_key_prefix,
|
| + const std::set<int64>& ids);
|
|
|
| // Reads the current schema version from the database. If the database hasn't
|
| // been written anything yet, sets |db_version| to 0 and returns OK.
|
| Status 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);
|
| + Status WriteBatch(leveldb::WriteBatch* batch);
|
|
|
| // Bumps the next available id if |used_id| is greater than or equal to the
|
| // cached one.
|
| - void BumpNextRegistrationIdIfNeeded(int64 used_id,
|
| - leveldb::WriteBatch* batch);
|
| - void BumpNextVersionIdIfNeeded(int64 used_id,
|
| - leveldb::WriteBatch* batch);
|
| + void BumpNextRegistrationIdIfNeeded(
|
| + int64 used_id,
|
| + leveldb::WriteBatch* batch);
|
| + void BumpNextVersionIdIfNeeded(
|
| + int64 used_id,
|
| + leveldb::WriteBatch* batch);
|
|
|
| bool IsOpen();
|
|
|
| - void HandleError(const tracked_objects::Location& from_here,
|
| - const leveldb::Status& status);
|
| + void HandleError(
|
| + const tracked_objects::Location& from_here,
|
| + const leveldb::Status& status);
|
|
|
| base::FilePath path_;
|
| scoped_ptr<leveldb::Env> env_;
|
|
|