| OLD | NEW |
| 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 Loading... |
| 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 "none"; |
| 99 case WebServiceWorkerUpdateViaCache::kUnknown: |
| 100 break; |
| 101 } |
| 102 NOTREACHED(); |
| 103 return "imports"; |
| 104 } |
| 105 |
| 91 ScriptPromise ServiceWorkerRegistration::update(ScriptState* script_state) { | 106 ScriptPromise ServiceWorkerRegistration::update(ScriptState* script_state) { |
| 92 ServiceWorkerContainerClient* client = | 107 ServiceWorkerContainerClient* client = |
| 93 ServiceWorkerContainerClient::From(GetExecutionContext()); | 108 ServiceWorkerContainerClient::From(GetExecutionContext()); |
| 94 if (!client || !client->Provider()) | 109 if (!client || !client->Provider()) |
| 95 return ScriptPromise::RejectWithDOMException( | 110 return ScriptPromise::RejectWithDOMException( |
| 96 script_state, | 111 script_state, |
| 97 DOMException::Create(kInvalidStateError, | 112 DOMException::Create(kInvalidStateError, |
| 98 "Failed to update a ServiceWorkerRegistration: No " | 113 "Failed to update a ServiceWorkerRegistration: No " |
| 99 "associated provider is available.")); | 114 "associated provider is available.")); |
| 100 | 115 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 175 } |
| 161 | 176 |
| 162 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) { | 177 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) { |
| 163 if (stopped_) | 178 if (stopped_) |
| 164 return; | 179 return; |
| 165 stopped_ = true; | 180 stopped_ = true; |
| 166 handle_->Registration()->ProxyStopped(); | 181 handle_->Registration()->ProxyStopped(); |
| 167 } | 182 } |
| 168 | 183 |
| 169 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |