Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: chromeos/network/network_state_handler.cc

Issue 2478573003: NetworkStateHandler::InitializeForTest() should return a std::unique_ptr. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/network/network_state_handler.cc
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index bf0681c27eb8410e736912e1161bcbe190a70756..74f6f4cdb9d25d914943073f6800b2879febc1c9 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -85,13 +85,14 @@ void NetworkStateHandler::Shutdown() {
}
void NetworkStateHandler::InitShillPropertyHandler() {
- shill_property_handler_.reset(new internal::ShillPropertyHandler(this));
+ shill_property_handler_ =
+ base::MakeUnique<internal::ShillPropertyHandler>(this);
shill_property_handler_->Init();
}
// static
-NetworkStateHandler* NetworkStateHandler::InitializeForTest() {
- NetworkStateHandler* handler = new NetworkStateHandler();
+std::unique_ptr<NetworkStateHandler> NetworkStateHandler::InitializeForTest() {
+ auto handler = base::WrapUnique(new NetworkStateHandler());
stevenjb 2016/11/04 16:31:37 My understanding is that MakeUnique<NetworkStateHa
Lei Zhang 2016/11/04 18:30:37 First thing I tried, but the ctor is private.
stevenjb 2016/11/04 18:33:31 Ah, right, I remember that part of the discussion
handler->InitShillPropertyHandler();
return handler;
}
@@ -260,12 +261,9 @@ const NetworkState* NetworkStateHandler::FirstNetworkByType(
std::string NetworkStateHandler::FormattedHardwareAddressForType(
const NetworkTypePattern& type) const {
- const DeviceState* device = nullptr;
const NetworkState* network = ConnectedNetworkByType(type);
- if (network)
- device = GetDeviceState(network->device_path());
- else
- device = GetDeviceStateByType(type);
+ const DeviceState* device = network ? GetDeviceState(network->device_path())
+ : GetDeviceStateByType(type);
if (!device)
return std::string();
return network_util::FormattedMacAddress(device->mac_address());
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | chromeos/network/prohibited_technologies_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698