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

Side by Side Diff: mojo/public/cpp/bindings/tests/request_response_unittest.cc

Issue 2080083002: Revert of Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 #include <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
11 #include "mojo/public/cpp/test_support/test_utils.h" 11 #include "mojo/public/cpp/test_support/test_utils.h"
12 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h" 12 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h"
13 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" 13 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace test { 17 namespace test {
18 namespace { 18 namespace {
19 19
20 class ProviderImpl : public sample::Provider { 20 class ProviderImpl : public sample::Provider {
21 public: 21 public:
22 explicit ProviderImpl(InterfaceRequest<sample::Provider> request) 22 explicit ProviderImpl(InterfaceRequest<sample::Provider> request)
23 : binding_(this, std::move(request)) {} 23 : binding_(this, std::move(request)) {}
24 24
25 void EchoString(const String& a, 25 void EchoString(const String& a,
26 const EchoStringCallback& callback) override { 26 const Callback<void(String)>& callback) override {
27 EchoStringCallback callback_copy; 27 Callback<void(String)> callback_copy;
28 // Make sure operator= is used. 28 // Make sure operator= is used.
29 callback_copy = callback; 29 callback_copy = callback;
30 callback_copy.Run(a); 30 callback_copy.Run(a);
31 } 31 }
32 32
33 void EchoStrings(const String& a, 33 void EchoStrings(const String& a,
34 const String& b, 34 const String& b,
35 const EchoStringsCallback& callback) override { 35 const Callback<void(String, String)>& callback) override {
36 callback.Run(a, b); 36 callback.Run(a, b);
37 } 37 }
38 38
39 void EchoMessagePipeHandle( 39 void EchoMessagePipeHandle(
40 ScopedMessagePipeHandle a, 40 ScopedMessagePipeHandle a,
41 const EchoMessagePipeHandleCallback& callback) override { 41 const Callback<void(ScopedMessagePipeHandle)>& callback) override {
42 callback.Run(std::move(a)); 42 callback.Run(std::move(a));
43 } 43 }
44 44
45 void EchoEnum(sample::Enum a, const EchoEnumCallback& callback) override { 45 void EchoEnum(sample::Enum a,
46 const Callback<void(sample::Enum)>& callback) override {
46 callback.Run(a); 47 callback.Run(a);
47 } 48 }
48 49
49 void EchoInt(int32_t a, const EchoIntCallback& callback) override { 50 void EchoInt(int32_t a, const EchoIntCallback& callback) override {
50 callback.Run(a); 51 callback.Run(a);
51 } 52 }
52 53
53 Binding<sample::Provider> binding_; 54 Binding<sample::Provider> binding_;
54 }; 55 };
55 56
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 provider->EchoEnum(sample::Enum::VALUE, 150 provider->EchoEnum(sample::Enum::VALUE,
150 base::Bind(&RecordEnum, &value, run_loop.QuitClosure())); 151 base::Bind(&RecordEnum, &value, run_loop.QuitClosure()));
151 run_loop.Run(); 152 run_loop.Run();
152 153
153 EXPECT_EQ(sample::Enum::VALUE, value); 154 EXPECT_EQ(sample::Enum::VALUE, value);
154 } 155 }
155 156
156 } // namespace 157 } // namespace
157 } // namespace test 158 } // namespace test
158 } // namespace mojo 159 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc ('k') | mojo/public/cpp/bindings/tests/sync_method_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698