| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/child/background_sync/background_sync_type_converters.h" | 9 #include "content/child/background_sync/background_sync_type_converters.h" |
| 10 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 10 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 blink::WebVector<blink::WebSyncRegistration*>* results; | 206 blink::WebVector<blink::WebSyncRegistration*>* results; |
| 207 switch (error) { | 207 switch (error) { |
| 208 case BACKGROUND_SYNC_ERROR_NONE: | 208 case BACKGROUND_SYNC_ERROR_NONE: |
| 209 results = new blink::WebVector<blink::WebSyncRegistration*>( | 209 results = new blink::WebVector<blink::WebSyncRegistration*>( |
| 210 registrations.size()); | 210 registrations.size()); |
| 211 for (size_t i = 0; i < registrations.size(); ++i) { | 211 for (size_t i = 0; i < registrations.size(); ++i) { |
| 212 (*results)[i] = mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>( | 212 (*results)[i] = mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>( |
| 213 registrations[i]).release(); | 213 registrations[i]).release(); |
| 214 } | 214 } |
| 215 callbacks->onSuccess(results); | 215 callbacks->onSuccess(results); |
| 216 break; |
| 216 case BACKGROUND_SYNC_ERROR_NOT_FOUND: | 217 case BACKGROUND_SYNC_ERROR_NOT_FOUND: |
| 217 // This error should never be returned from | 218 // This error should never be returned from |
| 218 // BackgroundSyncManager::GetRegistrations | 219 // BackgroundSyncManager::GetRegistrations |
| 219 NOTREACHED(); | 220 NOTREACHED(); |
| 220 break; | 221 break; |
| 221 case BACKGROUND_SYNC_ERROR_STORAGE: | 222 case BACKGROUND_SYNC_ERROR_STORAGE: |
| 222 callbacks->onError( | 223 callbacks->onError( |
| 223 new blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, | 224 new blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, |
| 224 "Background Sync is disabled.")); | 225 "Background Sync is disabled.")); |
| 225 break; | 226 break; |
| 226 case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: | 227 case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: |
| 227 callbacks->onError( | 228 callbacks->onError( |
| 228 new blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, | 229 new blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, |
| 229 "No service worker is active.")); | 230 "No service worker is active.")); |
| 230 break; | 231 break; |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 | 234 |
| 234 BackgroundSyncServicePtr& | 235 BackgroundSyncServicePtr& |
| 235 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { | 236 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { |
| 236 if (!background_sync_service_.get()) | 237 if (!background_sync_service_.get()) |
| 237 service_registry_->ConnectToRemoteService(&background_sync_service_); | 238 service_registry_->ConnectToRemoteService(&background_sync_service_); |
| 238 return background_sync_service_; | 239 return background_sync_service_; |
| 239 } | 240 } |
| 240 | 241 |
| 241 } // namespace content | 242 } // namespace content |
| OLD | NEW |