update_engine: Migrate time-based glib main loop calls to MessageLoop.

This patch replaces most calls to g_idle_add* and g_timeout_add* with
the equivalent MessageLoop::Post*Task(). To maintain compatibility with
unittests running the main loop and doing I/O we instantiate a
GlibMessageLoop for those tests.

BUG=chromium:499886
TEST=unittests still pass.

Change-Id: Ic87ba69bc47391ac3c36d1bfc3ca28d069666af1
Reviewed-on: https://chromium-review.googlesource.com/281197
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
diff --git a/proxy_resolver.h b/proxy_resolver.h
index d59b888..9d6b73a 100644
--- a/proxy_resolver.h
+++ b/proxy_resolver.h
@@ -5,11 +5,11 @@
 #ifndef UPDATE_ENGINE_PROXY_RESOLVER_H_
 #define UPDATE_ENGINE_PROXY_RESOLVER_H_
 
-
 #include <deque>
 #include <string>
 
 #include <base/logging.h>
+#include <chromeos/message_loops/message_loop.h>
 
 #include "update_engine/utils.h"
 
@@ -45,7 +45,7 @@
 // Always says to not use a proxy
 class DirectProxyResolver : public ProxyResolver {
  public:
-  DirectProxyResolver() : idle_callback_id_(0), num_proxies_(1) {}
+  DirectProxyResolver() = default;
   ~DirectProxyResolver() override;
   bool GetProxiesForUrl(const std::string& url,
                         ProxiesResolvedFn callback,
@@ -58,12 +58,13 @@
   }
 
  private:
-  // The ID of the idle main loop callback
-  guint idle_callback_id_;
+  // The ID of the main loop callback.
+  chromeos::MessageLoop::TaskId idle_callback_id_{
+      chromeos::MessageLoop::kTaskIdNull};
 
   // Number of direct proxies to return on resolved list; currently used for
   // testing.
-  size_t num_proxies_;
+  size_t num_proxies_{1};
 
   // The MainLoop callback, from here we return to the client.
   void ReturnCallback(ProxiesResolvedFn callback, void* data);