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/update_attempter.h b/update_attempter.h
index c3495da..1326365 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -283,12 +283,8 @@
void CleanupCpuSharesManagement();
// The cpu shares timeout source callback sets the current cpu shares to
- // normal. Returns false so that GLib destroys the timeout source.
- static gboolean StaticManageCpuSharesCallback(gpointer data);
- bool ManageCpuSharesCallback();
-
- // Callback to start the action processor.
- static gboolean StaticStartProcessing(gpointer data);
+ // normal.
+ void ManageCpuSharesCallback();
// Schedules an event loop callback to start the action processor. This is
// scheduled asynchronously to unblock the event loop.
@@ -432,8 +428,9 @@
// Current cpu shares.
utils::CpuShares shares_ = utils::kCpuSharesNormal;
- // The cpu shares management timeout source.
- GSource* manage_shares_source_ = nullptr;
+ // The cpu shares management timeout task id.
+ chromeos::MessageLoop::TaskId manage_shares_id_{
+ chromeos::MessageLoop::kTaskIdNull};
// Set to true if an update download is active (and BytesReceived
// will be called), set to false otherwise.