| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/background_sync/SyncCallbacks.h" | 6 #include "modules/background_sync/SyncCallbacks.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "modules/background_sync/SyncError.h" | 9 #include "modules/background_sync/SyncError.h" |
| 10 #include "modules/background_sync/SyncRegistration.h" | 10 #include "modules/background_sync/SyncRegistration.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ASSERT(m_resolver); | 113 ASSERT(m_resolver); |
| 114 ASSERT(m_serviceWorkerRegistration); | 114 ASSERT(m_serviceWorkerRegistration); |
| 115 } | 115 } |
| 116 | 116 |
| 117 SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks() | 117 SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks() |
| 118 { | 118 { |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SyncGetRegistrationsCallbacks::onSuccess(const WebVector<WebSyncRegistratio
n*>& webSyncRegistrations) | 121 void SyncGetRegistrationsCallbacks::onSuccess(const WebVector<WebSyncRegistratio
n*>& webSyncRegistrations) |
| 122 { | 122 { |
| 123 Vector<OwnPtr<WebSyncRegistration>> registrations; | |
| 124 for (WebSyncRegistration* r : webSyncRegistrations) { | |
| 125 registrations.append(adoptPtr(r)); | |
| 126 } | |
| 127 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { | 123 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { |
| 128 return; | 124 return; |
| 129 } | 125 } |
| 130 | 126 Vector<String> tags; |
| 131 HeapVector<Member<SyncRegistration>> syncRegistrations; | 127 for (const WebSyncRegistration* r : webSyncRegistrations) { |
| 132 for (auto& r : registrations) { | 128 tags.append(r->tag); |
| 133 SyncRegistration* reg = SyncRegistration::take(m_resolver.get(), r.relea
se(), m_serviceWorkerRegistration); | |
| 134 syncRegistrations.append(reg); | |
| 135 } | 129 } |
| 136 m_resolver->resolve(syncRegistrations); | 130 m_resolver->resolve(tags); |
| 137 } | 131 } |
| 138 | 132 |
| 139 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) | 133 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) |
| 140 { | 134 { |
| 141 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { | 135 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { |
| 142 return; | 136 return; |
| 143 } | 137 } |
| 144 m_resolver->reject(SyncError::take(m_resolver.get(), error)); | 138 m_resolver->reject(SyncError::take(m_resolver.get(), error)); |
| 145 } | 139 } |
| 146 | 140 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return "denied"; | 177 return "denied"; |
| 184 case WebSyncPermissionStatusPrompt: | 178 case WebSyncPermissionStatusPrompt: |
| 185 return "prompt"; | 179 return "prompt"; |
| 186 } | 180 } |
| 187 | 181 |
| 188 ASSERT_NOT_REACHED(); | 182 ASSERT_NOT_REACHED(); |
| 189 return "denied"; | 183 return "denied"; |
| 190 } | 184 } |
| 191 | 185 |
| 192 } // namespace blink | 186 } // namespace blink |
| OLD | NEW |