OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GOOGLE_APIS_TASK_UTIL_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_TASK_UTIL_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_TASK_UTIL_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_TASK_UTIL_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 template<typename T1, typename T2, typename T3> | 59 template<typename T1, typename T2, typename T3> |
60 struct ComposedCallback<void(T1, T2, T3)> { | 60 struct ComposedCallback<void(T1, T2, T3)> { |
61 static void Run( | 61 static void Run( |
62 const base::Callback<void(const base::Closure&)>& runner, | 62 const base::Callback<void(const base::Closure&)>& runner, |
63 const base::Callback<void(T1, T2, T3)>& callback, | 63 const base::Callback<void(T1, T2, T3)>& callback, |
64 T1 arg1, T2 arg2, T3 arg3) { | 64 T1 arg1, T2 arg2, T3 arg3) { |
65 runner.Run(base::Bind(callback, arg1, arg2, arg3)); | 65 runner.Run(base::Bind(callback, arg1, arg2, arg3)); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
| 69 // ComposedCallback with three arguments, and the second one is scoped_ptr. |
| 70 template<typename T1, typename T2, typename D2, typename T3> |
| 71 struct ComposedCallback<void(T1, scoped_ptr<T2, D2>, T3)> { |
| 72 static void Run( |
| 73 const base::Callback<void(const base::Closure&)>& runner, |
| 74 const base::Callback<void(T1, scoped_ptr<T2, D2>, T3)>& callback, |
| 75 T1 arg1, scoped_ptr<T2, D2> arg2, T3 arg3) { |
| 76 runner.Run(base::Bind(callback, arg1, base::Passed(&arg2), arg3)); |
| 77 } |
| 78 }; |
| 79 |
69 // ComposedCallback with three arguments, and the last one is scoped_ptr. | 80 // ComposedCallback with three arguments, and the last one is scoped_ptr. |
70 template<typename T1, typename T2, typename T3, typename D3> | 81 template<typename T1, typename T2, typename T3, typename D3> |
71 struct ComposedCallback<void(T1, T2, scoped_ptr<T3, D3>)> { | 82 struct ComposedCallback<void(T1, T2, scoped_ptr<T3, D3>)> { |
72 static void Run( | 83 static void Run( |
73 const base::Callback<void(const base::Closure&)>& runner, | 84 const base::Callback<void(const base::Closure&)>& runner, |
74 const base::Callback<void(T1, T2, scoped_ptr<T3, D3>)>& callback, | 85 const base::Callback<void(T1, T2, scoped_ptr<T3, D3>)>& callback, |
75 T1 arg1, T2 arg2, scoped_ptr<T3, D3> arg3) { | 86 T1 arg1, T2 arg2, scoped_ptr<T3, D3> arg3) { |
76 runner.Run(base::Bind(callback, arg1, arg2, base::Passed(&arg3))); | 87 runner.Run(base::Bind(callback, arg1, arg2, base::Passed(&arg3))); |
77 } | 88 } |
78 }; | 89 }; |
(...skipping 30 matching lines...) Expand all Loading... |
109 template<typename CallbackType> | 120 template<typename CallbackType> |
110 CallbackType CreateRelayCallback(const CallbackType& callback) { | 121 CallbackType CreateRelayCallback(const CallbackType& callback) { |
111 return CreateComposedCallback( | 122 return CreateComposedCallback( |
112 base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()), | 123 base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()), |
113 callback); | 124 callback); |
114 } | 125 } |
115 | 126 |
116 } // namespace google_apis | 127 } // namespace google_apis |
117 | 128 |
118 #endif // CHROME_BROWSER_GOOGLE_APIS_TASK_UTIL_H_ | 129 #endif // CHROME_BROWSER_GOOGLE_APIS_TASK_UTIL_H_ |
OLD | NEW |