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

Side by Side Diff: components/leveldb/leveldb_service_unittest.cc

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
« no previous file with comments | « components/filesystem/files_test_base.h ('k') | components/leveldb/remote_iterator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "components/filesystem/public/interfaces/directory.mojom.h" 7 #include "components/filesystem/public/interfaces/directory.mojom.h"
8 #include "components/filesystem/public/interfaces/file_system.mojom.h" 8 #include "components/filesystem/public/interfaces/file_system.mojom.h"
9 #include "components/filesystem/public/interfaces/types.mojom.h" 9 #include "components/filesystem/public/interfaces/types.mojom.h"
10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
11 #include "mojo/common/common_type_converters.h" 11 #include "mojo/common/common_type_converters.h"
12 #include "mojo/public/cpp/bindings/binding_set.h" 12 #include "mojo/public/cpp/bindings/binding_set.h"
13 #include "services/shell/public/cpp/shell_connection.h" 13 #include "services/shell/public/cpp/shell_connection.h"
14 #include "services/shell/public/cpp/shell_test.h" 14 #include "services/shell/public/cpp/shell_test.h"
15 15
16 using filesystem::mojom::FileError; 16 using filesystem::mojom::FileError;
17 17
18 namespace leveldb { 18 namespace leveldb {
19 namespace { 19 namespace {
20 20
21 template <typename... Args> void IgnoreAllArgs(Args&&...) {}
22
23 template <typename... Args>
24 void DoCaptures(Args*... out_args, Args... in_args) {
25 IgnoreAllArgs((*out_args = std::move(in_args))...);
26 }
27
21 template <typename T1> 28 template <typename T1>
22 mojo::Callback<void(T1)> Capture(T1* t1) { 29 base::Callback<void(T1)> Capture(T1* t1) {
23 return [t1](T1 got_t1) { *t1 = std::move(got_t1); }; 30 return base::Bind(&DoCaptures<T1>, t1);
24 } 31 }
25 32
26 template <typename T1, typename T2> 33 template <typename T1, typename T2>
27 mojo::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) { 34 base::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) {
28 return [t1, t2](T1 got_t1, T2 got_t2) { 35 return base::Bind(&DoCaptures<T1, T2>, t1, t2);
29 *t1 = std::move(got_t1);
30 *t2 = std::move(got_t2);
31 };
32 } 36 }
33 37
34 class LevelDBServiceTest : public shell::test::ShellTest { 38 class LevelDBServiceTest : public shell::test::ShellTest {
35 public: 39 public:
36 LevelDBServiceTest() : ShellTest("exe:leveldb_service_unittests") {} 40 LevelDBServiceTest() : ShellTest("exe:leveldb_service_unittests") {}
37 ~LevelDBServiceTest() override {} 41 ~LevelDBServiceTest() override {}
38 42
39 protected: 43 protected:
40 // Overridden from mojo::test::ApplicationTestBase: 44 // Overridden from mojo::test::ApplicationTestBase:
41 void SetUp() override { 45 void SetUp() override {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 key_values.SetToEmpty(); 507 key_values.SetToEmpty();
504 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), 508 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix),
505 Capture(&error, &key_values)); 509 Capture(&error, &key_values));
506 ASSERT_TRUE(database.WaitForIncomingResponse()); 510 ASSERT_TRUE(database.WaitForIncomingResponse());
507 EXPECT_EQ(mojom::DatabaseError::OK, error); 511 EXPECT_EQ(mojom::DatabaseError::OK, error);
508 EXPECT_TRUE(key_values.empty()); 512 EXPECT_TRUE(key_values.empty());
509 } 513 }
510 514
511 } // namespace 515 } // namespace
512 } // namespace leveldb 516 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/filesystem/files_test_base.h ('k') | components/leveldb/remote_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698