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

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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: fix IPC Created 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_database.cc
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc
index 93480c4bc580532577ab94bd083126aa1734da00..178c8be124b8beb9462d4251457785a7ed3c5d22 100644
--- a/content/browser/service_worker/service_worker_database.cc
+++ b/content/browser/service_worker/service_worker_database.cc
@@ -276,11 +276,11 @@ const char* ServiceWorkerDatabase::StatusToString(
ServiceWorkerDatabase::RegistrationData::RegistrationData()
: registration_id(kInvalidServiceWorkerRegistrationId),
+ update_via_cache(blink::WebServiceWorkerUpdateViaCache::kImports),
version_id(kInvalidServiceWorkerVersionId),
is_active(false),
has_fetch_handler(false),
- resources_total_size_bytes(0) {
-}
+ resources_total_size_bytes(0) {}
ServiceWorkerDatabase::RegistrationData::RegistrationData(
const RegistrationData& other) = default;
@@ -1399,6 +1399,17 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ParseRegistrationData(
for (uint32_t feature : data.used_features())
out->used_features.insert(feature);
+ if (data.has_update_via_cache()) {
+ auto value = data.update_via_cache();
+ if (!ServiceWorkerRegistrationData_ServiceWorkerUpdateViaCacheType_IsValid(
+ value)) {
+ DLOG(ERROR) << "Update via cache mode '" << value << "' is not valid.";
+ return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
+ }
+ out->update_via_cache =
+ static_cast<blink::WebServiceWorkerUpdateViaCache>(value);
+ }
+
return ServiceWorkerDatabase::STATUS_OK;
}
@@ -1448,6 +1459,11 @@ void ServiceWorkerDatabase::WriteRegistrationDataInBatch(
for (uint32_t feature : registration.used_features)
data.add_used_features(feature);
+ data.set_update_via_cache(
+ static_cast<
+ ServiceWorkerRegistrationData_ServiceWorkerUpdateViaCacheType>(
+ registration.update_via_cache));
+
std::string value;
bool success = data.SerializeToString(&value);
DCHECK(success);
« no previous file with comments | « content/browser/service_worker/service_worker_database.h ('k') | content/browser/service_worker/service_worker_database.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698