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_thread_proxy.h" | 5 #include "content/child/background_sync/background_sync_provider_thread_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 new CallbackThreadAdapter<blink::WebSyncGetPermissionStatusCallbacks>( | 204 new CallbackThreadAdapter<blink::WebSyncGetPermissionStatusCallbacks>( |
205 make_scoped_ptr(callbacks), WorkerThread::GetCurrentId()))); | 205 make_scoped_ptr(callbacks), WorkerThread::GetCurrentId()))); |
206 } | 206 } |
207 | 207 |
208 void BackgroundSyncProviderThreadProxy::releaseRegistration(int64_t handle_id) { | 208 void BackgroundSyncProviderThreadProxy::releaseRegistration(int64_t handle_id) { |
209 main_thread_task_runner_->PostTask( | 209 main_thread_task_runner_->PostTask( |
210 FROM_HERE, base::Bind(&BackgroundSyncProvider::releaseRegistration, | 210 FROM_HERE, base::Bind(&BackgroundSyncProvider::releaseRegistration, |
211 base::Unretained(sync_provider_), handle_id)); | 211 base::Unretained(sync_provider_), handle_id)); |
212 } | 212 } |
213 | 213 |
214 void BackgroundSyncProviderThreadProxy::notifyWhenDone( | |
215 int64_t handle_id, | |
216 blink::WebSyncNotifyWhenDoneCallbacks* callbacks) { | |
michaeln
2015/09/17 21:44:12
I'm very wary of the thread affinity all blink::We
jkarlin
2015/09/18 12:03:20
Yes, good catch. chasej@ is making good headway in
michaeln
2015/09/18 19:18:52
Glad to hear that. I hope it helps to establish sa
| |
217 DCHECK(callbacks); | |
218 | |
219 main_thread_task_runner_->PostTask( | |
220 FROM_HERE, | |
221 base::Bind( | |
222 &BackgroundSyncProvider::notifyWhenDone, | |
223 base::Unretained(sync_provider_), handle_id, | |
224 new CallbackThreadAdapter<blink::WebSyncNotifyWhenDoneCallbacks>( | |
225 make_scoped_ptr(callbacks), WorkerThread::GetCurrentId()))); | |
226 } | |
227 | |
214 void BackgroundSyncProviderThreadProxy::DuplicateRegistrationHandle( | 228 void BackgroundSyncProviderThreadProxy::DuplicateRegistrationHandle( |
215 int64 handle_id, | 229 int64 handle_id, |
216 const BackgroundSyncService::DuplicateRegistrationHandleCallback& | 230 const BackgroundSyncService::DuplicateRegistrationHandleCallback& |
217 callback) { | 231 callback) { |
218 main_thread_task_runner_->PostTask( | 232 main_thread_task_runner_->PostTask( |
219 FROM_HERE, | 233 FROM_HERE, |
220 base::Bind(&BackgroundSyncProvider::DuplicateRegistrationHandle, | 234 base::Bind(&BackgroundSyncProvider::DuplicateRegistrationHandle, |
221 base::Unretained(sync_provider_), handle_id, | 235 base::Unretained(sync_provider_), handle_id, |
222 base::Bind(&DuplicateRegistrationHandleCallbackOnMainThread, | 236 base::Bind(&DuplicateRegistrationHandleCallbackOnMainThread, |
223 WorkerThread::GetCurrentId(), callback))); | 237 WorkerThread::GetCurrentId(), callback))); |
224 } | 238 } |
225 | 239 |
226 void BackgroundSyncProviderThreadProxy::WillStopCurrentWorkerThread() { | 240 void BackgroundSyncProviderThreadProxy::WillStopCurrentWorkerThread() { |
227 delete this; | 241 delete this; |
228 } | 242 } |
229 | 243 |
230 BackgroundSyncProviderThreadProxy::BackgroundSyncProviderThreadProxy( | 244 BackgroundSyncProviderThreadProxy::BackgroundSyncProviderThreadProxy( |
231 base::SingleThreadTaskRunner* main_thread_task_runner, | 245 base::SingleThreadTaskRunner* main_thread_task_runner, |
232 BackgroundSyncProvider* sync_provider) | 246 BackgroundSyncProvider* sync_provider) |
233 : main_thread_task_runner_(main_thread_task_runner), | 247 : main_thread_task_runner_(main_thread_task_runner), |
234 sync_provider_(sync_provider) { | 248 sync_provider_(sync_provider) { |
235 g_sync_provider_tls.Pointer()->Set(this); | 249 g_sync_provider_tls.Pointer()->Set(this); |
236 } | 250 } |
237 | 251 |
238 BackgroundSyncProviderThreadProxy::~BackgroundSyncProviderThreadProxy() { | 252 BackgroundSyncProviderThreadProxy::~BackgroundSyncProviderThreadProxy() { |
239 g_sync_provider_tls.Pointer()->Set(nullptr); | 253 g_sync_provider_tls.Pointer()->Set(nullptr); |
240 } | 254 } |
241 | 255 |
242 } // namespace content | 256 } // namespace content |
OLD | NEW |