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/download_action.cc b/download_action.cc
index 6f55220..8e6061c 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -8,7 +8,6 @@
#include <algorithm>
#include <string>
#include <vector>
-#include <glib.h>
#include <base/files/file_path.h>
#include <base/strings/stringprintf.h>
@@ -17,7 +16,6 @@
#include "update_engine/omaha_request_params.h"
#include "update_engine/p2p_manager.h"
#include "update_engine/payload_state_interface.h"
-#include "update_engine/subprocess.h"
#include "update_engine/utils.h"
using base::FilePath;
@@ -99,7 +97,7 @@
return true;
}
-void DownloadAction::WriteToP2PFile(const void *data,
+void DownloadAction::WriteToP2PFile(const void* data,
size_t length,
off_t file_offset) {
if (p2p_sharing_fd_ == -1) {
@@ -247,7 +245,7 @@
bytes_received_ = offset;
}
-void DownloadAction::ReceivedBytes(HttpFetcher *fetcher,
+void DownloadAction::ReceivedBytes(HttpFetcher* fetcher,
const void* bytes,
size_t length) {
// Note that bytes_received_ is the current offset.
@@ -281,7 +279,7 @@
}
}
-void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
+void DownloadAction::TransferComplete(HttpFetcher* fetcher, bool successful) {
if (writer_) {
LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer.";
writer_ = nullptr;