OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 } | 23 } |
24 | 24 |
25 template <typename T> | 25 template <typename T> |
26 typename base::enable_if< | 26 typename base::enable_if< |
27 !base::internal::IsMoveOnlyType<T>::value, | 27 !base::internal::IsMoveOnlyType<T>::value, |
28 T&>::type | 28 T&>::type |
29 RebindForward(T& t) { | 29 RebindForward(T& t) { |
30 return t; | 30 return t; |
31 } | 31 } |
32 | 32 |
33 void RelayToTaskRunner0(base::SequencedTaskRunner* task_runner, | |
peria
2014/04/24 02:38:21
This declaration is not needed.
tzik
2014/04/24 06:56:55
Refactored in another CL.
| |
34 const tracked_objects::Location& from_here, | |
35 const base::Callback<void()>& callback); | |
36 | |
33 template <typename T> | 37 template <typename T> |
34 void RelayToTaskRunner1(base::SequencedTaskRunner* task_runner, | 38 void RelayToTaskRunner1(base::SequencedTaskRunner* task_runner, |
35 const tracked_objects::Location& from_here, | 39 const tracked_objects::Location& from_here, |
36 const base::Callback<void(T)>& callback, | 40 const base::Callback<void(T)>& callback, |
37 T arg) { | 41 T arg) { |
38 task_runner->PostTask( | 42 task_runner->PostTask( |
39 from_here, base::Bind(callback, RebindForward(arg))); | 43 from_here, base::Bind(callback, RebindForward(arg))); |
40 } | 44 } |
41 | 45 |
42 template <typename T1, typename T2> | 46 template <typename T1, typename T2> |
43 void RelayToTaskRunner2(base::SequencedTaskRunner* task_runner, | 47 void RelayToTaskRunner2(base::SequencedTaskRunner* task_runner, |
44 const tracked_objects::Location& from_here, | 48 const tracked_objects::Location& from_here, |
45 const base::Callback<void(T1, T2)>& callback, | 49 const base::Callback<void(T1, T2)>& callback, |
46 T1 arg1, | 50 T1 arg1, |
47 T2 arg2) { | 51 T2 arg2) { |
48 task_runner->PostTask( | 52 task_runner->PostTask( |
49 from_here, base::Bind(callback, | 53 from_here, base::Bind(callback, |
50 RebindForward(arg1), | 54 RebindForward(arg1), |
51 RebindForward(arg2))); | 55 RebindForward(arg2))); |
52 } | 56 } |
53 | 57 |
54 } // namespace internal | 58 } // namespace internal |
55 | 59 |
60 base::Callback<void()> CreateRelayedCallback( | |
61 const base::Callback<void()>& callback); | |
62 | |
56 template <typename T> | 63 template <typename T> |
57 base::Callback<void(T)> CreateRelayedCallback( | 64 base::Callback<void(T)> CreateRelayedCallback( |
58 const base::Callback<void(T)>& callback) { | 65 const base::Callback<void(T)>& callback) { |
59 return base::Bind(&internal::RelayToTaskRunner1<T>, | 66 return base::Bind(&internal::RelayToTaskRunner1<T>, |
60 base::MessageLoopProxy::current(), | 67 base::MessageLoopProxy::current(), |
61 FROM_HERE, | 68 FROM_HERE, |
62 callback); | 69 callback); |
63 } | 70 } |
64 | 71 |
65 template <typename T1, typename T2> | 72 template <typename T1, typename T2> |
66 base::Callback<void(T1, T2)> CreateRelayedCallback( | 73 base::Callback<void(T1, T2)> CreateRelayedCallback( |
67 const base::Callback<void(T1, T2)>& callback) { | 74 const base::Callback<void(T1, T2)>& callback) { |
68 return base::Bind(&internal::RelayToTaskRunner2<T1, T2>, | 75 return base::Bind(&internal::RelayToTaskRunner2<T1, T2>, |
69 base::MessageLoopProxy::current(), | 76 base::MessageLoopProxy::current(), |
70 FROM_HERE, | 77 FROM_HERE, |
71 callback); | 78 callback); |
72 } | 79 } |
73 | 80 |
74 } // namespace drive_backend | 81 } // namespace drive_backend |
75 } // namespace sync_file_system | 82 } // namespace sync_file_system |
76 | 83 |
77 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 84 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
OLD | NEW |