update_engine: Remove all references to glib.
The message loop in production code switched from
chromeos::GlibMessageLoop to chromeos::BaseMessageLoop used in
chromeos::Dameon. This patch moves all the unittests also to use
chromeos::BaseMessageLoop or chromeos::FakeMessageLoop when I/O is not
required.
This patch removes all (now unused) references to glib.
BUG=chromium:499886
TEST=`grep glib[^c] . -R` return no results. Also, unittests work.
Change-Id: Iddfb17def501829d932ed1f70faad3e00268898e
Reviewed-on: https://chromium-review.googlesource.com/292157
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
diff --git a/action.h b/action.h
index 53786d1..3cbc26b 100644
--- a/action.h
+++ b/action.h
@@ -30,12 +30,12 @@
// How it works:
//
// First off, there is only one thread and all I/O should be asynchronous.
-// A glib main loop blocks whenever there is no work to be done. This happens
+// A message loop blocks whenever there is no work to be done. This happens
// where there is no CPU work to be done and no I/O ready to transfer in or
-// out. Two kinds of events can wake up the main loop: timer alarm or file
-// descriptors. If either of these happens, glib finds out the owner of what
-// fired and calls the appropriate code to handle it. As such, all the code
-// in the Action* classes and the code that is calls is non-blocking.
+// out. Two kinds of events can wake up the message loop: timer alarm or file
+// descriptors. If either of these happens, the message loop finds out the owner
+// of what fired and calls the appropriate code to handle it. As such, all the
+// code in the Action* classes and the code that is calls is non-blocking.
//
// An ActionProcessor contains a queue of Actions to perform. When
// ActionProcessor::StartProcessing() is called, it executes the first action.
diff --git a/connection_manager.cc b/connection_manager.cc
index d0d3392..004eba0 100644
--- a/connection_manager.cc
+++ b/connection_manager.cc
@@ -10,7 +10,6 @@
#include <base/stl_util.h>
#include <base/strings/string_util.h>
#include <chromeos/dbus/service_constants.h>
-#include <glib.h>
#include <policy/device_policy.h>
#include "update_engine/prefs.h"
diff --git a/dbus_bindings/org.chromium.UpdateEngineInterface.xml b/dbus_bindings/org.chromium.UpdateEngineInterface.xml
index dda972d..a632608 100644
--- a/dbus_bindings/org.chromium.UpdateEngineInterface.xml
+++ b/dbus_bindings/org.chromium.UpdateEngineInterface.xml
@@ -1,8 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
-<!-- COPYRIGHT HERE
- dbus-binding-tool -mode=glib-server -prefix=update_engine update_engine.xml
- > glib_server.h
--->
<node name="/org/chromium/UpdateEngine">
<interface name="org.chromium.UpdateEngineInterface">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 254dbd7..a8306f3 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -4,7 +4,6 @@
#include "update_engine/download_action.h"
-#include <glib.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/filesystem_verifier_action.h b/filesystem_verifier_action.h
index 731790a..e6c1908 100644
--- a/filesystem_verifier_action.h
+++ b/filesystem_verifier_action.h
@@ -44,7 +44,7 @@
// Used for testing. Return true if Cleanup() has not yet been called due
// to a callback upon the completion or cancellation of the verifier action.
// A test should wait until IsCleanupPending() returns false before
- // terminating the glib main loop.
+ // terminating the main loop.
bool IsCleanupPending() const;
// Debugging/logging
diff --git a/filesystem_verifier_action_unittest.cc b/filesystem_verifier_action_unittest.cc
index 66f8571..9ddeb29 100644
--- a/filesystem_verifier_action_unittest.cc
+++ b/filesystem_verifier_action_unittest.cc
@@ -14,7 +14,7 @@
#include <base/posix/eintr_wrapper.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
-#include <chromeos/message_loops/glib_message_loop.h>
+#include <chromeos/message_loops/fake_message_loop.h>
#include <chromeos/message_loops/message_loop_utils.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -47,7 +47,7 @@
bool hash_fail,
PartitionType partition_type);
- chromeos::GlibMessageLoop loop_;
+ chromeos::FakeMessageLoop loop_{nullptr};
FakeSystemState fake_system_state_;
};
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 4f68a9a..1b8891d 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -129,7 +129,7 @@
// Calls into curl_multi_perform to let libcurl do its work. Returns after
// curl_multi_perform is finished, which may actually be after more than
- // one call to curl_multi_perform. This method will set up the glib run
+ // one call to curl_multi_perform. This method will set up the message
// loop with sources for future work that libcurl will do.
// This method will not block.
// Returns true if we should resume immediately after this call.
diff --git a/main.cc b/main.cc
index 0e5f4e5..1d82dd6 100644
--- a/main.cc
+++ b/main.cc
@@ -14,7 +14,6 @@
#include <base/strings/stringprintf.h>
#include <chromeos/flag_helper.h>
#include <chromeos/message_loops/base_message_loop.h>
-#include <glib.h>
#include <metrics/metrics_library.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/mock_http_fetcher.h b/mock_http_fetcher.h
index 36b6a1d..fa718bc 100644
--- a/mock_http_fetcher.h
+++ b/mock_http_fetcher.h
@@ -10,7 +10,6 @@
#include <base/logging.h>
#include <chromeos/message_loops/message_loop.h>
-#include <glib.h>
#include "update_engine/fake_system_state.h"
#include "update_engine/http_fetcher.h"
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index 29a0e45..d575fb0 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -11,7 +11,6 @@
#include <vector>
#include <chromeos/secure_blob.h>
-#include <glib.h>
#include <gtest/gtest.h>
#include "update_engine/libcurl_http_fetcher.h"
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index aae0506..2a11d7d 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -4,7 +4,6 @@
#include "update_engine/omaha_request_action.h"
-#include <glib.h>
#include <stdint.h>
#include <string>
diff --git a/p2p_manager.h b/p2p_manager.h
index fb07c2e..559bba8 100644
--- a/p2p_manager.h
+++ b/p2p_manager.h
@@ -77,7 +77,7 @@
// Asynchronously finds a peer that serves the file identified by
// |file_id|. If |minimum_size| is non-zero, will find a peer that
// has at least that many bytes. When the result is ready |callback|
- // is called from the default GLib mainloop.
+ // is called from the current message loop.
//
// This operation may take a very long time to complete because part
// of the p2p protocol involves waiting for the LAN-wide sum of all
diff --git a/p2p_manager_unittest.cc b/p2p_manager_unittest.cc
index 3b1f1c0..18b4184 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -17,9 +17,10 @@
#include <base/bind.h>
#include <base/callback.h>
#include <base/files/file_util.h>
+#include <base/message_loop/message_loop.h>
#include <base/strings/stringprintf.h>
#include <chromeos/asynchronous_signal_handler.h>
-#include <chromeos/message_loops/glib_message_loop.h>
+#include <chromeos/message_loops/base_message_loop.h>
#include <chromeos/message_loops/message_loop.h>
#include <chromeos/message_loops/message_loop_utils.h>
#include <gmock/gmock.h>
@@ -74,10 +75,8 @@
TimeDelta::FromDays(5)));
}
- // TODO(deymo): Replace this with a FakeMessageLoop. P2PManager uses glib to
- // interact with the p2p-client tool, so we need to run a GlibMessageLoop
- // here.
- chromeos::GlibMessageLoop loop_;
+ base::MessageLoopForIO base_loop_;
+ chromeos::BaseMessageLoop loop_{&base_loop_};
chromeos::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 1873331..ecdadc7 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -16,7 +16,6 @@
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_split.h>
#include <chromeos/flag_helper.h>
-#include <glib.h>
#include "update_engine/delta_performer.h"
#include "update_engine/payload_generator/delta_diff_generator.h"
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 08ed398..c4e66ac 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -4,8 +4,6 @@
#include "update_engine/payload_state.h"
-#include <glib.h>
-
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/strings/stringprintf.h>
diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc
index 5131239..056ae21 100644
--- a/postinstall_runner_action_unittest.cc
+++ b/postinstall_runner_action_unittest.cc
@@ -13,10 +13,11 @@
#include <vector>
#include <base/files/file_util.h>
+#include <base/message_loop/message_loop.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <chromeos/bind_lambda.h>
-#include <chromeos/message_loops/glib_message_loop.h>
+#include <chromeos/message_loops/base_message_loop.h>
#include <chromeos/message_loops/message_loop_utils.h>
#include <gtest/gtest.h>
@@ -48,7 +49,8 @@
private:
static const char* kImageMountPointTemplate;
- chromeos::GlibMessageLoop loop_;
+ base::MessageLoopForIO base_loop_;
+ chromeos::BaseMessageLoop loop_{&base_loop_};
chromeos::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
};
diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc
index 3933f25..d9b212b 100644
--- a/subprocess_unittest.cc
+++ b/subprocess_unittest.cc
@@ -19,11 +19,12 @@
#include <base/bind.h>
#include <base/location.h>
+#include <base/message_loop/message_loop.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <base/time/time.h>
#include <chromeos/bind_lambda.h>
-#include <chromeos/message_loops/glib_message_loop.h>
+#include <chromeos/message_loops/base_message_loop.h>
#include <chromeos/message_loops/message_loop.h>
#include <chromeos/message_loops/message_loop_utils.h>
#include <chromeos/strings/string_utils.h>
@@ -47,9 +48,8 @@
subprocess_.Init(&async_signal_handler_);
}
- // TODO(deymo): Replace this with a FakeMessageLoop. Subprocess uses glib to
- // asynchronously spawn a process, so we need to run a GlibMessageLoop here.
- chromeos::GlibMessageLoop loop_;
+ base::MessageLoopForIO base_loop_;
+ chromeos::BaseMessageLoop loop_{&base_loop_};
chromeos::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
};
diff --git a/testrunner.cc b/testrunner.cc
index dfd8a73..845f16a 100644
--- a/testrunner.cc
+++ b/testrunner.cc
@@ -7,7 +7,6 @@
#include <base/at_exit.h>
#include <base/command_line.h>
#include <chromeos/test_helpers.h>
-#include <glib.h>
#include <gtest/gtest.h>
#include "update_engine/terminator.h"
diff --git a/update_attempter.cc b/update_attempter.cc
index 05fbde8..0e9a5c2 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -23,7 +23,6 @@
#include <chromeos/dbus/service_constants.h>
#include <chromeos/message_loops/message_loop.h>
-#include <glib.h>
#include <metrics/metrics_library.h>
#include <policy/device_policy.h>
#include <policy/libpolicy.h>
diff --git a/update_attempter.h b/update_attempter.h
index 180b45e..85b06f5 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -14,7 +14,6 @@
#include <base/bind.h>
#include <base/time/time.h>
-#include <glib.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
#include "update_engine/action_processor.h"
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 9965def..19f2081 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -9,10 +9,11 @@
#include <memory>
#include <base/files/file_util.h>
+#include <base/message_loop/message_loop.h>
#include <chromeos/bind_lambda.h>
#include <chromeos/dbus/service_constants.h>
#include <chromeos/make_unique_ptr.h>
-#include <chromeos/message_loops/glib_message_loop.h>
+#include <chromeos/message_loops/base_message_loop.h>
#include <chromeos/message_loops/message_loop.h>
#include <chromeos/message_loops/message_loop_utils.h>
#include <gtest/gtest.h>
@@ -175,9 +176,8 @@
return actual_using_p2p_for_sharing_;
}
- // TODO(deymo): Replace this with a FakeMessageLoop. Some of these tests use a
- // real LibcurlHttpFetcher, which still requires a GlibMessageLoop.
- chromeos::GlibMessageLoop loop_;
+ base::MessageLoopForIO base_loop_;
+ chromeos::BaseMessageLoop loop_{&base_loop_};
FakeSystemState fake_system_state_;
org::chromium::debugdProxyMock debugd_proxy_mock_;
diff --git a/update_engine.gyp b/update_engine.gyp
index 1482877..e339a4c 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -4,7 +4,6 @@
'deps': [
'libchrome-<(libbase_ver)',
'libchromeos-<(libbase_ver)',
- 'libchromeos-glib-<(libbase_ver)',
],
# Defaults if the -DUSE_* flags are not passed to gyp is 0. You can set
# the default value for the USE flag in the ebuild.
@@ -82,7 +81,6 @@
'variables': {
'exported_deps': [
'dbus-1',
- 'glib-2.0',
'libchrome-<(libbase_ver)',
'libchromeos-<(libbase_ver)',
'libcrypto',
diff --git a/utils.h b/utils.h
index 73d6eb9..efea204 100644
--- a/utils.h
+++ b/utils.h
@@ -397,9 +397,7 @@
// (NOTE: This function does not currently take daylight savings time
// into account so the result may up to one hour off. This is because
// the glibc date and timezone routines depend on the TZ environment
-// variable and changing environment variables is not thread-safe. An
-// alternative, thread-safe API to use would be GDateTime/GTimeZone
-// available in GLib 2.26 or later.)
+// variable and changing environment variables is not thread-safe.
bool ConvertToOmahaInstallDate(base::Time time, int *out_num_days);
// This function returns the duration on the wallclock since the last