metricsd: Create a brillo::MessageLoop.

brillo::BinderWatcher now requires a brillo::MessageLoop, so this patch
creates a brillo::BaseMessageLoop and passes it when creating the
brillo::BinderWatcher.

Bug: 26356682
TEST=Deployed metricsd to edison-eng.

Change-Id: I6a9e592623faf231205ae44e479bec2b873b8898
This commit is contained in:
Alex Deymo 2016-02-04 13:52:56 -08:00
parent 9dead6deec
commit f1bf9e5fc9
2 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include <binder/IServiceManager.h>
#include <brillo/binder_watcher.h>
#include <brillo/message_loops/base_message_loop.h>
#include <utils/Errors.h>
#include "uploader/bn_metricsd_impl.h"
@ -40,15 +41,17 @@ void MetricsdServiceRunner::Run() {
CHECK(status == android::OK) << "Metricsd service registration failed";
message_loop_for_io_.reset(new base::MessageLoopForIO);
message_loop_.reset(new brillo::BaseMessageLoop(message_loop_for_io_.get()));
brillo::BinderWatcher watcher;
brillo::BinderWatcher watcher(message_loop_.get());
CHECK(watcher.Init()) << "failed to initialize the binder file descriptor "
<< "watcher";
message_loop_for_io_->Run();
message_loop_->Run();
// Delete the message loop here as it needs to be deconstructed in the thread
// it is attached to.
message_loop_.reset();
message_loop_for_io_.reset();
}

View File

@ -21,6 +21,7 @@
#include <thread>
#include <base/message_loop/message_loop.h>
#include <brillo/message_loops/message_loop.h>
#include "uploader/crash_counters.h"
@ -39,6 +40,7 @@ class MetricsdServiceRunner {
void Run();
std::unique_ptr<base::MessageLoopForIO> message_loop_for_io_;
std::unique_ptr<brillo::MessageLoop> message_loop_;
std::unique_ptr<std::thread> thread_;
std::shared_ptr<CrashCounters> counters_;