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

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

Issue 355163003: Don't prematurely delete script resources when registration is deleted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: really fix win build Created 6 years, 5 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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int64 registration_id, 110 int64 registration_id,
111 const GURL& origin, 111 const GURL& origin,
112 RegistrationData* registration, 112 RegistrationData* registration,
113 std::vector<ResourceRecord>* resources); 113 std::vector<ResourceRecord>* resources);
114 114
115 // Writes |registration| and |resources| into the database and does following 115 // Writes |registration| and |resources| into the database and does following
116 // things: 116 // things:
117 // - Deletes an old version of the registration if exists. 117 // - Deletes an old version of the registration if exists.
118 // - Bumps the next registration id and the next version id if needed. 118 // - Bumps the next registration id and the next version id if needed.
119 // - Removes |resources| from the uncommitted list if exist. 119 // - Removes |resources| from the uncommitted list if exist.
120 // Returns OK they are successfully written. Otherwise, returns an error. 120 // Returns OK they are successfully written. Otherwise, returns an error.
michaeln 2014/07/01 20:54:06 also describe the output params here
falken 2014/07/02 04:04:24 Done.
121 Status WriteRegistration( 121 Status WriteRegistration(const RegistrationData& registration,
122 const RegistrationData& registration, 122 const std::vector<ResourceRecord>& resources,
123 const std::vector<ResourceRecord>& resources, 123 int64* deleted_version_id,
124 std::vector<int64>* newly_purgeable_resources); 124 std::vector<int64>* newly_purgeable_resources);
125 125
126 // Updates a registration for |registration_id| to an active state. Returns OK 126 // Updates a registration for |registration_id| to an active state. Returns OK
127 // if it's successfully updated. Otherwise, returns an error. 127 // if it's successfully updated. Otherwise, returns an error.
128 Status UpdateVersionToActive( 128 Status UpdateVersionToActive(
129 int64 registration_id, 129 int64 registration_id,
130 const GURL& origin); 130 const GURL& origin);
131 131
132 // Updates last check time of a registration for |registration_id| by |time|. 132 // Updates last check time of a registration for |registration_id| by |time|.
133 // Returns OK if it's successfully updated. Otherwise, returns an error. 133 // Returns OK if it's successfully updated. Otherwise, returns an error.
134 Status UpdateLastCheckTime( 134 Status UpdateLastCheckTime(
135 int64 registration_id, 135 int64 registration_id,
136 const GURL& origin, 136 const GURL& origin,
137 const base::Time& time); 137 const base::Time& time);
138 138
139 // Deletes a registration for |registration_id| and moves resource records 139 // Deletes a registration for |registration_id| and moves resource records
140 // associated with it into the purgeable list. Returns OK if it's successfully 140 // associated with it into the purgeable list. Sets |version_id| to the
141 // deleted or not found in the database. Otherwise, returns an error. 141 // id of the version that was stored and |newly_purgeable_resources| to its
michaeln 2014/07/01 20:54:06 'version that was deleted'
falken 2014/07/02 04:04:24 Done.
142 Status DeleteRegistration( 142 // resources. Returns OK if it's successfully deleted or not found in the
143 int64 registration_id, 143 // database. Otherwise, returns an error.
144 const GURL& origin, 144 Status DeleteRegistration(int64 registration_id,
145 std::vector<int64>* newly_purgeable_resources); 145 const GURL& origin,
146 int64* version_id,
147 std::vector<int64>* newly_purgeable_resources);
146 148
147 // As new resources are put into the diskcache, they go into an uncommitted 149 // As new resources are put into the diskcache, they go into an uncommitted
148 // list. When a registration is saved that refers to those ids, they're 150 // list. When a registration is saved that refers to those ids, they're
149 // removed from that list. When a resource no longer has any registrations or 151 // removed from that list. When a resource no longer has any registrations or
150 // caches referring to it, it's added to the purgeable list. Periodically, 152 // caches referring to it, it's added to the purgeable list. Periodically,
151 // the purgeable list can be purged from the diskcache. At system startup, all 153 // the purgeable list can be purged from the diskcache. At system startup, all
152 // uncommitted ids are moved to the purgeable list. 154 // uncommitted ids are moved to the purgeable list.
153 155
154 // Reads uncommitted resource ids from the database. Returns OK on success. 156 // Reads uncommitted resource ids from the database. Returns OK on success.
155 // Otherwise clears |ids| and returns an error. 157 // Otherwise clears |ids| and returns an error.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); 317 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion);
316 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); 318 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
317 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); 319 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase);
318 320
319 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 321 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
320 }; 322 };
321 323
322 } // namespace content 324 } // namespace content
323 325
324 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 326 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698