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/variable.h b/update_manager/variable.h
index c47f488..9f80461 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -12,10 +12,9 @@
#include <base/bind.h>
#include <base/logging.h>
#include <base/time/time.h>
+#include <chromeos/message_loops/message_loop.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
-#include "update_engine/update_manager/event_loop.h"
-
namespace chromeos_update_manager {
// The VariableMode specifies important behavior of the variable in terms of
@@ -108,8 +107,9 @@
// to avoid scheduling these callbacks when it is not needed, we check
// first the list of observers.
if (!observer_list_.empty()) {
- RunFromMainLoop(base::Bind(&BaseVariable::OnValueChangedNotification,
- base::Unretained(this)));
+ chromeos::MessageLoop::current()->PostTask(
+ base::Bind(&BaseVariable::OnValueChangedNotification,
+ base::Unretained(this)));
}
}