Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: components/filesystem/files_test_base.h

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ 5 #ifndef COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
6 #define COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ 6 #define COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
7 7
8 #include <utility>
9
10 #include "base/bind.h"
8 #include "base/macros.h" 11 #include "base/macros.h"
9 #include "components/filesystem/public/interfaces/file_system.mojom.h" 12 #include "components/filesystem/public/interfaces/file_system.mojom.h"
10 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
11 #include "services/shell/public/cpp/shell_test.h" 14 #include "services/shell/public/cpp/shell_test.h"
12 15
13 namespace filesystem { 16 namespace filesystem {
14 17
18 template <typename... Args> void IgnoreAllArgs(Args&&... args) {}
19
20 template <typename... Args>
21 void DoCaptures(Args*... out_args, Args... in_args) {
22 IgnoreAllArgs((*out_args = std::move(in_args))...);
23 }
24
15 template <typename T1> 25 template <typename T1>
16 mojo::Callback<void(T1)> Capture(T1* t1) { 26 base::Callback<void(T1)> Capture(T1* t1) {
17 return [t1](T1 got_t1) { *t1 = std::move(got_t1); }; 27 return base::Bind(&DoCaptures<T1>, t1);
18 } 28 }
19 29
20 template <typename T1, typename T2> 30 template <typename T1, typename T2>
21 mojo::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) { 31 base::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) {
22 return [t1, t2](T1 got_t1, T2 got_t2) { 32 return base::Bind(&DoCaptures<T1, T2>, t1, t2);
23 *t1 = std::move(got_t1);
24 *t2 = std::move(got_t2);
25 };
26 } 33 }
27 34
28 template <typename T1, typename T2, typename T3> 35 template <typename T1, typename T2, typename T3>
29 mojo::Callback<void(T1, T2, T3)> Capture(T1* t1, T2* t2, T3* t3) { 36 base::Callback<void(T1, T2, T3)> Capture(T1* t1, T2* t2, T3* t3) {
30 return [t1, t2, t3](T1 got_t1, T2 got_t2, T3 got_t3) { 37 return base::Bind(&DoCaptures<T1, T2, T3>, t1, t2, t3);
31 *t1 = std::move(got_t1);
32 *t2 = std::move(got_t2);
33 *t3 = std::move(got_t3);
34 };
35 } 38 }
36 39
37 class FilesTestBase : public shell::test::ShellTest { 40 class FilesTestBase : public shell::test::ShellTest {
38 public: 41 public:
39 FilesTestBase(); 42 FilesTestBase();
40 ~FilesTestBase() override; 43 ~FilesTestBase() override;
41 44
42 // Overridden from shell::test::ShellTest: 45 // Overridden from shell::test::ShellTest:
43 void SetUp() override; 46 void SetUp() override;
44 47
45 protected: 48 protected:
46 // Note: This has an out parameter rather than returning the |DirectoryPtr|, 49 // Note: This has an out parameter rather than returning the |DirectoryPtr|,
47 // since |ASSERT_...()| doesn't work with return values. 50 // since |ASSERT_...()| doesn't work with return values.
48 void GetTemporaryRoot(mojom::DirectoryPtr* directory); 51 void GetTemporaryRoot(mojom::DirectoryPtr* directory);
49 52
50 mojom::FileSystemPtr& files() { return files_; } 53 mojom::FileSystemPtr& files() { return files_; }
51 54
52 private: 55 private:
53 mojom::FileSystemPtr files_; 56 mojom::FileSystemPtr files_;
54 57
55 DISALLOW_COPY_AND_ASSIGN(FilesTestBase); 58 DISALLOW_COPY_AND_ASSIGN(FilesTestBase);
56 }; 59 };
57 60
58 } // namespace filesystem 61 } // namespace filesystem
59 62
60 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ 63 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698