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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

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: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index f939ee94ae507ebdaafc64006a602c64aa8c53ef..64290e507b0c7ea88f9eb8bb07f3490f58856050 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -66,6 +66,21 @@
namespace blink {
+namespace {
+
+WebServiceWorkerUpdateViaCache ParseUpdateViaCache(const String& value) {
+ if (value == "imports")
+ return WebServiceWorkerUpdateViaCache::kImports;
+ if (value == "all")
+ return WebServiceWorkerUpdateViaCache::kAll;
+ if (value == "none")
+ return WebServiceWorkerUpdateViaCache::kNone;
+ // Default value
+ return WebServiceWorkerUpdateViaCache::kImports;
+}
+
+} // namespace
+
class GetRegistrationCallback : public WebServiceWorkerProvider::
WebServiceWorkerGetRegistrationCallbacks {
public:
@@ -156,6 +171,7 @@ void ServiceWorkerContainer::RegisterServiceWorkerImpl(
ExecutionContext* execution_context,
const KURL& raw_script_url,
const KURL& scope,
+ WebServiceWorkerUpdateViaCache update_via_cache,
std::unique_ptr<RegistrationCallbacks> callbacks) {
if (!provider_) {
callbacks->OnError(
@@ -261,7 +277,7 @@ void ServiceWorkerContainer::RegisterServiceWorkerImpl(
}
}
- provider_->RegisterServiceWorker(pattern_url, script_url,
+ provider_->RegisterServiceWorker(pattern_url, script_url, update_via_cache,
std::move(callbacks));
}
@@ -294,8 +310,11 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(
else
pattern_url = execution_context->CompleteURL(options.scope());
+ WebServiceWorkerUpdateViaCache update_via_cache =
+ ParseUpdateViaCache(options.updateViaCache());
+
RegisterServiceWorkerImpl(
- execution_context, script_url, pattern_url,
+ execution_context, script_url, pattern_url, update_via_cache,
WTF::MakeUnique<CallbackPromiseAdapter<ServiceWorkerRegistration,
ServiceWorkerErrorForUpdate>>(
resolver));

Powered by Google App Engine
This is Rietveld 408576698