Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1bf9e5f authored by Alex Deymo's avatar Alex Deymo
Browse files

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
parent 9dead6de
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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();
}

+2 −0
Original line number Diff line number Diff line
@@ -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_;