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 "content/child/background_sync/background_sync_provider.h" | 5 #include "content/child/background_sync/background_sync_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 base::Passed(std::move(callbacksPtr)))); | 124 base::Passed(std::move(callbacksPtr)))); |
125 } | 125 } |
126 | 126 |
127 void BackgroundSyncProvider::WillStopCurrentWorkerThread() { | 127 void BackgroundSyncProvider::WillStopCurrentWorkerThread() { |
128 delete this; | 128 delete this; |
129 } | 129 } |
130 | 130 |
131 void BackgroundSyncProvider::RegisterCallback( | 131 void BackgroundSyncProvider::RegisterCallback( |
132 std::unique_ptr<blink::WebSyncRegistrationCallbacks> callbacks, | 132 std::unique_ptr<blink::WebSyncRegistrationCallbacks> callbacks, |
133 blink::mojom::BackgroundSyncError error, | 133 blink::mojom::BackgroundSyncError error, |
134 const blink::mojom::SyncRegistrationPtr& options) { | 134 blink::mojom::SyncRegistrationPtr options) { |
135 // TODO(iclelland): Determine the correct error message to return in each case | 135 // TODO(iclelland): Determine the correct error message to return in each case |
136 std::unique_ptr<blink::WebSyncRegistration> result; | 136 std::unique_ptr<blink::WebSyncRegistration> result; |
137 switch (error) { | 137 switch (error) { |
138 case blink::mojom::BackgroundSyncError::NONE: | 138 case blink::mojom::BackgroundSyncError::NONE: |
139 if (!options.is_null()) | 139 if (!options.is_null()) |
140 result = mojo::ConvertTo<std::unique_ptr<blink::WebSyncRegistration>>( | 140 result = mojo::ConvertTo<std::unique_ptr<blink::WebSyncRegistration>>( |
141 options); | 141 options); |
142 callbacks->onSuccess(std::move(result)); | 142 callbacks->onSuccess(std::move(result)); |
143 break; | 143 break; |
144 case blink::mojom::BackgroundSyncError::NOT_FOUND: | 144 case blink::mojom::BackgroundSyncError::NOT_FOUND: |
(...skipping 19 matching lines...) Expand all Loading... |
164 callbacks->onError( | 164 callbacks->onError( |
165 blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, | 165 blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, |
166 "No service worker is active.")); | 166 "No service worker is active.")); |
167 break; | 167 break; |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 void BackgroundSyncProvider::GetRegistrationsCallback( | 171 void BackgroundSyncProvider::GetRegistrationsCallback( |
172 std::unique_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks, | 172 std::unique_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks, |
173 blink::mojom::BackgroundSyncError error, | 173 blink::mojom::BackgroundSyncError error, |
174 const mojo::Array<blink::mojom::SyncRegistrationPtr>& registrations) { | 174 mojo::Array<blink::mojom::SyncRegistrationPtr> registrations) { |
175 // TODO(iclelland): Determine the correct error message to return in each case | 175 // TODO(iclelland): Determine the correct error message to return in each case |
176 switch (error) { | 176 switch (error) { |
177 case blink::mojom::BackgroundSyncError::NONE: { | 177 case blink::mojom::BackgroundSyncError::NONE: { |
178 blink::WebVector<blink::WebSyncRegistration*> results( | 178 blink::WebVector<blink::WebSyncRegistration*> results( |
179 registrations.size()); | 179 registrations.size()); |
180 for (size_t i = 0; i < registrations.size(); ++i) { | 180 for (size_t i = 0; i < registrations.size(); ++i) { |
181 results[i] = | 181 results[i] = |
182 mojo::ConvertTo<std::unique_ptr<blink::WebSyncRegistration>>( | 182 mojo::ConvertTo<std::unique_ptr<blink::WebSyncRegistration>>( |
183 registrations[i]) | 183 registrations[i]) |
184 .release(); | 184 .release(); |
(...skipping 27 matching lines...) Expand all Loading... |
212 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> request = | 212 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> request = |
213 mojo::GetProxy(&background_sync_service_); | 213 mojo::GetProxy(&background_sync_service_); |
214 main_thread_task_runner_->PostTask( | 214 main_thread_task_runner_->PostTask( |
215 FROM_HERE, | 215 FROM_HERE, |
216 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request))); | 216 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request))); |
217 } | 217 } |
218 return background_sync_service_; | 218 return background_sync_service_; |
219 } | 219 } |
220 | 220 |
221 } // namespace content | 221 } // namespace content |
OLD | NEW |