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

Unified Diff: content/browser/service_worker/service_worker_database.h

Issue 287843002: ServiceWorker: DB functions should return status code instead of boolean (2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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 7fdd0a91a66223445e92698add8c7210ed38395c..6e368da65f7f0a6a7607153ad886a4a6df05e49b 100644
--- a/content/browser/service_worker/service_worker_database.h
+++ b/content/browser/service_worker/service_worker_database.h
@@ -67,19 +67,30 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
GURL url;
};
- // For use during initialization.
+ // Reads next available ids from the database. Returns OK if they are
+ // successfully read. Fills the arguments with an initial value and returns
+ // OK if they are not found in the database. Otherwise, returns an error.
ServiceWorkerStatusCode GetNextAvailableIds(
int64* next_avail_registration_id,
int64* next_avail_version_id,
int64* next_avail_resource_id);
+
+ // Reads origins that have one or more than one registration from the
+ // database. Returns OK if they are successfully read or not found.
+ // Otherwise, returns an error.
ServiceWorkerStatusCode GetOriginsWithRegistrations(
std::set<GURL>* origins);
- // For use when first handling a request in an origin with registrations.
- bool GetRegistrationsForOrigin(const GURL& origin,
- std::vector<RegistrationData>* registrations);
+ // Reads registrations for |origin| from the database. Returns OK if they are
+ // successfully read or not found. Otherwise, returns an error.
+ ServiceWorkerStatusCode GetRegistrationsForOrigin(
+ const GURL& origin,
+ std::vector<RegistrationData>* registrations);
- bool GetAllRegistrations(std::vector<RegistrationData>* registrations);
+ // Reads all registrations from the database. Returns OK if successfully read
+ // or not found. Otherwise, returns an error.
+ ServiceWorkerStatusCode GetAllRegistrations(
+ std::vector<RegistrationData>* registrations);
// Saving, retrieving, and updating registration data.
// (will bump next_avail_xxxx_ids as needed)
@@ -141,14 +152,18 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
private:
// Opens the database at the |path_|. This is lazily called when the first
- // database API is called. Returns true if the database was opened. Returns
- // false if the opening failed or was not neccessary, that is, the database
- // does not exist and |create_if_needed| is false.
- bool LazyOpen(bool create_if_needed);
-
+ // database API is called. Returns OK if the database is successfully opened.
+ // Returns NOT_FOUND if the database does not exist and |create_if_missing| is
+ // false. Otherwise, returns an error.
+ ServiceWorkerStatusCode LazyOpen(bool create_if_missing);
+
+ // Reads the next available id for |id_key|. Returns OK if it's successfully
+ // read. Fills |next_avail_id| with an initial value and returns OK if it's
+ // not found in the database. Otherwise, returns an error.
ServiceWorkerStatusCode ReadNextAvailableId(
const char* id_key,
int64* next_avail_id);
+
bool ReadRegistrationData(int64 registration_id,
const GURL& origin,
RegistrationData* registration);
@@ -164,8 +179,8 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
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 true.
- bool ReadDatabaseVersion(int64* db_version);
+ // been written anything yet, sets |db_version| to 0 and returns OK.
+ ServiceWorkerStatusCode ReadDatabaseVersion(int64* db_version);
// Write a batch into the database.
// NOTE: You must call this when you want to put something into the database
@@ -209,9 +224,6 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
- FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Basic);
- FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Overwrite);
- FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Multiple);
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
};

Powered by Google App Engine
This is Rietveld 408576698