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

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

Issue 1283273002: Service Worker: Change last update check location and HTTP cache bypass rule (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. Created 5 years, 4 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
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 #include "content/browser/service_worker/service_worker_database.h" 5 #include "content/browser/service_worker/service_worker_database.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Convert RegistrationData to ServiceWorkerRegistrationData. 199 // Convert RegistrationData to ServiceWorkerRegistrationData.
200 ServiceWorkerRegistrationData data; 200 ServiceWorkerRegistrationData data;
201 data.set_registration_id(input.registration_id); 201 data.set_registration_id(input.registration_id);
202 data.set_scope_url(input.scope.spec()); 202 data.set_scope_url(input.scope.spec());
203 data.set_script_url(input.script.spec()); 203 data.set_script_url(input.script.spec());
204 data.set_version_id(input.version_id); 204 data.set_version_id(input.version_id);
205 data.set_is_active(input.is_active); 205 data.set_is_active(input.is_active);
206 data.set_has_fetch_handler(input.has_fetch_handler); 206 data.set_has_fetch_handler(input.has_fetch_handler);
207 data.set_last_update_check_time(input.last_update_check.ToInternalValue()); 207 data.set_last_update_check_time(input.last_update_check.ToInternalValue());
208 data.set_resources_total_size_bytes(input.resources_total_size_bytes); 208 data.set_resources_total_size_bytes(input.resources_total_size_bytes);
209 data.set_max_age(input.max_age.ToInternalValue());
209 210
210 std::string value; 211 std::string value;
211 bool success = data.SerializeToString(&value); 212 bool success = data.SerializeToString(&value);
212 DCHECK(success); 213 DCHECK(success);
213 GURL origin = input.scope.GetOrigin(); 214 GURL origin = input.scope.GetOrigin();
214 batch->Put(CreateRegistrationKey(data.registration_id(), origin), value); 215 batch->Put(CreateRegistrationKey(data.registration_id(), origin), value);
215 } 216 }
216 217
217 void PutResourceRecordToBatch( 218 void PutResourceRecordToBatch(
218 const ServiceWorkerDatabase::ResourceRecord& input, 219 const ServiceWorkerDatabase::ResourceRecord& input,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Convert ServiceWorkerRegistrationData to RegistrationData. 299 // Convert ServiceWorkerRegistrationData to RegistrationData.
299 out->registration_id = data.registration_id(); 300 out->registration_id = data.registration_id();
300 out->scope = scope_url; 301 out->scope = scope_url;
301 out->script = script_url; 302 out->script = script_url;
302 out->version_id = data.version_id(); 303 out->version_id = data.version_id();
303 out->is_active = data.is_active(); 304 out->is_active = data.is_active();
304 out->has_fetch_handler = data.has_fetch_handler(); 305 out->has_fetch_handler = data.has_fetch_handler();
305 out->last_update_check = 306 out->last_update_check =
306 base::Time::FromInternalValue(data.last_update_check_time()); 307 base::Time::FromInternalValue(data.last_update_check_time());
307 out->resources_total_size_bytes = data.resources_total_size_bytes(); 308 out->resources_total_size_bytes = data.resources_total_size_bytes();
309 out->max_age = base::TimeDelta::FromInternalValue(data.max_age());
308 310
309 return ServiceWorkerDatabase::STATUS_OK; 311 return ServiceWorkerDatabase::STATUS_OK;
310 } 312 }
311 313
312 ServiceWorkerDatabase::Status ParseResourceRecord( 314 ServiceWorkerDatabase::Status ParseResourceRecord(
313 const std::string& serialized, 315 const std::string& serialized,
314 ServiceWorkerDatabase::ResourceRecord* out) { 316 ServiceWorkerDatabase::ResourceRecord* out) {
315 DCHECK(out); 317 DCHECK(out);
316 ServiceWorkerResourceRecord record; 318 ServiceWorkerResourceRecord record;
317 if (!record.ParseFromString(serialized)) 319 if (!record.ParseFromString(serialized))
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 if (status != STATUS_OK) 1601 if (status != STATUS_OK)
1600 Disable(from_here, status); 1602 Disable(from_here, status);
1601 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1603 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1602 } 1604 }
1603 1605
1604 bool ServiceWorkerDatabase::IsDatabaseInMemory() const { 1606 bool ServiceWorkerDatabase::IsDatabaseInMemory() const {
1605 return path_.empty(); 1607 return path_.empty();
1606 } 1608 }
1607 1609
1608 } // namespace content 1610 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698