| 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 "config.h" | 5 #include "config.h" |
| 6 #include "ServiceWorkerRegistration.h" | 6 #include "ServiceWorkerRegistration.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 { | 90 { |
| 91 if (!m_provider) { | 91 if (!m_provider) { |
| 92 exceptionState.throwDOMException(InvalidStateError, "Failed to update a
ServiceWorkerRegistration: No associated provider is available."); | 92 exceptionState.throwDOMException(InvalidStateError, "Failed to update a
ServiceWorkerRegistration: No associated provider is available."); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 m_outerRegistration->update(m_provider); | 95 m_outerRegistration->update(m_provider); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) | 98 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) |
| 99 { | 99 { |
| 100 |
| 100 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 101 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 101 ScriptPromise promise = resolver->promise(); | 102 ScriptPromise promise = resolver->promise(); |
| 102 | 103 |
| 103 if (!m_provider) { | 104 if (!m_provider) { |
| 104 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre
gister a ServiceWorkerRegistration: No associated provider is available.")); | 105 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre
gister a ServiceWorkerRegistration: No associated provider is available.")); |
| 105 return promise; | 106 return promise; |
| 106 } | 107 } |
| 107 | 108 |
| 108 m_outerRegistration->unregister(m_provider, new CallbackPromiseAdapter<bool,
ServiceWorkerError>(resolver)); | 109 m_outerRegistration->unregister(m_provider, new CallbackPromiseAdapter<bool,
ServiceWorkerError>(resolver)); |
| 109 return promise; | 110 return promise; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 bool ServiceWorkerRegistration::hasPendingActivity() const | 158 bool ServiceWorkerRegistration::hasPendingActivity() const |
| 158 { | 159 { |
| 159 return !m_stopped; | 160 return !m_stopped; |
| 160 } | 161 } |
| 161 | 162 |
| 162 void ServiceWorkerRegistration::stop() | 163 void ServiceWorkerRegistration::stop() |
| 163 { | 164 { |
| 164 if (m_stopped) | 165 if (m_stopped) |
| 165 return; | 166 return; |
| 166 m_stopped = true; | 167 m_stopped = true; |
| 168 m_provider = 0; |
| 167 m_outerRegistration->proxyStopped(); | 169 m_outerRegistration->proxyStopped(); |
| 168 } | 170 } |
| 169 | 171 |
| 170 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |