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

Unified Diff: mojo/public/cpp/bindings/tests/request_response_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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/request_response_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/request_response_unittest.cc b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
index 14f552ca5fb9a8959bc0cfecf4faf1736fe18c56..cb944f7209c3937db896c7e7a7d8ee73a051b0d9 100644
--- a/mojo/public/cpp/bindings/tests/request_response_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
@@ -54,51 +54,34 @@ class ProviderImpl : public sample::Provider {
Binding<sample::Provider> binding_;
};
-class StringRecorder {
- public:
- StringRecorder(std::string* buf, const base::Closure& closure)
- : buf_(buf), closure_(closure) {}
- void Run(const String& a) const {
- *buf_ = a;
- closure_.Run();
- }
- void Run(const String& a, const String& b) const {
- *buf_ = a.get() + b.get();
- closure_.Run();
- }
-
- private:
- std::string* buf_;
- base::Closure closure_;
-};
-
-class EnumRecorder {
- public:
- explicit EnumRecorder(sample::Enum* value, const base::Closure& closure)
- : value_(value), closure_(closure) {}
- void Run(sample::Enum a) const {
- *value_ = a;
- closure_.Run();
- }
+void RecordString(std::string* storage,
+ const base::Closure& closure,
+ String str) {
+ *storage = str;
+ closure.Run();
+}
- private:
- sample::Enum* value_;
- base::Closure closure_;
-};
+void RecordStrings(std::string* storage,
+ const base::Closure& closure,
+ String a,
+ String b) {
+ *storage = a.get() + b.get();
+ closure.Run();
+}
-class MessagePipeWriter {
- public:
- MessagePipeWriter(const char* text, const base::Closure& closure)
- : text_(text), closure_(closure) {}
- void Run(ScopedMessagePipeHandle handle) const {
- WriteTextMessage(handle.get(), text_);
- closure_.Run();
- }
+void WriteToMessagePipe(const char* text,
+ const base::Closure& closure,
+ ScopedMessagePipeHandle handle) {
+ WriteTextMessage(handle.get(), text);
+ closure.Run();
+}
- private:
- std::string text_;
- base::Closure closure_;
-};
+void RecordEnum(sample::Enum* storage,
+ const base::Closure& closure,
+ sample::Enum value) {
+ *storage = value;
+ closure.Run();
+}
class RequestResponseTest : public testing::Test {
public:
@@ -118,7 +101,7 @@ TEST_F(RequestResponseTest, EchoString) {
std::string buf;
base::RunLoop run_loop;
provider->EchoString(String::From("hello"),
- StringRecorder(&buf, run_loop.QuitClosure()));
+ base::Bind(&RecordString, &buf, run_loop.QuitClosure()));
run_loop.Run();
@@ -133,7 +116,7 @@ TEST_F(RequestResponseTest, EchoStrings) {
base::RunLoop run_loop;
provider->EchoStrings(
String::From("hello"), String::From(" world"),
- StringRecorder(&buf, run_loop.QuitClosure()));
+ base::Bind(&RecordStrings, &buf, run_loop.QuitClosure()));
run_loop.Run();
@@ -148,7 +131,7 @@ TEST_F(RequestResponseTest, EchoMessagePipeHandle) {
base::RunLoop run_loop;
provider->EchoMessagePipeHandle(
std::move(pipe2.handle1),
- MessagePipeWriter("hello", run_loop.QuitClosure()));
+ base::Bind(&WriteToMessagePipe, "hello", run_loop.QuitClosure()));
run_loop.Run();
@@ -165,8 +148,7 @@ TEST_F(RequestResponseTest, EchoEnum) {
sample::Enum value;
base::RunLoop run_loop;
provider->EchoEnum(sample::Enum::VALUE,
- EnumRecorder(&value, run_loop.QuitClosure()));
-
+ base::Bind(&RecordEnum, &value, run_loop.QuitClosure()));
run_loop.Run();
EXPECT_EQ(sample::Enum::VALUE, value);
« no previous file with comments | « mojo/public/cpp/bindings/tests/pickle_unittest.cc ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698