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

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

Issue 275103004: ServiceWorker: Database functions should return status code instead of boolean (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 10 #include <vector>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 RegistrationData(); 61 RegistrationData();
62 ~RegistrationData(); 62 ~RegistrationData();
63 }; 63 };
64 64
65 struct ResourceRecord { 65 struct ResourceRecord {
66 int64 resource_id; 66 int64 resource_id;
67 GURL url; 67 GURL url;
68 }; 68 };
69 69
70 // For use during initialization. 70 // For use during initialization.
71 bool GetNextAvailableIds(int64* next_avail_registration_id, 71 ServiceWorkerStatusCode GetNextAvailableIds(
72 int64* next_avail_version_id, 72 int64* next_avail_registration_id,
73 int64* next_avail_resource_id); 73 int64* next_avail_version_id,
74 bool GetOriginsWithRegistrations(std::set<GURL>* origins); 74 int64* next_avail_resource_id);
75 ServiceWorkerStatusCode GetOriginsWithRegistrations(
76 std::set<GURL>* origins);
75 77
76 // For use when first handling a request in an origin with registrations. 78 // For use when first handling a request in an origin with registrations.
77 bool GetRegistrationsForOrigin(const GURL& origin, 79 bool GetRegistrationsForOrigin(const GURL& origin,
78 std::vector<RegistrationData>* registrations); 80 std::vector<RegistrationData>* registrations);
79 81
80 bool GetAllRegistrations(std::vector<RegistrationData>* registrations); 82 bool GetAllRegistrations(std::vector<RegistrationData>* registrations);
81 83
82 // Saving, retrieving, and updating registration data. 84 // Saving, retrieving, and updating registration data.
83 // (will bump next_avail_xxxx_ids as needed) 85 // (will bump next_avail_xxxx_ids as needed)
84 // (resource ids will be added/removed from the uncommitted/purgeable 86 // (resource ids will be added/removed from the uncommitted/purgeable
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 bool is_disabled() const { return is_disabled_; } 139 bool is_disabled() const { return is_disabled_; }
138 bool was_corruption_detected() const { return was_corruption_detected_; } 140 bool was_corruption_detected() const { return was_corruption_detected_; }
139 141
140 private: 142 private:
141 // Opens the database at the |path_|. This is lazily called when the first 143 // Opens the database at the |path_|. This is lazily called when the first
142 // database API is called. Returns true if the database was opened. Returns 144 // database API is called. Returns true if the database was opened. Returns
143 // false if the opening failed or was not neccessary, that is, the database 145 // false if the opening failed or was not neccessary, that is, the database
144 // does not exist and |create_if_needed| is false. 146 // does not exist and |create_if_needed| is false.
145 bool LazyOpen(bool create_if_needed); 147 bool LazyOpen(bool create_if_needed);
146 148
147 bool ReadNextAvailableId(const char* id_key, 149 ServiceWorkerStatusCode ReadNextAvailableId(
148 int64* next_avail_id); 150 const char* id_key,
151 int64* next_avail_id);
149 bool ReadRegistrationData(int64 registration_id, 152 bool ReadRegistrationData(int64 registration_id,
150 const GURL& origin, 153 const GURL& origin,
151 RegistrationData* registration); 154 RegistrationData* registration);
152 bool ReadResourceRecords(int64 version_id, 155 bool ReadResourceRecords(int64 version_id,
153 std::vector<ResourceRecord>* resources); 156 std::vector<ResourceRecord>* resources);
154 bool DeleteResourceRecords(int64 version_id, 157 bool DeleteResourceRecords(int64 version_id,
155 leveldb::WriteBatch* batch); 158 leveldb::WriteBatch* batch);
156 bool ReadResourceIds(const char* id_key_prefix, 159 bool ReadResourceIds(const char* id_key_prefix,
157 std::set<int64>* ids); 160 std::set<int64>* ids);
158 bool WriteResourceIds(const char* id_key_prefix, 161 bool WriteResourceIds(const char* id_key_prefix,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Basic); 212 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Basic);
210 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Overwrite); 213 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Overwrite);
211 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Multiple); 214 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, Registration_Multiple);
212 215
213 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 216 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
214 }; 217 };
215 218
216 } // namespace content 219 } // namespace content
217 220
218 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 221 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698