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 22 matching lines...) Expand all Loading... |
33 : worker_thread_id_(worker_thread_id) { | 33 : worker_thread_id_(worker_thread_id) { |
34 callbacks_.reset(callbacks.release()); | 34 callbacks_.reset(callbacks.release()); |
35 } | 35 } |
36 | 36 |
37 virtual void onSuccess(S* results) { | 37 virtual void onSuccess(S* results) { |
38 // If the worker thread has been destroyed, then this task will be | 38 // If the worker thread has been destroyed, then this task will be |
39 // silently discarded. | 39 // silently discarded. |
40 WorkerTaskRunner::Instance()->PostTask( | 40 WorkerTaskRunner::Instance()->PostTask( |
41 worker_thread_id_, | 41 worker_thread_id_, |
42 base::Bind(&blink::WebCallbacks<S, T>::onSuccess, | 42 base::Bind(&blink::WebCallbacks<S, T>::onSuccess, |
43 base::Unretained(callbacks_.get()), results)); | 43 base::Owned(callbacks_.release()), results)); |
44 } | 44 } |
45 | 45 |
46 virtual void onError(T* error) { | 46 virtual void onError(T* error) { |
47 // If the worker thread has been destroyed, then this task will be | 47 // If the worker thread has been destroyed, then this task will be |
48 // silently discarded. | 48 // silently discarded. |
49 WorkerTaskRunner::Instance()->PostTask( | 49 WorkerTaskRunner::Instance()->PostTask( |
50 worker_thread_id_, | 50 worker_thread_id_, |
51 base::Bind(&blink::WebCallbacks<S, T>::onError, | 51 base::Bind(&blink::WebCallbacks<S, T>::onError, |
52 base::Unretained(callbacks_.get()), error)); | 52 base::Owned(callbacks_.release()), error)); |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 scoped_ptr<blink::WebCallbacks<S, T>> callbacks_; | 56 scoped_ptr<blink::WebCallbacks<S, T>> callbacks_; |
57 int worker_thread_id_; | 57 int worker_thread_id_; |
58 }; | 58 }; |
59 | 59 |
60 LazyInstance<ThreadLocalPointer<BackgroundSyncProviderThreadProxy>>::Leaky | 60 LazyInstance<ThreadLocalPointer<BackgroundSyncProviderThreadProxy>>::Leaky |
61 g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER; | 61 g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER; |
62 | 62 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 : main_thread_task_runner_(main_thread_task_runner), | 159 : main_thread_task_runner_(main_thread_task_runner), |
160 sync_provider_(sync_provider) { | 160 sync_provider_(sync_provider) { |
161 g_sync_provider_tls.Pointer()->Set(this); | 161 g_sync_provider_tls.Pointer()->Set(this); |
162 } | 162 } |
163 | 163 |
164 BackgroundSyncProviderThreadProxy::~BackgroundSyncProviderThreadProxy() { | 164 BackgroundSyncProviderThreadProxy::~BackgroundSyncProviderThreadProxy() { |
165 g_sync_provider_tls.Pointer()->Set(nullptr); | 165 g_sync_provider_tls.Pointer()->Set(nullptr); |
166 } | 166 } |
167 | 167 |
168 } // namespace content | 168 } // namespace content |
OLD | NEW |