diff options
author | hscham <hscham@chromium.org> | 2020-02-20 12:32:06 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-04 11:51:34 +0000 |
commit | 00b6aa24548cffae6e979e99722ea2bda95be8fe (patch) | |
tree | ed01d7c7f66d8bdea4ea7ca2e9ca6d16484f52c4 | |
parent | c48581a0b26c77f900aa7b82bd13f4c6691d474f (diff) |
update_engine: changes for libchrome r680000 uprev
Changes applied include:
Replace arraysize by base::size.
Replace base::MessageLoop::current()->task_runner by
base::ThreadTaskRunnerHandle::Get, and
base::MessageLoopForIO::current by base::MessageLoopCurrent::IsSet.
Remove use of base::ContainsKey.
Replace base::Int{,64}ToString by base::NumberTostring.
The changes are all compatible with current libchrome r576279.
BUG=chromium:1054279
TEST=unittest
Change-Id: Ibb6027a5070e0e2d4554a6684350168542fedf5e
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2065691
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Tested-by: Qijiang Fan <fqj@google.com>
Commit-Queue: Qijiang Fan <fqj@google.com>
-rw-r--r-- | client_library/client_dbus.cc | 2 | ||||
-rw-r--r-- | common/cpu_limiter.cc | 2 | ||||
-rw-r--r-- | common/error_code_utils.cc | 2 | ||||
-rw-r--r-- | common/http_common.cc | 5 | ||||
-rw-r--r-- | common/http_fetcher_unittest.cc | 7 | ||||
-rw-r--r-- | common/prefs.cc | 2 | ||||
-rw-r--r-- | common/subprocess.cc | 3 | ||||
-rw-r--r-- | connection_manager.cc | 3 | ||||
-rw-r--r-- | libcurl_http_fetcher.cc | 8 | ||||
-rw-r--r-- | omaha_request_params.cc | 3 | ||||
-rw-r--r-- | payload_consumer/delta_performer_integration_test.cc | 3 | ||||
-rw-r--r-- | payload_consumer/delta_performer_unittest.cc | 5 | ||||
-rw-r--r-- | payload_consumer/postinstall_runner_action.cc | 3 | ||||
-rw-r--r-- | payload_generator/extent_ranges_unittest.cc | 3 | ||||
-rw-r--r-- | payload_generator/payload_signer_unittest.cc | 5 | ||||
-rw-r--r-- | update_engine_client.cc | 3 |
16 files changed, 35 insertions, 24 deletions
diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc index f16b7591..4ec76c5b 100644 --- a/client_library/client_dbus.cc +++ b/client_library/client_dbus.cc @@ -214,7 +214,7 @@ bool DBusUpdateEngineClient::UnregisterStatusUpdateHandler( bool DBusUpdateEngineClient::RegisterStatusUpdateHandler( StatusUpdateHandler* handler) { - if (!base::MessageLoopForIO::current()) { + if (!base::MessageLoopCurrent::IsSet()) { LOG(FATAL) << "Cannot get UpdateEngineClient outside of message loop."; return false; } diff --git a/common/cpu_limiter.cc b/common/cpu_limiter.cc index 1d14764f..5f1ae6f0 100644 --- a/common/cpu_limiter.cc +++ b/common/cpu_limiter.cc @@ -67,7 +67,7 @@ bool CPULimiter::SetCpuShares(CpuShares shares) { if (shares_ == shares) return true; - std::string string_shares = base::IntToString(static_cast<int>(shares)); + std::string string_shares = base::NumberToString(static_cast<int>(shares)); LOG(INFO) << "Setting cgroup cpu shares to " << string_shares; if (!utils::WriteFile( kCGroupSharesPath, string_shares.c_str(), string_shares.size())) { diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc index 5bcbaa40..397cdf24 100644 --- a/common/error_code_utils.cc +++ b/common/error_code_utils.cc @@ -171,7 +171,7 @@ string ErrorCodeToString(ErrorCode code) { // error codes which should be added here. } - return "Unknown error: " + base::UintToString(static_cast<unsigned>(code)); + return "Unknown error: " + base::NumberToString(static_cast<unsigned>(code)); } } // namespace utils diff --git a/common/http_common.cc b/common/http_common.cc index 5f234b0b..c8bac477 100644 --- a/common/http_common.cc +++ b/common/http_common.cc @@ -21,6 +21,7 @@ #include <cstdlib> #include <base/macros.h> +#include <base/stl_util.h> namespace chromeos_update_engine { @@ -56,7 +57,7 @@ const char* GetHttpResponseDescription(HttpResponseCode code) { bool is_found = false; size_t i; - for (i = 0; i < arraysize(http_response_table); i++) + for (i = 0; i < base::size(http_response_table); i++) if ((is_found = (http_response_table[i].code == code))) break; @@ -77,7 +78,7 @@ const char* GetHttpContentTypeString(HttpContentType type) { bool is_found = false; size_t i; - for (i = 0; i < arraysize(http_content_type_table); i++) + for (i = 0; i < base::size(http_content_type_table); i++) if ((is_found = (http_content_type_table[i].type == type))) break; diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc index 237ea209..589579e3 100644 --- a/common/http_fetcher_unittest.cc +++ b/common/http_fetcher_unittest.cc @@ -29,6 +29,7 @@ #include <base/location.h> #include <base/logging.h> #include <base/message_loop/message_loop.h> +#include <base/stl_util.h> #include <base/strings/string_number_conversions.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> @@ -1049,7 +1050,7 @@ TYPED_TEST(HttpFetcherTest, SimpleRedirectTest) { unique_ptr<HttpServer> server(this->test_.CreateServer()); ASSERT_TRUE(server->started_); - for (size_t c = 0; c < arraysize(kRedirectCodes); ++c) { + for (size_t c = 0; c < base::size(kRedirectCodes); ++c) { const string url = base::StringPrintf( "/redirect/%d/download/%d", kRedirectCodes[c], kMediumLength); RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher()); @@ -1066,7 +1067,7 @@ TYPED_TEST(HttpFetcherTest, MaxRedirectTest) { string url; for (int r = 0; r < kDownloadMaxRedirects; r++) { url += base::StringPrintf("/redirect/%d", - kRedirectCodes[r % arraysize(kRedirectCodes)]); + kRedirectCodes[r % base::size(kRedirectCodes)]); } url += base::StringPrintf("/download/%d", kMediumLength); RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher()); @@ -1082,7 +1083,7 @@ TYPED_TEST(HttpFetcherTest, BeyondMaxRedirectTest) { string url; for (int r = 0; r < kDownloadMaxRedirects + 1; r++) { url += base::StringPrintf("/redirect/%d", - kRedirectCodes[r % arraysize(kRedirectCodes)]); + kRedirectCodes[r % base::size(kRedirectCodes)]); } url += base::StringPrintf("/download/%d", kMediumLength); RedirectTest(server.get(), false, url, this->test_.NewLargeFetcher()); diff --git a/common/prefs.cc b/common/prefs.cc index 71838619..194bbd8b 100644 --- a/common/prefs.cc +++ b/common/prefs.cc @@ -54,7 +54,7 @@ bool PrefsBase::GetInt64(const string& key, int64_t* value) const { } bool PrefsBase::SetInt64(const string& key, const int64_t value) { - return SetString(key, base::Int64ToString(value)); + return SetString(key, base::NumberToString(value)); } bool PrefsBase::GetBoolean(const string& key, bool* value) const { diff --git a/common/subprocess.cc b/common/subprocess.cc index 24ad2d9b..45dff923 100644 --- a/common/subprocess.cc +++ b/common/subprocess.cc @@ -29,6 +29,7 @@ #include <base/bind.h> #include <base/logging.h> #include <base/posix/eintr_wrapper.h> +#include <base/stl_util.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> #include <brillo/process.h> @@ -122,7 +123,7 @@ void Subprocess::OnStdoutReady(SubprocessRecord* record) { bytes_read = 0; bool eof; bool ok = utils::ReadAll( - record->stdout_fd, buf, arraysize(buf), &bytes_read, &eof); + record->stdout_fd, buf, base::size(buf), &bytes_read, &eof); record->stdout.append(buf, bytes_read); if (!ok || eof) { // There was either an error or an EOF condition, so we are done watching diff --git a/connection_manager.cc b/connection_manager.cc index ad7e5f65..fe43f37b 100644 --- a/connection_manager.cc +++ b/connection_manager.cc @@ -89,7 +89,8 @@ bool ConnectionManager::IsUpdateAllowedOver( if (device_policy->GetAllowedConnectionTypesForUpdate(&allowed_types)) { // The update setting is enforced by the device policy. - if (!base::ContainsKey(allowed_types, shill::kTypeCellular)) { + // TODO(crbug.com/1054279): Use base::Contains after uprev to r680000. + if (allowed_types.find(shill::kTypeCellular) == allowed_types.end()) { LOG(INFO) << "Disabling updates over cellular connection as it's not " "allowed in the device policy."; return false; diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc index 4bea4eff..d317d489 100644 --- a/libcurl_http_fetcher.cc +++ b/libcurl_http_fetcher.cc @@ -80,7 +80,7 @@ int LibcurlHttpFetcher::LibcurlCloseSocketCallback(void* clientp, #endif // __ANDROID__ LibcurlHttpFetcher* fetcher = static_cast<LibcurlHttpFetcher*>(clientp); // Stop watching the socket before closing it. - for (size_t t = 0; t < arraysize(fetcher->fd_controller_maps_); ++t) { + for (size_t t = 0; t < base::size(fetcher->fd_controller_maps_); ++t) { fetcher->fd_controller_maps_[t].erase(item); } @@ -676,7 +676,7 @@ void LibcurlHttpFetcher::SetupMessageLoopSources() { // We should iterate through all file descriptors up to libcurl's fd_max or // the highest one we're tracking, whichever is larger. - for (size_t t = 0; t < arraysize(fd_controller_maps_); ++t) { + for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) { if (!fd_controller_maps_[t].empty()) fd_max = max(fd_max, fd_controller_maps_[t].rbegin()->first); } @@ -694,7 +694,7 @@ void LibcurlHttpFetcher::SetupMessageLoopSources() { is_exc || (FD_ISSET(fd, &fd_write) != 0) // track 1 -- write }; - for (size_t t = 0; t < arraysize(fd_controller_maps_); ++t) { + for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) { bool tracked = fd_controller_maps_[t].find(fd) != fd_controller_maps_[t].end(); @@ -775,7 +775,7 @@ void LibcurlHttpFetcher::CleanUp() { MessageLoop::current()->CancelTask(timeout_id_); timeout_id_ = MessageLoop::kTaskIdNull; - for (size_t t = 0; t < arraysize(fd_controller_maps_); ++t) { + for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) { fd_controller_maps_[t].clear(); } diff --git a/omaha_request_params.cc b/omaha_request_params.cc index b6c18a6c..88633926 100644 --- a/omaha_request_params.cc +++ b/omaha_request_params.cc @@ -25,6 +25,7 @@ #include <vector> #include <base/files/file_util.h> +#include <base/stl_util.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> #include <brillo/key_value_store.h> @@ -217,7 +218,7 @@ void OmahaRequestParams::set_root(const string& root) { } int OmahaRequestParams::GetChannelIndex(const string& channel) const { - for (size_t t = 0; t < arraysize(kChannelsByStability); ++t) + for (size_t t = 0; t < base::size(kChannelsByStability); ++t) if (channel == kChannelsByStability[t]) return t; diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc index f1a492b5..af6682a4 100644 --- a/payload_consumer/delta_performer_integration_test.cc +++ b/payload_consumer/delta_performer_integration_test.cc @@ -25,6 +25,7 @@ #include <base/files/file_path.h> #include <base/files/file_util.h> +#include <base/stl_util.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> #include <google/protobuf/repeated_field.h> @@ -848,7 +849,7 @@ void VerifyPayloadResult(DeltaPerformer* performer, brillo::Blob updated_kernel_partition; EXPECT_TRUE(utils::ReadFile(state->result_kernel, &updated_kernel_partition)); - ASSERT_GE(updated_kernel_partition.size(), arraysize(kNewData)); + ASSERT_GE(updated_kernel_partition.size(), base::size(kNewData)); EXPECT_TRUE(std::equal(std::begin(kNewData), std::end(kNewData), updated_kernel_partition.begin())); diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc index 47cb0e78..39011957 100644 --- a/payload_consumer/delta_performer_unittest.cc +++ b/payload_consumer/delta_performer_unittest.cc @@ -27,6 +27,7 @@ #include <base/files/file_path.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> +#include <base/stl_util.h> #include <base/strings/string_number_conversions.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> @@ -715,12 +716,12 @@ TEST_F(DeltaPerformerTest, ChooseSourceFDTest) { TEST_F(DeltaPerformerTest, ExtentsToByteStringTest) { uint64_t test[] = {1, 1, 4, 2, 0, 1}; - static_assert(arraysize(test) % 2 == 0, "Array size uneven"); + static_assert(base::size(test) % 2 == 0, "Array size uneven"); const uint64_t block_size = 4096; const uint64_t file_length = 4 * block_size - 13; google::protobuf::RepeatedPtrField<Extent> extents; - for (size_t i = 0; i < arraysize(test); i += 2) { + for (size_t i = 0; i < base::size(test); i += 2) { *(extents.Add()) = ExtentForRange(test[i], test[i + 1]); } diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc index 9ecda488..a0b67eac 100644 --- a/payload_consumer/postinstall_runner_action.cc +++ b/payload_consumer/postinstall_runner_action.cc @@ -28,6 +28,7 @@ #include <base/files/file_path.h> #include <base/files/file_util.h> #include <base/logging.h> +#include <base/stl_util.h> #include <base/strings/string_split.h> #include <base/strings/string_util.h> @@ -229,7 +230,7 @@ void PostinstallRunnerAction::OnProgressFdReady() { bytes_read = 0; bool eof; bool ok = - utils::ReadAll(progress_fd_, buf, arraysize(buf), &bytes_read, &eof); + utils::ReadAll(progress_fd_, buf, base::size(buf), &bytes_read, &eof); progress_buffer_.append(buf, bytes_read); // Process every line. vector<string> lines = base::SplitString( diff --git a/payload_generator/extent_ranges_unittest.cc b/payload_generator/extent_ranges_unittest.cc index 2bcffed2..326e9360 100644 --- a/payload_generator/extent_ranges_unittest.cc +++ b/payload_generator/extent_ranges_unittest.cc @@ -18,6 +18,7 @@ #include <vector> +#include <base/stl_util.h> #include <gtest/gtest.h> #include "update_engine/common/test_utils.h" @@ -53,7 +54,7 @@ void ExpectRangeEq(const ExtentRanges& ranges, #define EXPECT_RANGE_EQ(ranges, var) \ do { \ - ExpectRangeEq(ranges, var, arraysize(var), __LINE__); \ + ExpectRangeEq(ranges, var, base::size(var), __LINE__); \ } while (0) void ExpectRangesOverlapOrTouch(uint64_t a_start, diff --git a/payload_generator/payload_signer_unittest.cc b/payload_generator/payload_signer_unittest.cc index 52d51bc4..f7f9c696 100644 --- a/payload_generator/payload_signer_unittest.cc +++ b/payload_generator/payload_signer_unittest.cc @@ -20,6 +20,7 @@ #include <vector> #include <base/logging.h> +#include <base/stl_util.h> #include <gtest/gtest.h> #include "update_engine/common/hash_calculator.h" @@ -124,8 +125,8 @@ TEST_F(PayloadSignerTest, SignSimpleTextTest) { const Signatures_Signature& signature = signatures.signatures(0); EXPECT_EQ(1U, signature.version()); const string& sig_data = signature.data(); - ASSERT_EQ(arraysize(kDataSignature), sig_data.size()); - for (size_t i = 0; i < arraysize(kDataSignature); i++) { + ASSERT_EQ(base::size(kDataSignature), sig_data.size()); + for (size_t i = 0; i < base::size(kDataSignature); i++) { EXPECT_EQ(kDataSignature[i], static_cast<uint8_t>(sig_data[i])); } } diff --git a/update_engine_client.cc b/update_engine_client.cc index a721f7a7..31448eaa 100644 --- a/update_engine_client.cc +++ b/update_engine_client.cc @@ -29,6 +29,7 @@ #include <base/strings/string_number_conversions.h> #include <base/strings/string_split.h> #include <base/threading/platform_thread.h> +#include <base/threading/thread_task_runner_handle.h> #include <brillo/daemons/daemon.h> #include <brillo/flag_helper.h> #include <brillo/key_value_store.h> @@ -86,7 +87,7 @@ class UpdateEngineClient : public brillo::Daemon { // We can't call QuitWithExitCode from OnInit(), so we delay the execution // of the ProcessFlags method after the Daemon initialization is done. - base::MessageLoop::current()->task_runner()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&UpdateEngineClient::ProcessFlagsAndExit, base::Unretained(this))); |