| 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 "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState) | 72 ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState) |
| 73 { | 73 { |
| 74 ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(ge
tExecutionContext()); | 74 ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(ge
tExecutionContext()); |
| 75 if (!client || !client->provider()) | 75 if (!client || !client->provider()) |
| 76 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Failed to update a ServiceWorkerRegistration: No asso
ciated provider is available.")); | 76 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Failed to update a ServiceWorkerRegistration: No asso
ciated provider is available.")); |
| 77 | 77 |
| 78 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 78 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 79 ScriptPromise promise = resolver->promise(); | 79 ScriptPromise promise = resolver->promise(); |
| 80 m_handle->registration()->update(client->provider(), new CallbackPromiseAdap
ter<void, ServiceWorkerError>(resolver)); | 80 m_handle->registration()->update(client->provider(), new CallbackPromiseAdap
ter<void, ServiceWorkerErrorForUpdate>(resolver)); |
| 81 return promise; | 81 return promise; |
| 82 } | 82 } |
| 83 | 83 |
| 84 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) | 84 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) |
| 85 { | 85 { |
| 86 ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(ge
tExecutionContext()); | 86 ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(ge
tExecutionContext()); |
| 87 if (!client || !client->provider()) | 87 if (!client || !client->provider()) |
| 88 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Failed to unregister a ServiceWorkerRegistration: No
associated provider is available.")); | 88 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Failed to unregister a ServiceWorkerRegistration: No
associated provider is available.")); |
| 89 | 89 |
| 90 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 90 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 void ServiceWorkerRegistration::stop() | 137 void ServiceWorkerRegistration::stop() |
| 138 { | 138 { |
| 139 if (m_stopped) | 139 if (m_stopped) |
| 140 return; | 140 return; |
| 141 m_stopped = true; | 141 m_stopped = true; |
| 142 m_handle->registration()->proxyStopped(); | 142 m_handle->registration()->proxyStopped(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |