service_example: Instantiate a brillo::MessageLoop.
The brillo::BinderWatcher now requires a brillo::MessageLoop to work.
Bug: None
TEST=mmma product/google/common/service_example
Change-Id: I27175aeacc708764e366aec604f84a76cfdc337f
diff --git a/service_example/brillo_example_client.cpp b/service_example/brillo_example_client.cpp
index ec63569..21804ee 100644
--- a/service_example/brillo_example_client.cpp
+++ b/service_example/brillo_example_client.cpp
@@ -69,15 +69,14 @@
service->RegisterCallback(cbo, 3);
// Create a message loop.
- // TODO(ralphnathan): Change this to brillo::BaseMessageLoop.
base::MessageLoopForIO message_loop_for_io;
+ brillo::BaseMessageLoop message_loop{&message_loop_for_io};
// Initialize a binder watcher.
brillo::BinderWatcher watcher;
watcher.Init();
// Poll stdin.
- brillo::BaseMessageLoop message_loop(&message_loop_for_io);
base::Closure stdin_callback = base::Bind(&StdinCallback, service);
message_loop.WatchFileDescriptor(
STDIN_FILENO, brillo::BaseMessageLoop::kWatchRead, true, stdin_callback);
diff --git a/service_example/brillo_example_service.cpp b/service_example/brillo_example_service.cpp
index 4c4af15..cf98665 100644
--- a/service_example/brillo_example_service.cpp
+++ b/service_example/brillo_example_service.cpp
@@ -20,6 +20,7 @@
#include <binder/IServiceManager.h>
#include <binder/Status.h>
#include <brillo/binder_watcher.h>
+#include <brillo/message_loops/base_message_loop.h>
#include <brillo/syslog_logging.h>
#include <utils/String16.h>
@@ -68,13 +69,13 @@
"Failed to get IExampleService binder from service manager!";
// Create a message loop.
- // TODO(ralphnathan): Change this to brillo::BaseMessageLoop.
base::MessageLoopForIO message_loop_for_io;
+ brillo::BaseMessageLoop message_loop{&message_loop_for_io};
// Initialize a binder watcher.
brillo::BinderWatcher watcher;
watcher.Init();
// Run the message loop.
- message_loop_for_io.Run();
+ message_loop.Run();
}