| 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 22 matching lines...) Expand all Loading... |
| 33 : service_registry_(service_registry) { | 33 : service_registry_(service_registry) { |
| 34 DCHECK(service_registry); | 34 DCHECK(service_registry); |
| 35 } | 35 } |
| 36 | 36 |
| 37 BackgroundSyncProvider::~BackgroundSyncProvider() { | 37 BackgroundSyncProvider::~BackgroundSyncProvider() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void BackgroundSyncProvider::registerBackgroundSync( | 40 void BackgroundSyncProvider::registerBackgroundSync( |
| 41 const blink::WebSyncRegistration* options, | 41 const blink::WebSyncRegistration* options, |
| 42 blink::WebServiceWorkerRegistration* service_worker_registration, | 42 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 43 bool requested_from_service_worker, | |
| 44 blink::WebSyncRegistrationCallbacks* callbacks) { | 43 blink::WebSyncRegistrationCallbacks* callbacks) { |
| 45 DCHECK(options); | 44 DCHECK(options); |
| 46 DCHECK(service_worker_registration); | 45 DCHECK(service_worker_registration); |
| 47 DCHECK(callbacks); | 46 DCHECK(callbacks); |
| 48 int64 service_worker_registration_id = | 47 int64 service_worker_registration_id = |
| 49 GetServiceWorkerRegistrationId(service_worker_registration); | 48 GetServiceWorkerRegistrationId(service_worker_registration); |
| 50 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options); | 49 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options); |
| 51 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); | 50 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); |
| 52 | 51 |
| 53 // base::Unretained is safe here, as the mojo channel will be deleted (and | 52 // base::Unretained is safe here, as the mojo channel will be deleted (and |
| 54 // will wipe its callbacks) before 'this' is deleted. | 53 // will wipe its callbacks) before 'this' is deleted. |
| 55 GetBackgroundSyncServicePtr()->Register( | 54 GetBackgroundSyncServicePtr()->Register( |
| 56 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())), | 55 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())), |
| 57 service_worker_registration_id, requested_from_service_worker, | 56 service_worker_registration_id, |
| 58 base::Bind(&BackgroundSyncProvider::RegisterCallback, | 57 base::Bind(&BackgroundSyncProvider::RegisterCallback, |
| 59 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); | 58 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); |
| 60 } | 59 } |
| 61 | 60 |
| 62 void BackgroundSyncProvider::unregisterBackgroundSync( | 61 void BackgroundSyncProvider::unregisterBackgroundSync( |
| 63 blink::WebSyncRegistration::Periodicity periodicity, | 62 blink::WebSyncRegistration::Periodicity periodicity, |
| 64 int64_t id, | 63 int64_t id, |
| 65 const blink::WebString& tag, | 64 const blink::WebString& tag, |
| 66 blink::WebServiceWorkerRegistration* service_worker_registration, | 65 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 67 blink::WebSyncUnregistrationCallbacks* callbacks) { | 66 blink::WebSyncUnregistrationCallbacks* callbacks) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 BackgroundSyncServicePtr& | 314 BackgroundSyncServicePtr& |
| 316 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { | 315 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { |
| 317 if (!background_sync_service_.get()) { | 316 if (!background_sync_service_.get()) { |
| 318 service_registry_->ConnectToRemoteService( | 317 service_registry_->ConnectToRemoteService( |
| 319 mojo::GetProxy(&background_sync_service_)); | 318 mojo::GetProxy(&background_sync_service_)); |
| 320 } | 319 } |
| 321 return background_sync_service_; | 320 return background_sync_service_; |
| 322 } | 321 } |
| 323 | 322 |
| 324 } // namespace content | 323 } // namespace content |
| OLD | NEW |