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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 { | 79 { |
80 if (registration && !registration->proxy()) | 80 if (registration && !registration->proxy()) |
81 delete registration; | 81 delete registration; |
82 } | 82 } |
83 | 83 |
84 String ServiceWorkerRegistration::scope() const | 84 String ServiceWorkerRegistration::scope() const |
85 { | 85 { |
86 return m_outerRegistration->scope().string(); | 86 return m_outerRegistration->scope().string(); |
87 } | 87 } |
88 | 88 |
89 ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState) | 89 void ServiceWorkerRegistration::update(ScriptState* scriptState, ExceptionState&
exceptionState) |
90 { | 90 { |
91 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | |
92 ScriptPromise promise = resolver->promise(); | |
93 | |
94 if (!m_provider) { | 91 if (!m_provider) { |
95 resolver->reject(DOMException::create(InvalidStateError, "Failed to upda
te a ServiceWorkerRegistration: No associated provider is available.")); | 92 exceptionState.throwDOMException(InvalidStateError, "Failed to update a
ServiceWorkerRegistration: No associated provider is available."); |
96 return promise; | 93 return; |
97 } | 94 } |
98 | 95 m_outerRegistration->update(m_provider); |
99 m_outerRegistration->update(m_provider, new CallbackPromiseAdapter<void, Ser
viceWorkerError>(resolver)); | |
100 return promise; | |
101 } | 96 } |
102 | 97 |
103 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) | 98 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) |
104 { | 99 { |
105 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 100 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
106 ScriptPromise promise = resolver->promise(); | 101 ScriptPromise promise = resolver->promise(); |
107 | 102 |
108 if (!m_provider) { | 103 if (!m_provider) { |
109 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre
gister a ServiceWorkerRegistration: No associated provider is available.")); | 104 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre
gister a ServiceWorkerRegistration: No associated provider is available.")); |
110 return promise; | 105 return promise; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 161 |
167 void ServiceWorkerRegistration::stop() | 162 void ServiceWorkerRegistration::stop() |
168 { | 163 { |
169 if (m_stopped) | 164 if (m_stopped) |
170 return; | 165 return; |
171 m_stopped = true; | 166 m_stopped = true; |
172 m_outerRegistration->proxyStopped(); | 167 m_outerRegistration->proxyStopped(); |
173 } | 168 } |
174 | 169 |
175 } // namespace blink | 170 } // namespace blink |
OLD | NEW |