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

Unified Diff: chrome/browser/chromeos/cros/network_library_impl_cros.cc

Issue 10170003: Replace const char* in cros_network_functions.h with const std::stirng& (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 8 months 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: chrome/browser/chromeos/cros/network_library_impl_cros.cc
diff --git a/chrome/browser/chromeos/cros/network_library_impl_cros.cc b/chrome/browser/chromeos/cros/network_library_impl_cros.cc
index 2f658e1d945a5a8955f7b29f8d2c1cd3ec1f97ca..5c36fbdd68c8600c4db65831f9b86276fc94a0b7 100644
--- a/chrome/browser/chromeos/cros/network_library_impl_cros.cc
+++ b/chrome/browser/chromeos/cros/network_library_impl_cros.cc
@@ -123,7 +123,7 @@ void NetworkLibraryImplCros::NetworkStatusChangedHandler(
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- networklib->UpdateNetworkStatus(std::string(path), std::string(key), value);
+ networklib->UpdateNetworkStatus(path, key, value);
}
void NetworkLibraryImplCros::UpdateNetworkStatus(
@@ -156,9 +156,7 @@ void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler(
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- networklib->UpdateNetworkDeviceStatus(std::string(path),
- std::string(key),
- value);
+ networklib->UpdateNetworkDeviceStatus(path, key, value);
}
void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(
@@ -181,7 +179,7 @@ void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(
NotifyNetworkDeviceChanged(device, index);
// If a device's power state changes, new properties may become defined.
if (index == PROPERTY_INDEX_POWERED) {
- CrosRequestNetworkDeviceProperties(path.c_str(),
+ CrosRequestNetworkDeviceProperties(path,
base::Bind(&NetworkDeviceUpdate,
this));
}
@@ -229,8 +227,7 @@ void NetworkLibraryImplCros::ConfigureServiceCallback(
void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier,
const DictionaryValue* info) {
- CrosConfigureService(identifier.c_str(), *info,
- ConfigureServiceCallback, this);
+ CrosConfigureService(identifier, *info, ConfigureServiceCallback, this);
}
// static callback
@@ -256,7 +253,7 @@ void NetworkLibraryImplCros::NetworkConnectCallback(
}
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
- Network* network = networklib->FindNetworkByPath(std::string(service_path));
+ Network* network = networklib->FindNetworkByPath(service_path);
if (!network) {
LOG(ERROR) << "No network for path: " << service_path;
return;
@@ -266,22 +263,21 @@ void NetworkLibraryImplCros::NetworkConnectCallback(
void NetworkLibraryImplCros::CallConnectToNetwork(Network* network) {
DCHECK(network);
- CrosRequestNetworkServiceConnect(network->service_path().c_str(),
+ CrosRequestNetworkServiceConnect(network->service_path(),
NetworkConnectCallback, this);
}
// static callback
void NetworkLibraryImplCros::WifiServiceUpdateAndConnect(
void* object,
- const char* service_path,
+ const std::string& service_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- if (service_path && properties) {
- Network* network =
- networklib->ParseNetwork(std::string(service_path), *properties);
+ if (properties) {
+ Network* network = networklib->ParseNetwork(service_path, *properties);
DCHECK_EQ(network->type(), TYPE_WIFI);
networklib->ConnectToWifiNetworkUsingConnectData(
static_cast<WifiNetwork*>(network));
@@ -293,7 +289,7 @@ void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect(
// Asynchronously request service properties and call
// WifiServiceUpdateAndConnect.
CrosRequestHiddenWifiNetworkProperties(
- ssid.c_str(),
+ ssid,
SecurityToString(security),
base::Bind(&WifiServiceUpdateAndConnect, this));
}
@@ -301,16 +297,15 @@ void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect(
// static callback
void NetworkLibraryImplCros::VPNServiceUpdateAndConnect(
void* object,
- const char* service_path,
+ const std::string& service_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- if (service_path && properties) {
+ if (properties) {
VLOG(1) << "Connecting to new VPN Service: " << service_path;
- Network* network =
- networklib->ParseNetwork(std::string(service_path), *properties);
+ Network* network = networklib->ParseNetwork(service_path, *properties);
DCHECK_EQ(network->type(), TYPE_VPN);
networklib->ConnectToVirtualNetworkUsingConnectData(
static_cast<VirtualNetwork*>(network));
@@ -324,8 +319,8 @@ void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect(
const std::string& server_hostname,
ProviderType provider_type) {
CrosRequestVirtualNetworkProperties(
- service_name.c_str(),
- server_hostname.c_str(),
+ service_name,
+ server_hostname,
ProviderTypeToString(provider_type),
base::Bind(&VPNServiceUpdateAndConnect, this));
}
@@ -333,8 +328,7 @@ void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect(
void NetworkLibraryImplCros::CallDeleteRememberedNetwork(
const std::string& profile_path,
const std::string& service_path) {
- CrosDeleteServiceFromProfile(
- profile_path.c_str(), service_path.c_str());
+ CrosDeleteServiceFromProfile(profile_path, service_path);
}
//////////////////////////////////////////////////////////////////////////////
@@ -358,8 +352,7 @@ void NetworkLibraryImplCros::ChangePin(const std::string& old_pin,
return;
}
sim_operation_ = SIM_OPERATION_CHANGE_PIN;
- CrosRequestChangePin(cellular->device_path().c_str(),
- old_pin.c_str(), new_pin.c_str(),
+ CrosRequestChangePin(cellular->device_path(), old_pin, new_pin,
PinOperationCallback, this);
}
@@ -373,8 +366,7 @@ void NetworkLibraryImplCros::ChangeRequirePin(bool require_pin,
return;
}
sim_operation_ = SIM_OPERATION_CHANGE_REQUIRE_PIN;
- CrosRequestRequirePin(cellular->device_path().c_str(),
- pin.c_str(), require_pin,
+ CrosRequestRequirePin(cellular->device_path(), pin, require_pin,
PinOperationCallback, this);
}
@@ -385,9 +377,7 @@ void NetworkLibraryImplCros::EnterPin(const std::string& pin) {
return;
}
sim_operation_ = SIM_OPERATION_ENTER_PIN;
- CrosRequestEnterPin(cellular->device_path().c_str(),
- pin.c_str(),
- PinOperationCallback, this);
+ CrosRequestEnterPin(cellular->device_path(), pin, PinOperationCallback, this);
}
void NetworkLibraryImplCros::UnblockPin(const std::string& puk,
@@ -398,8 +388,7 @@ void NetworkLibraryImplCros::UnblockPin(const std::string& puk,
return;
}
sim_operation_ = SIM_OPERATION_UNBLOCK_PIN;
- CrosRequestUnblockPin(cellular->device_path().c_str(),
- puk.c_str(), new_pin.c_str(),
+ CrosRequestUnblockPin(cellular->device_path(), puk, new_pin,
PinOperationCallback, this);
}
@@ -441,7 +430,7 @@ void NetworkLibraryImplCros::RequestCellularScan() {
NOTREACHED() << "Calling RequestCellularScan method w/o cellular device.";
return;
}
- CrosProposeScan(cellular->device_path().c_str());
+ CrosProposeScan(cellular->device_path());
}
void NetworkLibraryImplCros::RequestCellularRegister(
@@ -451,10 +440,8 @@ void NetworkLibraryImplCros::RequestCellularRegister(
NOTREACHED() << "Calling CellularRegister method w/o cellular device.";
return;
}
- CrosRequestCellularRegister(cellular->device_path().c_str(),
- network_id.c_str(),
- CellularRegisterCallback,
- this);
+ CrosRequestCellularRegister(
+ cellular->device_path(), network_id, CellularRegisterCallback, this);
}
// static callback
@@ -479,7 +466,7 @@ void NetworkLibraryImplCros::SetCellularDataRoamingAllowed(bool new_value) {
return;
}
base::FundamentalValue value(new_value);
- CrosSetNetworkDeviceProperty(cellular->device_path().c_str(),
+ CrosSetNetworkDeviceProperty(cellular->device_path(),
flimflam::kCellularAllowRoamingProperty,
value);
}
@@ -540,18 +527,17 @@ void NetworkLibraryImplCros::DisconnectFromNetwork(const Network* network) {
DCHECK(network);
// Asynchronous disconnect request. Network state will be updated through
// the network manager once disconnect completes.
- CrosRequestNetworkServiceDisconnect(network->service_path().c_str());
+ CrosRequestNetworkServiceDisconnect(network->service_path());
}
void NetworkLibraryImplCros::CallEnableNetworkDeviceType(
ConnectionType device, bool enable) {
busy_devices_ |= 1 << device;
- CrosRequestNetworkDeviceEnable(
- ConnectionTypeToString(device), enable);
+ CrosRequestNetworkDeviceEnable(ConnectionTypeToString(device), enable);
}
void NetworkLibraryImplCros::CallRemoveNetwork(const Network* network) {
- const char* service_path = network->service_path().c_str();
+ const std::string& service_path = network->service_path();
if (network->connected())
CrosRequestNetworkServiceDisconnect(service_path);
CrosRequestRemoveNetworkService(service_path);
@@ -571,7 +557,7 @@ NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigs(
hardware_address->clear();
NetworkIPConfigVector ipconfig_vector;
if (!device_path.empty()) {
- IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path.c_str());
+ IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path);
if (ipconfig_status) {
for (int i = 0; i < ipconfig_status->size; ++i) {
IPConfig ipconfig = ipconfig_status->ips[i];
@@ -611,7 +597,7 @@ void NetworkLibraryImplCros::SetIPConfig(const NetworkIPConfig& ipconfig) {
IPConfig* ipconfig_static = NULL;
IPConfigStatus* ipconfig_status =
- CrosListIPConfigs(ipconfig.device_path.c_str());
+ CrosListIPConfigs(ipconfig.device_path);
if (ipconfig_status) {
for (int i = 0; i < ipconfig_status->size; ++i) {
if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_DHCP)
@@ -625,19 +611,17 @@ void NetworkLibraryImplCros::SetIPConfig(const NetworkIPConfig& ipconfig) {
if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) {
// If switching from static to dhcp, create new dhcp ip config.
if (!ipconfig_dhcp)
- CrosAddIPConfig(ipconfig.device_path.c_str(),
- chromeos::IPCONFIG_TYPE_DHCP);
+ CrosAddIPConfig(ipconfig.device_path, chromeos::IPCONFIG_TYPE_DHCP);
// User wants DHCP now. So delete the static ip config.
if (ipconfig_static)
CrosRemoveIPConfig(ipconfig_static);
} else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) {
// If switching from dhcp to static, create new static ip config.
if (!ipconfig_static) {
- CrosAddIPConfig(ipconfig.device_path.c_str(),
- chromeos::IPCONFIG_TYPE_IPV4);
+ CrosAddIPConfig(ipconfig.device_path, chromeos::IPCONFIG_TYPE_IPV4);
// Now find the newly created IP config.
ipconfig_status2 =
- CrosListIPConfigs(ipconfig.device_path.c_str());
+ CrosListIPConfigs(ipconfig.device_path);
if (ipconfig_status2) {
for (int i = 0; i < ipconfig_status2->size; ++i) {
if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4)
@@ -797,7 +781,7 @@ void NetworkLibraryImplCros::NetworkManagerStatusChanged(
// static
void NetworkLibraryImplCros::NetworkManagerUpdate(
void* object,
- const char* manager_path,
+ const std::string& manager_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
@@ -818,7 +802,7 @@ void NetworkLibraryImplCros::ParseNetworkManager(const DictionaryValue& dict) {
Value* value;
bool res = dict.GetWithoutPathExpansion(key, &value);
CHECK(res);
- NetworkManagerStatusChanged(key.c_str(), value);
+ NetworkManagerStatusChanged(key, value);
}
// If there is no Profiles entry, request remembered networks here.
if (!dict.HasKey(flimflam::kProfilesProperty))
@@ -934,7 +918,7 @@ void NetworkLibraryImplCros::UpdateNetworkServiceList(
// Use update_request map to store network priority.
network_update_requests_[service_path] = network_priority_order++;
wifi_scanning_ = true;
- CrosRequestNetworkServiceProperties(service_path.c_str(),
+ CrosRequestNetworkServiceProperties(service_path,
base::Bind(&NetworkServiceUpdate,
this));
}
@@ -980,7 +964,7 @@ void NetworkLibraryImplCros::UpdateWatchedNetworkServiceList(
if (!service_path.empty()) {
VLOG(1) << "Watched Service: " << service_path;
CrosRequestNetworkServiceProperties(
- service_path.c_str(),
+ service_path,
base::Bind(&NetworkServiceUpdate, this));
}
}
@@ -989,17 +973,15 @@ void NetworkLibraryImplCros::UpdateWatchedNetworkServiceList(
// static
void NetworkLibraryImplCros::NetworkServiceUpdate(
void* object,
- const char* service_path,
+ const std::string& service_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- if (service_path) {
- if (!properties)
- return; // Network no longer in visible list, ignore.
- networklib->ParseNetwork(std::string(service_path), *properties);
- }
+ if (!properties)
+ return; // Network no longer in visible list, ignore.
+ networklib->ParseNetwork(service_path, *properties);
}
// Called from NetworkServiceUpdate and WifiServiceUpdateAndConnect.
@@ -1098,14 +1080,14 @@ void NetworkLibraryImplCros::RequestRememberedNetworksUpdate() {
NetworkProfile& profile = *iter;
VLOG(1) << " Requesting Profile: " << profile.path;
CrosRequestNetworkProfileProperties(
- profile.path.c_str(), base::Bind(&ProfileUpdate, this));
+ profile.path, base::Bind(&ProfileUpdate, this));
}
}
// static
void NetworkLibraryImplCros::ProfileUpdate(
void* object,
- const char* profile_path,
+ const std::string& profile_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
@@ -1123,8 +1105,7 @@ void NetworkLibraryImplCros::ProfileUpdate(
}
void NetworkLibraryImplCros::UpdateRememberedServiceList(
- const char* profile_path, const ListValue* profile_entries) {
- DCHECK(profile_path);
+ const std::string& profile_path, const ListValue* profile_entries) {
VLOG(1) << "UpdateRememberedServiceList for path: " << profile_path;
NetworkProfileList::iterator iter1;
for (iter1 = profile_list_.begin(); iter1 != profile_list_.end(); ++iter1) {
@@ -1153,7 +1134,7 @@ void NetworkLibraryImplCros::UpdateRememberedServiceList(
// Request update for remembered network.
CrosRequestNetworkProfileEntryProperties(
profile_path,
- service_path.c_str(),
+ service_path,
base::Bind(&RememberedNetworkServiceUpdate, this));
}
}
@@ -1161,20 +1142,17 @@ void NetworkLibraryImplCros::UpdateRememberedServiceList(
// static
void NetworkLibraryImplCros::RememberedNetworkServiceUpdate(
void* object,
- const char* service_path,
+ const std::string& service_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- if (service_path) {
- if (!properties) {
- // Remembered network no longer exists.
- networklib->DeleteRememberedNetwork(std::string(service_path));
- } else {
- networklib->ParseRememberedNetwork(
- std::string(service_path), *properties);
- }
+ if (!properties) {
+ // Remembered network no longer exists.
+ networklib->DeleteRememberedNetwork(service_path);
+ } else {
+ networklib->ParseRememberedNetwork(service_path, *properties);
}
}
@@ -1225,9 +1203,9 @@ Network* NetworkLibraryImplCros::ParseRememberedNetwork(
<< " Server: " << vpn->server_hostname()
<< " Type: " << provider_type;
CrosRequestVirtualNetworkProperties(
- vpn->name().c_str(),
- vpn->server_hostname().c_str(),
- provider_type.c_str(),
+ vpn->name(),
+ vpn->server_hostname(),
+ provider_type,
base::Bind(&NetworkServiceUpdate, this));
}
}
@@ -1257,7 +1235,7 @@ void NetworkLibraryImplCros::UpdateNetworkDeviceList(const ListValue* devices) {
old_device_map.erase(found);
}
CrosRequestNetworkDeviceProperties(
- device_path.c_str(),
+ device_path,
base::Bind(&NetworkDeviceUpdate, this));
}
}
@@ -1273,19 +1251,17 @@ void NetworkLibraryImplCros::UpdateNetworkDeviceList(const ListValue* devices) {
// static
void NetworkLibraryImplCros::NetworkDeviceUpdate(
void* object,
- const char* device_path,
+ const std::string& device_path,
const base::DictionaryValue* properties) {
DCHECK(CrosLibrary::Get()->libcros_loaded());
NetworkLibraryImplCros* networklib =
static_cast<NetworkLibraryImplCros*>(object);
DCHECK(networklib);
- if (device_path) {
- if (!properties) {
- // device no longer exists.
- networklib->DeleteDevice(std::string(device_path));
- } else {
- networklib->ParseNetworkDevice(std::string(device_path), *properties);
- }
+ if (!properties) {
+ // device no longer exists.
+ networklib->DeleteDevice(device_path);
+ } else {
+ networklib->ParseNetworkDevice(device_path, *properties);
}
}

Powered by Google App Engine
This is Rietveld 408576698