update_engine: Convert update_manager to chromeos::MessageLoop.

The update_manager/event_loop.* files were basically an abstraction of
the glib main loop in order to make it easier to replace it later.
This patch removes those files and replaces their functions with the
chromeos::MessageLoop interface, backing it up with a FakeMessageLoop
during test, and a real GlibMessageLoop during normal execution. This
patch reduces the running time of the unittest considerably since there
is no need to wait for the timeouts.

BUG=chromium:419827,chromium:402066
TEST=Unittest still pass. Tested on a link device that the UM still runs.

Change-Id: Id572248ff4c9c8be7226ef8c653a5c94ab9c1677
Reviewed-on: https://chromium-review.googlesource.com/276892
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index 3584ac8..0c4ef21 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -19,6 +19,7 @@
 using base::Closure;
 using base::Time;
 using base::TimeDelta;
+using chromeos::MessageLoop;
 using chromeos_update_engine::ClockInterface;
 using std::string;
 using std::unique_ptr;
@@ -75,8 +76,8 @@
     if (it.first->GetMode() == kVariableModeAsync)
       it.first->RemoveObserver(this);
   }
-  CancelMainLoopEvent(timeout_event_);
-  timeout_event_ = kEventIdNull;
+  MessageLoop::current()->CancelTask(timeout_event_);
+  timeout_event_ = MessageLoop::kTaskIdNull;
 
   return unique_ptr<Closure>(callback_.release());
 }
@@ -101,7 +102,7 @@
 void EvaluationContext::OnTimeout() {
   DLOG(INFO) << "OnTimeout() called due to "
              << (timeout_marks_expiration_ ? "expiration" : "poll interval");
-  timeout_event_ = kEventIdNull;
+  timeout_event_ = MessageLoop::kTaskIdNull;
   is_expired_ = timeout_marks_expiration_;
   OnValueChangedOrTimeout();
 }
@@ -202,7 +203,7 @@
   if (!timeout.is_max()) {
     DLOG(INFO) << "Waiting for timeout in "
                << chromeos_update_engine::utils::FormatTimeDelta(timeout);
-    timeout_event_ = RunFromMainLoopAfterTimeout(
+    timeout_event_ = MessageLoop::current()->PostDelayedTask(
         base::Bind(&EvaluationContext::OnTimeout,
                    weak_ptr_factory_.GetWeakPtr()),
         timeout);