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

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

Issue 254733002: ServiceWorker: Manipulate uncommitted/purgeable resource ids (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
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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const std::vector<ResourceRecord>& resources); 89 const std::vector<ResourceRecord>& resources);
90 90
91 bool UpdateVersionToActive(int64 registration_id, 91 bool UpdateVersionToActive(int64 registration_id,
92 const GURL& origin); 92 const GURL& origin);
93 bool UpdateLastCheckTime(int64 registration_id, 93 bool UpdateLastCheckTime(int64 registration_id,
94 const GURL& origin, 94 const GURL& origin,
95 const base::Time& time); 95 const base::Time& time);
96 bool DeleteRegistration(int64 registration_id, 96 bool DeleteRegistration(int64 registration_id,
97 const GURL& origin); 97 const GURL& origin);
98 98
99 // As new resources are put into the diskcache, they go into an uncommitted
100 // list. When a registration is saved that refers to those ids, they're
101 // removed from that list. When a resource no longer has any registrations or
102 // caches referring to it, it's added to the unclaimed list. Periodically,
michaeln 2014/04/29 23:50:03 the language in the comment is a little stale, 'un
nhiroki 2014/04/30 03:05:58 Done.
103 // the unclaimed list can be purged from the diskcache. At system startup, all
104 // uncommitted ids are moved to the purgeable list.
105
106 // Reads uncommitted resource ids from the database. Returns true on success.
107 // Otherwise clears |ids| and returns false.
108 bool GetUncommittedResourceIds(std::set<int64>* ids);
michaeln 2014/04/29 23:50:03 As a consumer of this api, i was thinking a std::v
nhiroki 2014/04/30 03:05:58 This is just implementation issue. LevelDB seems n
michaeln 2014/04/30 03:23:57 Which result in the last one value added to the ba
nhiroki 2014/04/30 04:04:06 Yes, records having the same key are operated in F
109
110 // Writes |ids| into the database as uncommitted resources. Returns true on
111 // success. Otherwise writes nothing and returns false.
112 bool WriteUncommittedResourceIds(const std::set<int64>& ids);
113
114 // Deletes uncommitted resource ids specified by |ids| from the database.
115 // Returns true on success. Otherwise deletes nothing and returns false.
116 bool ClearUncommittedResourceIds(const std::set<int64>& ids);
117
118 // Reads purgeable resource ids from the database. Returns true on success.
119 // Otherwise clears |ids| and returns false.
120 bool GetPurgeableResourceIds(std::set<int64>* ids);
121
122 // Writes |ids| into the database as purgeable resources. Returns true on
123 // success. Otherwise writes nothing and returns false.
124 bool WritePurgeableResourceIds(const std::set<int64>& ids);
125
126 // Deletes purgeable resource ids specified by |ids| from the database.
127 // Returns true on success. Otherwise deletes nothing and returns false.
128 bool ClearPurgeableResourceIds(const std::set<int64>& ids);
129
99 bool is_disabled() const { return is_disabled_; } 130 bool is_disabled() const { return is_disabled_; }
100 bool was_corruption_detected() const { return was_corruption_detected_; } 131 bool was_corruption_detected() const { return was_corruption_detected_; }
101 132
102 private: 133 private:
103 // Opens the database at the |path_|. This is lazily called when the first 134 // Opens the database at the |path_|. This is lazily called when the first
104 // database API is called. Returns true if the database was opened. Returns 135 // database API is called. Returns true if the database was opened. Returns
105 // false if the opening failed or was not neccessary, that is, the database 136 // false if the opening failed or was not neccessary, that is, the database
106 // does not exist and |create_if_needed| is false. 137 // does not exist and |create_if_needed| is false.
107 bool LazyOpen(bool create_if_needed); 138 bool LazyOpen(bool create_if_needed);
108 139
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase); 185 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase);
155 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory); 186 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, OpenDatabase_InMemory);
156 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); 187 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
157 188
158 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 189 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
159 }; 190 };
160 191
161 } // namespace content 192 } // namespace content
162 193
163 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 194 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698