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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: Move API change to another patch and address comments Created 3 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
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 "modules/serviceworkers/ServiceWorkerRegistration.h" 5 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include "bindings/core/v8/CallbackPromiseAdapter.h" 9 #include "bindings/core/v8/CallbackPromiseAdapter.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 NavigationPreloadManager* ServiceWorkerRegistration::navigationPreload() { 81 NavigationPreloadManager* ServiceWorkerRegistration::navigationPreload() {
82 if (!navigation_preload_) 82 if (!navigation_preload_)
83 navigation_preload_ = NavigationPreloadManager::Create(this); 83 navigation_preload_ = NavigationPreloadManager::Create(this);
84 return navigation_preload_; 84 return navigation_preload_;
85 } 85 }
86 86
87 String ServiceWorkerRegistration::scope() const { 87 String ServiceWorkerRegistration::scope() const {
88 return handle_->Registration()->Scope().GetString(); 88 return handle_->Registration()->Scope().GetString();
89 } 89 }
90 90
91 String ServiceWorkerRegistration::updateViaCache() const {
92 switch (handle_->Registration()->UpdateViaCache()) {
93 case WebServiceWorkerUpdateViaCache::kImports:
94 return "imports";
95 case WebServiceWorkerUpdateViaCache::kAll:
96 return "all";
97 case WebServiceWorkerUpdateViaCache::kNone:
98 return "never";
nhiroki 2017/07/21 04:39:46 "never" -> "none"?
yuryu 2017/08/03 04:20:05 Done.
99 default:
nhiroki 2017/07/21 04:39:46 I'd prefer to avoid 'default' as much as possible
yuryu 2017/08/03 04:20:05 Done.
100 return "imports";
101 }
102 return "imports";
103 }
104
91 ScriptPromise ServiceWorkerRegistration::update(ScriptState* script_state) { 105 ScriptPromise ServiceWorkerRegistration::update(ScriptState* script_state) {
92 ServiceWorkerContainerClient* client = 106 ServiceWorkerContainerClient* client =
93 ServiceWorkerContainerClient::From(GetExecutionContext()); 107 ServiceWorkerContainerClient::From(GetExecutionContext());
94 if (!client || !client->Provider()) 108 if (!client || !client->Provider())
95 return ScriptPromise::RejectWithDOMException( 109 return ScriptPromise::RejectWithDOMException(
96 script_state, 110 script_state,
97 DOMException::Create(kInvalidStateError, 111 DOMException::Create(kInvalidStateError,
98 "Failed to update a ServiceWorkerRegistration: No " 112 "Failed to update a ServiceWorkerRegistration: No "
99 "associated provider is available.")); 113 "associated provider is available."));
100 114
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 174 }
161 175
162 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) { 176 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) {
163 if (stopped_) 177 if (stopped_)
164 return; 178 return;
165 stopped_ = true; 179 stopped_ = true;
166 handle_->Registration()->ProxyStopped(); 180 handle_->Registration()->ProxyStopped();
167 } 181 }
168 182
169 } // namespace blink 183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698