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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // base::Unretained is safe here, as the mojo channel will be deleted (and | 120 // base::Unretained is safe here, as the mojo channel will be deleted (and |
121 // will wipe its callbacks) before 'this' is deleted. | 121 // will wipe its callbacks) before 'this' is deleted. |
122 GetBackgroundSyncServicePtr()->Unregister( | 122 GetBackgroundSyncServicePtr()->Unregister( |
123 handle_id, service_worker_registration_id, | 123 handle_id, service_worker_registration_id, |
124 base::Bind(&BackgroundSyncProvider::UnregisterCallback, | 124 base::Bind(&BackgroundSyncProvider::UnregisterCallback, |
125 base::Unretained(this), | 125 base::Unretained(this), |
126 base::Passed(std::move(callbacksPtr)))); | 126 base::Passed(std::move(callbacksPtr)))); |
127 } | 127 } |
128 | 128 |
129 void BackgroundSyncProvider::getRegistration( | 129 void BackgroundSyncProvider::getRegistration( |
130 blink::WebSyncRegistration::Periodicity periodicity, | |
131 const blink::WebString& tag, | 130 const blink::WebString& tag, |
132 blink::WebServiceWorkerRegistration* service_worker_registration, | 131 blink::WebServiceWorkerRegistration* service_worker_registration, |
133 blink::WebSyncRegistrationCallbacks* callbacks) { | 132 blink::WebSyncRegistrationCallbacks* callbacks) { |
134 DCHECK(service_worker_registration); | 133 DCHECK(service_worker_registration); |
135 DCHECK(callbacks); | 134 DCHECK(callbacks); |
136 int64_t service_worker_registration_id = | 135 int64_t service_worker_registration_id = |
137 GetServiceWorkerRegistrationId(service_worker_registration); | 136 GetServiceWorkerRegistrationId(service_worker_registration); |
138 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); | 137 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); |
139 | 138 |
140 // base::Unretained is safe here, as the mojo channel will be deleted (and | 139 // base::Unretained is safe here, as the mojo channel will be deleted (and |
141 // will wipe its callbacks) before 'this' is deleted. | 140 // will wipe its callbacks) before 'this' is deleted. |
142 GetBackgroundSyncServicePtr()->GetRegistration( | 141 GetBackgroundSyncServicePtr()->GetRegistration( |
143 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), tag.utf8(), | 142 tag.utf8(), service_worker_registration_id, |
144 service_worker_registration_id, | |
145 base::Bind(&BackgroundSyncProvider::GetRegistrationCallback, | 143 base::Bind(&BackgroundSyncProvider::GetRegistrationCallback, |
146 base::Unretained(this), | 144 base::Unretained(this), |
147 base::Passed(std::move(callbacksPtr)))); | 145 base::Passed(std::move(callbacksPtr)))); |
148 } | 146 } |
149 | 147 |
150 void BackgroundSyncProvider::getRegistrations( | 148 void BackgroundSyncProvider::getRegistrations( |
151 blink::WebSyncRegistration::Periodicity periodicity, | |
152 blink::WebServiceWorkerRegistration* service_worker_registration, | 149 blink::WebServiceWorkerRegistration* service_worker_registration, |
153 blink::WebSyncGetRegistrationsCallbacks* callbacks) { | 150 blink::WebSyncGetRegistrationsCallbacks* callbacks) { |
154 DCHECK(service_worker_registration); | 151 DCHECK(service_worker_registration); |
155 DCHECK(callbacks); | 152 DCHECK(callbacks); |
156 int64_t service_worker_registration_id = | 153 int64_t service_worker_registration_id = |
157 GetServiceWorkerRegistrationId(service_worker_registration); | 154 GetServiceWorkerRegistrationId(service_worker_registration); |
158 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacksPtr(callbacks); | 155 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacksPtr(callbacks); |
159 | 156 |
160 // base::Unretained is safe here, as the mojo channel will be deleted (and | 157 // base::Unretained is safe here, as the mojo channel will be deleted (and |
161 // will wipe its callbacks) before 'this' is deleted. | 158 // will wipe its callbacks) before 'this' is deleted. |
162 GetBackgroundSyncServicePtr()->GetRegistrations( | 159 GetBackgroundSyncServicePtr()->GetRegistrations( |
163 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), | |
164 service_worker_registration_id, | 160 service_worker_registration_id, |
165 base::Bind(&BackgroundSyncProvider::GetRegistrationsCallback, | 161 base::Bind(&BackgroundSyncProvider::GetRegistrationsCallback, |
166 base::Unretained(this), | 162 base::Unretained(this), |
167 base::Passed(std::move(callbacksPtr)))); | 163 base::Passed(std::move(callbacksPtr)))); |
168 } | 164 } |
169 | 165 |
170 void BackgroundSyncProvider::getPermissionStatus( | 166 void BackgroundSyncProvider::getPermissionStatus( |
171 blink::WebSyncRegistration::Periodicity periodicity, | |
172 blink::WebServiceWorkerRegistration* service_worker_registration, | 167 blink::WebServiceWorkerRegistration* service_worker_registration, |
173 blink::WebSyncGetPermissionStatusCallbacks* callbacks) { | 168 blink::WebSyncGetPermissionStatusCallbacks* callbacks) { |
174 DCHECK(service_worker_registration); | 169 DCHECK(service_worker_registration); |
175 DCHECK(callbacks); | 170 DCHECK(callbacks); |
176 int64_t service_worker_registration_id = | 171 int64_t service_worker_registration_id = |
177 GetServiceWorkerRegistrationId(service_worker_registration); | 172 GetServiceWorkerRegistrationId(service_worker_registration); |
178 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacksPtr( | 173 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacksPtr( |
179 callbacks); | 174 callbacks); |
180 | 175 |
181 // base::Unretained is safe here, as the mojo channel will be deleted (and | 176 // base::Unretained is safe here, as the mojo channel will be deleted (and |
182 // will wipe its callbacks) before 'this' is deleted. | 177 // will wipe its callbacks) before 'this' is deleted. |
183 GetBackgroundSyncServicePtr()->GetPermissionStatus( | 178 GetBackgroundSyncServicePtr()->GetPermissionStatus( |
184 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), | |
185 service_worker_registration_id, | 179 service_worker_registration_id, |
186 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback, | 180 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback, |
187 base::Unretained(this), | 181 base::Unretained(this), |
188 base::Passed(std::move(callbacksPtr)))); | 182 base::Passed(std::move(callbacksPtr)))); |
189 } | 183 } |
190 | 184 |
191 void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) { | 185 void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) { |
192 GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id); | 186 GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id); |
193 } | 187 } |
194 | 188 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 mojo::InterfaceRequest<BackgroundSyncService> request = | 433 mojo::InterfaceRequest<BackgroundSyncService> request = |
440 mojo::GetProxy(&background_sync_service_); | 434 mojo::GetProxy(&background_sync_service_); |
441 main_thread_task_runner_->PostTask( | 435 main_thread_task_runner_->PostTask( |
442 FROM_HERE, | 436 FROM_HERE, |
443 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request))); | 437 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request))); |
444 } | 438 } |
445 return background_sync_service_; | 439 return background_sync_service_; |
446 } | 440 } |
447 | 441 |
448 } // namespace content | 442 } // namespace content |
OLD | NEW |