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_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class RunLoop; | 13 class RunLoop; |
14 } | 14 } |
15 | 15 |
16 namespace sync_file_system { | 16 namespace sync_file_system { |
17 | 17 |
18 template <typename Arg1, typename Arg2> | 18 template <typename Arg1, typename Arg2> |
19 void ReceiveResult2(bool* done, | 19 void ReceiveResult2(bool* done, |
20 Arg1* arg1_out, | 20 Arg1* arg1_out, |
21 Arg2* arg2_out, | 21 Arg2* arg2_out, |
22 Arg1 arg1, | 22 Arg1 arg1, |
23 Arg2 arg2) { | 23 Arg2 arg2) { |
24 EXPECT_FALSE(*done); | 24 EXPECT_FALSE(*done); |
25 *done = true; | 25 *done = true; |
26 *arg1_out = base::internal::CallbackForward(arg1); | 26 *arg1_out = base::internal::CallbackForward(arg1); |
27 *arg2_out = base::internal::CallbackForward(arg2); | 27 *arg2_out = base::internal::CallbackForward(arg2); |
28 } | 28 } |
29 | 29 |
30 template <typename Arg1, typename Arg2> | |
31 void ReceiveResultConst2(bool* done, | |
tzik
2013/11/22 04:48:16
This looks not clean to me...
And to make this cle
| |
32 Arg1* arg1_out, | |
33 Arg2* arg2_out, | |
34 Arg1 arg1, | |
35 const Arg2& arg2) { | |
36 EXPECT_FALSE(*done); | |
37 *done = true; | |
38 *arg1_out = base::internal::CallbackForward(arg1); | |
39 *arg2_out = base::internal::CallbackForward(arg2); | |
40 } | |
41 | |
30 template <typename R> | 42 template <typename R> |
31 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result); | 43 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result); |
32 | 44 |
33 template <typename R> base::Callback<void(R)> | 45 template <typename R> base::Callback<void(R)> |
34 AssignAndQuitCallback(base::RunLoop* run_loop, R* result); | 46 AssignAndQuitCallback(base::RunLoop* run_loop, R* result); |
35 | 47 |
36 template <typename Arg> | 48 template <typename Arg> |
37 base::Callback<void(Arg)> CreateResultReceiver(Arg* arg_out); | 49 base::Callback<void(Arg)> CreateResultReceiver(Arg* arg_out); |
38 | 50 |
39 template <typename Arg1, typename Arg2> | 51 template <typename Arg1, typename Arg2> |
40 base::Callback<void(Arg1, Arg2)> CreateResultReceiver(Arg1* arg1_out, | 52 base::Callback<void(Arg1, Arg2)> CreateResultReceiver(Arg1* arg1_out, |
41 Arg2* arg2_out) { | 53 Arg2* arg2_out) { |
42 return base::Bind(&ReceiveResult2<Arg1, Arg2>, | 54 return base::Bind(&ReceiveResult2<Arg1, Arg2>, |
43 base::Owned(new bool(false)), | 55 base::Owned(new bool(false)), |
44 arg1_out, arg2_out); | 56 arg1_out, arg2_out); |
45 } | 57 } |
kinuko
2013/11/22 04:52:41
Is it reasonable to specify we always use const &
| |
46 | 58 |
59 template <typename Arg1, typename Arg2> | |
60 base::Callback<void(Arg1, const Arg2&)> CreateResultReceiverConst( | |
61 Arg1* arg1_out, Arg2* arg2_out) { | |
62 return base::Bind(&ReceiveResultConst2<Arg1, Arg2>, | |
63 base::Owned(new bool(false)), | |
64 arg1_out, arg2_out); | |
65 } | |
66 | |
47 } // namespace sync_file_system | 67 } // namespace sync_file_system |
48 | 68 |
49 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 69 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
OLD | NEW |