update_engine: migrate from base::MakeUnique to std::make_unique base::MakeUnique is being deprecated as we can now use std::make_unique when compiling code in the C++14 mode. BUG=chromium:769107 CQ-DEPEND=CL:669672 TEST=Run unit tests. Change-Id: I82f76647239b1eb3b98b19f6479788ffd86ce756 Reviewed-on: https://chromium-review.googlesource.com/716826 Commit-Ready: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/hardware_android.cc b/hardware_android.cc index 1793e48..c388b82 100644 --- a/hardware_android.cc +++ b/hardware_android.cc
@@ -21,11 +21,11 @@ #include <sys/types.h> #include <algorithm> +#include <memory> #include <bootloader.h> #include <base/files/file_util.h> -#include <base/memory/ptr_util.h> #include <base/strings/stringprintf.h> #include <cutils/properties.h> @@ -95,7 +95,7 @@ // Factory defined in hardware.h. std::unique_ptr<HardwareInterface> CreateHardware() { - return base::MakeUnique<HardwareAndroid>(); + return std::make_unique<HardwareAndroid>(); } } // namespace hardware
diff --git a/network_selector_android.cc b/network_selector_android.cc index 5edfe40..55ba799 100644 --- a/network_selector_android.cc +++ b/network_selector_android.cc
@@ -16,9 +16,10 @@ #include "update_engine/network_selector_android.h" +#include <memory> + #include <android/multinetwork.h> #include <base/logging.h> -#include <base/memory/ptr_util.h> namespace chromeos_update_engine { @@ -26,7 +27,7 @@ // Factory defined in network_selector.h. std::unique_ptr<NetworkSelectorInterface> CreateNetworkSelector() { - return base::MakeUnique<NetworkSelectorAndroid>(); + return std::make_unique<NetworkSelectorAndroid>(); } } // namespace network
diff --git a/network_selector_stub.cc b/network_selector_stub.cc index e9569a2..67925f4 100644 --- a/network_selector_stub.cc +++ b/network_selector_stub.cc
@@ -16,8 +16,9 @@ #include "update_engine/network_selector_stub.h" +#include <memory> + #include <base/logging.h> -#include <base/memory/ptr_util.h> namespace chromeos_update_engine { @@ -25,7 +26,7 @@ // Factory defined in network_selector.h. std::unique_ptr<NetworkSelectorInterface> CreateNetworkSelector() { - return base::MakeUnique<NetworkSelectorStub>(); + return std::make_unique<NetworkSelectorStub>(); } } // namespace network
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc index c7ef0c7..b1cf31c 100644 --- a/omaha_request_action_unittest.cc +++ b/omaha_request_action_unittest.cc
@@ -18,6 +18,7 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> @@ -1103,7 +1104,7 @@ OmahaRequestAction action( &fake_system_state_, nullptr, - base::MakeUnique<MockHttpFetcher>(http_response.data(), + std::make_unique<MockHttpFetcher>(http_response.data(), http_response.size(), nullptr), false); @@ -1276,7 +1277,7 @@ OmahaRequestAction action( &fake_system_state_, nullptr, - base::MakeUnique<MockHttpFetcher>(http_response.data(), + std::make_unique<MockHttpFetcher>(http_response.data(), http_response.size(), nullptr), false); @@ -1489,7 +1490,7 @@ OmahaRequestAction update_check_action( &fake_system_state_, nullptr, - base::MakeUnique<MockHttpFetcher>(http_response.data(), + std::make_unique<MockHttpFetcher>(http_response.data(), http_response.size(), nullptr), false); @@ -1500,7 +1501,7 @@ OmahaRequestAction event_action( &fake_system_state_, new OmahaEvent(OmahaEvent::kTypeUpdateComplete), - base::MakeUnique<MockHttpFetcher>(http_response.data(), + std::make_unique<MockHttpFetcher>(http_response.data(), http_response.size(), nullptr), false);
diff --git a/payload_consumer/bzip_extent_writer_unittest.cc b/payload_consumer/bzip_extent_writer_unittest.cc index c0efd63..bf050ef 100644 --- a/payload_consumer/bzip_extent_writer_unittest.cc +++ b/payload_consumer/bzip_extent_writer_unittest.cc
@@ -19,10 +19,10 @@ #include <fcntl.h> #include <algorithm> +#include <memory> #include <string> #include <vector> -#include <base/memory/ptr_util.h> #include <gtest/gtest.h> #include "update_engine/common/test_utils.h" @@ -68,7 +68,7 @@ 0x22, 0x9c, 0x28, 0x48, 0x66, 0x61, 0xb8, 0xea, 0x00, }; - BzipExtentWriter bzip_writer(base::MakeUnique<DirectExtentWriter>()); + BzipExtentWriter bzip_writer(std::make_unique<DirectExtentWriter>()); EXPECT_TRUE( bzip_writer.Init(fd_, {extents.begin(), extents.end()}, kBlockSize)); EXPECT_TRUE(bzip_writer.Write(test, sizeof(test))); @@ -103,7 +103,7 @@ vector<Extent> extents = { ExtentForRange(0, (kDecompressedLength + kBlockSize - 1) / kBlockSize)}; - BzipExtentWriter bzip_writer(base::MakeUnique<DirectExtentWriter>()); + BzipExtentWriter bzip_writer(std::make_unique<DirectExtentWriter>()); EXPECT_TRUE( bzip_writer.Init(fd_, {extents.begin(), extents.end()}, kBlockSize));
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc index e05a47d..78a8a42 100644 --- a/payload_consumer/delta_performer.cc +++ b/payload_consumer/delta_performer.cc
@@ -29,7 +29,6 @@ #include <base/files/file_util.h> #include <base/format_macros.h> -#include <base/memory/ptr_util.h> #include <base/metrics/histogram_macros.h> #include <base/strings/string_number_conversions.h> #include <base/strings/string_util.h> @@ -953,8 +952,8 @@ } // Setup the ExtentWriter stack based on the operation type. - std::unique_ptr<ExtentWriter> writer = base::MakeUnique<ZeroPadExtentWriter>( - base::MakeUnique<DirectExtentWriter>()); + std::unique_ptr<ExtentWriter> writer = std::make_unique<ZeroPadExtentWriter>( + std::make_unique<DirectExtentWriter>()); if (operation.type() == InstallOperation::REPLACE_BZ) { writer.reset(new BzipExtentWriter(std::move(writer)));
diff --git a/payload_consumer/extent_writer_unittest.cc b/payload_consumer/extent_writer_unittest.cc index 1f5fbaa..48b27cb 100644 --- a/payload_consumer/extent_writer_unittest.cc +++ b/payload_consumer/extent_writer_unittest.cc
@@ -19,10 +19,10 @@ #include <fcntl.h> #include <algorithm> +#include <memory> #include <string> #include <vector> -#include <base/memory/ptr_util.h> #include <brillo/secure_blob.h> #include <gtest/gtest.h> @@ -159,7 +159,7 @@ brillo::Blob data(kBlockSize * 2); test_utils::FillWithData(&data); - ZeroPadExtentWriter zero_pad_writer(base::MakeUnique<DirectExtentWriter>()); + ZeroPadExtentWriter zero_pad_writer(std::make_unique<DirectExtentWriter>()); EXPECT_TRUE( zero_pad_writer.Init(fd_, {extents.begin(), extents.end()}, kBlockSize));
diff --git a/payload_generator/zip_unittest.cc b/payload_generator/zip_unittest.cc index 308ba2f..c750eb7 100644 --- a/payload_generator/zip_unittest.cc +++ b/payload_generator/zip_unittest.cc
@@ -17,10 +17,10 @@ #include <string.h> #include <unistd.h> +#include <memory> #include <string> #include <vector> -#include <base/memory/ptr_util.h> #include <gtest/gtest.h> #include "update_engine/common/test_utils.h" @@ -71,7 +71,7 @@ template <typename W> bool DecompressWithWriter(const brillo::Blob& in, brillo::Blob* out) { std::unique_ptr<ExtentWriter> writer( - new W(base::MakeUnique<MemoryExtentWriter>(out))); + new W(std::make_unique<MemoryExtentWriter>(out))); // Init() parameters are ignored by the testing MemoryExtentWriter. bool ok = writer->Init(nullptr, {}, 1); ok = writer->Write(in.data(), in.size()) && ok;
diff --git a/real_system_state.cc b/real_system_state.cc index d1af41f..2a208ae 100644 --- a/real_system_state.cc +++ b/real_system_state.cc
@@ -16,12 +16,12 @@ #include "update_engine/real_system_state.h" +#include <memory> #include <string> #include <base/bind.h> #include <base/files/file_util.h> #include <base/location.h> -#include <base/memory/ptr_util.h> #include <base/time/time.h> #include <brillo/message_loops/message_loop.h> #if USE_CHROME_KIOSK_APP @@ -56,7 +56,7 @@ if (!boot_control_) { LOG(WARNING) << "Unable to create BootControl instance, using stub " << "instead. All update attempts will fail."; - boot_control_ = base::MakeUnique<BootControlStub>(); + boot_control_ = std::make_unique<BootControlStub>(); } hardware_ = hardware::CreateHardware();
diff --git a/update_attempter.cc b/update_attempter.cc index 9b34365..f8161a4 100644 --- a/update_attempter.cc +++ b/update_attempter.cc
@@ -28,7 +28,6 @@ #include <base/bind.h> #include <base/files/file_util.h> #include <base/logging.h> -#include <base/memory/ptr_util.h> #include <base/rand_util.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> @@ -603,7 +602,7 @@ new OmahaRequestAction( system_state_, new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted), - base::MakeUnique<LibcurlHttpFetcher>(GetProxyResolver(), + std::make_unique<LibcurlHttpFetcher>(GetProxyResolver(), system_state_->hardware()), false)); @@ -622,7 +621,7 @@ new OmahaRequestAction( system_state_, new OmahaEvent(OmahaEvent::kTypeUpdateDownloadFinished), - base::MakeUnique<LibcurlHttpFetcher>(GetProxyResolver(), + std::make_unique<LibcurlHttpFetcher>(GetProxyResolver(), system_state_->hardware()), false)); shared_ptr<FilesystemVerifierAction> filesystem_verifier_action( @@ -631,7 +630,7 @@ new OmahaRequestAction( system_state_, new OmahaEvent(OmahaEvent::kTypeUpdateComplete), - base::MakeUnique<LibcurlHttpFetcher>(GetProxyResolver(), + std::make_unique<LibcurlHttpFetcher>(GetProxyResolver(), system_state_->hardware()), false)); @@ -1276,7 +1275,7 @@ new OmahaRequestAction( system_state_, error_event_.release(), // Pass ownership. - base::MakeUnique<LibcurlHttpFetcher>(GetProxyResolver(), + std::make_unique<LibcurlHttpFetcher>(GetProxyResolver(), system_state_->hardware()), false)); actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); @@ -1347,7 +1346,7 @@ shared_ptr<OmahaRequestAction> ping_action(new OmahaRequestAction( system_state_, nullptr, - base::MakeUnique<LibcurlHttpFetcher>(GetProxyResolver(), + std::make_unique<LibcurlHttpFetcher>(GetProxyResolver(), system_state_->hardware()), true)); actions_.push_back(shared_ptr<OmahaRequestAction>(ping_action));
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc index 98238f2..b6c7b91 100644 --- a/update_manager/evaluation_context.cc +++ b/update_manager/evaluation_context.cc
@@ -24,7 +24,6 @@ #include <base/bind.h> #include <base/json/json_writer.h> #include <base/location.h> -#include <base/memory/ptr_util.h> #include <base/strings/string_util.h> #include <base/values.h> @@ -229,7 +228,7 @@ } string EvaluationContext::DumpContext() const { - auto variables = base::MakeUnique<base::DictionaryValue>(); + auto variables = std::make_unique<base::DictionaryValue>(); for (auto& it : value_cache_) { variables->SetString(it.first->GetName(), it.second.ToString()); }
diff --git a/update_manager/state_factory.cc b/update_manager/state_factory.cc index 92a9b1b..208ed51 100644 --- a/update_manager/state_factory.cc +++ b/update_manager/state_factory.cc
@@ -19,7 +19,6 @@ #include <memory> #include <base/logging.h> -#include <base/memory/ptr_util.h> #if USE_DBUS #include <session_manager/dbus-proxies.h> #endif // USE_DBUS @@ -57,7 +56,7 @@ chromeos_update_engine::DBusConnection::Get()->GetDBus(); unique_ptr<RealDevicePolicyProvider> device_policy_provider( new RealDevicePolicyProvider( - base::MakeUnique<org::chromium::SessionManagerInterfaceProxy>(bus), + std::make_unique<org::chromium::SessionManagerInterfaceProxy>(bus), policy_provider)); #else unique_ptr<RealDevicePolicyProvider> device_policy_provider(