diff options
author | ki.stfu <ki.stfu@gmail.com> | 2015-09-21 17:56:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-22 00:57:25 +0000 |
commit | d3709b5f91fe5d0d4accd7386da5a61743824b9e (patch) | |
tree | ffd618fc74a2588a96fc42be809f0dbf5ee0a93f | |
parent | 15b28d658c5a66655c19a7299f2e50fcd7b591c3 (diff) | |
download | chromium_src-d3709b5f91fe5d0d4accd7386da5a61743824b9e.zip chromium_src-d3709b5f91fe5d0d4accd7386da5a61743824b9e.tar.gz chromium_src-d3709b5f91fe5d0d4accd7386da5a61743824b9e.tar.bz2 |
Cleanup: Pass std::string as const reference from chromeos/
Passing std::string by reference can prevent extra copying of object.
BUG=367418
TEST=
R=zelidrag@chromium.org,derat@chromium.org,gauravsh@chromium.org
Review URL: https://codereview.chromium.org/1353323002
Cr-Commit-Position: refs/heads/master@{#350078}
-rw-r--r-- | chromeos/audio/audio_devices_pref_handler_impl.cc | 4 | ||||
-rw-r--r-- | chromeos/audio/audio_devices_pref_handler_impl.h | 4 | ||||
-rw-r--r-- | chromeos/dbus/fake_shill_manager_client.cc | 5 | ||||
-rw-r--r-- | chromeos/dbus/fake_shill_manager_client.h | 3 | ||||
-rw-r--r-- | chromeos/network/network_connection_handler.h | 4 | ||||
-rw-r--r-- | chromeos/network/onc/onc_certificate_importer_impl_unittest.cc | 5 | ||||
-rw-r--r-- | chromeos/network/shill_property_util.cc | 2 | ||||
-rw-r--r-- | chromeos/network/shill_property_util.h | 2 | ||||
-rw-r--r-- | chromeos/tools/onc_validator/onc_validator.cc | 4 |
9 files changed, 20 insertions, 13 deletions
diff --git a/chromeos/audio/audio_devices_pref_handler_impl.cc b/chromeos/audio/audio_devices_pref_handler_impl.cc index 4e72de6..17b5681 100644 --- a/chromeos/audio/audio_devices_pref_handler_impl.cc +++ b/chromeos/audio/audio_devices_pref_handler_impl.cc @@ -187,14 +187,14 @@ void AudioDevicesPrefHandlerImpl::SaveDevicesVolumePref() { } void AudioDevicesPrefHandlerImpl::MigrateDeviceMuteSettings( - std::string active_device) { + const std::string& active_device) { int old_mute = local_state_->GetInteger(prefs::kAudioMute); device_mute_settings_->SetInteger(active_device, old_mute); SaveDevicesMutePref(); } void AudioDevicesPrefHandlerImpl::MigrateDeviceVolumeSettings( - std::string active_device) { + const std::string& active_device) { double old_volume = local_state_->GetDouble(prefs::kAudioVolumePercent); device_volume_settings_->SetDouble(active_device, old_volume); SaveDevicesVolumePref(); diff --git a/chromeos/audio/audio_devices_pref_handler_impl.h b/chromeos/audio/audio_devices_pref_handler_impl.h index aeb9f3e..72dc335 100644 --- a/chromeos/audio/audio_devices_pref_handler_impl.h +++ b/chromeos/audio/audio_devices_pref_handler_impl.h @@ -64,8 +64,8 @@ class CHROMEOS_EXPORT AudioDevicesPrefHandlerImpl // previous global pref value to the new per device pref value for the // current active device. If a previous global setting doesn't exist, we'll // use default values of mute = off and volume = 75%. - void MigrateDeviceMuteSettings(std::string active_device); - void MigrateDeviceVolumeSettings(std::string active_device); + void MigrateDeviceMuteSettings(const std::string& active_device); + void MigrateDeviceVolumeSettings(const std::string& active_device); // Notifies the AudioPrefObserver for audio policy pref changes. void NotifyAudioPolicyChange(); diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc index 337041b..ca7c6a5 100644 --- a/chromeos/dbus/fake_shill_manager_client.cc +++ b/chromeos/dbus/fake_shill_manager_client.cc @@ -1115,8 +1115,9 @@ bool FakeShillManagerClient::ParseOption(const std::string& arg0, return SetInitialNetworkState(arg0, arg1); } -bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, - std::string state_arg) { +bool FakeShillManagerClient::SetInitialNetworkState( + std::string type_arg, + const std::string& state_arg) { int state_arg_as_int = -1; base::StringToInt(state_arg, &state_arg_as_int); diff --git a/chromeos/dbus/fake_shill_manager_client.h b/chromeos/dbus/fake_shill_manager_client.h index 313a2d4..f677350 100644 --- a/chromeos/dbus/fake_shill_manager_client.h +++ b/chromeos/dbus/fake_shill_manager_client.h @@ -126,7 +126,8 @@ class CHROMEOS_EXPORT FakeShillManagerClient // {wifi,cellular,etc}={on,off,disabled,none} - sets initial state for type void ParseCommandLineSwitch(); bool ParseOption(const std::string& arg0, const std::string& arg1); - bool SetInitialNetworkState(std::string type_arg, std::string state_arg); + bool SetInitialNetworkState(std::string type_arg, + const std::string& state_arg); std::string GetInitialStateForType(const std::string& type, bool* enabled); diff --git a/chromeos/network/network_connection_handler.h b/chromeos/network/network_connection_handler.h index ddadf7a..8b4e93f 100644 --- a/chromeos/network/network_connection_handler.h +++ b/chromeos/network/network_connection_handler.h @@ -193,7 +193,11 @@ class CHROMEOS_EXPORT NetworkConnectionHandler const std::string& error_name, const std::string& error_message); + // Note: |service_path| is passed by value here, because in some cases + // the value may be located in the map and then it can be deleted, producing + // a reference to invalid memory. void CheckPendingRequest(const std::string service_path); + void CheckAllPendingRequests(); // Notify caller and observers that the connect request succeeded. diff --git a/chromeos/network/onc/onc_certificate_importer_impl_unittest.cc b/chromeos/network/onc/onc_certificate_importer_impl_unittest.cc index 35ff424..caa5ed8 100644 --- a/chromeos/network/onc/onc_certificate_importer_impl_unittest.cc +++ b/chromeos/network/onc/onc_certificate_importer_impl_unittest.cc @@ -97,7 +97,8 @@ class ONCCertificateImporterImplTest : public testing::Test { web_trust_certificates_ = onc_trusted_certificates; } - void AddCertificatesFromFile(std::string filename, bool expected_success) { + void AddCertificatesFromFile(const std::string& filename, + bool expected_success) { scoped_ptr<base::DictionaryValue> onc = test_utils::ReadTestDictionary(filename); scoped_ptr<base::Value> certificates_value; @@ -122,7 +123,7 @@ class ONCCertificateImporterImplTest : public testing::Test { private_list_ = ListCertsInPrivateSlot(); } - void AddCertificateFromFile(std::string filename, + void AddCertificateFromFile(const std::string& filename, net::CertType expected_type, std::string* guid) { std::string guid_temporary; diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc index 30a6925..c5cafc8 100644 --- a/chromeos/network/shill_property_util.cc +++ b/chromeos/network/shill_property_util.cc @@ -61,7 +61,7 @@ bool CopyStringFromDictionary(const base::DictionaryValue& source, } // namespace -void SetSSID(const std::string ssid, base::DictionaryValue* properties) { +void SetSSID(const std::string& ssid, base::DictionaryValue* properties) { std::string hex_ssid = base::HexEncode(ssid.c_str(), ssid.size()); properties->SetStringWithoutPathExpansion(shill::kWifiHexSsid, hex_ssid); } diff --git a/chromeos/network/shill_property_util.h b/chromeos/network/shill_property_util.h index cc9da9c..f585da4 100644 --- a/chromeos/network/shill_property_util.h +++ b/chromeos/network/shill_property_util.h @@ -22,7 +22,7 @@ class NetworkUIData; namespace shill_property_util { // Sets the |ssid| in |properties|. -CHROMEOS_EXPORT void SetSSID(const std::string ssid, +CHROMEOS_EXPORT void SetSSID(const std::string& ssid, base::DictionaryValue* properties); // Returns the SSID from |properties| in UTF-8 encoding. If |verbose_logging| is diff --git a/chromeos/tools/onc_validator/onc_validator.cc b/chromeos/tools/onc_validator/onc_validator.cc index 84a9220..14ed891 100644 --- a/chromeos/tools/onc_validator/onc_validator.cc +++ b/chromeos/tools/onc_validator/onc_validator.cc @@ -82,7 +82,7 @@ void PrintHelp() { kStatusArgumentError); } -scoped_ptr<base::DictionaryValue> ReadDictionary(std::string filename) { +scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) { base::FilePath path(filename); JSONFileValueDeserializer deserializer(path); deserializer.set_allow_trailing_comma(true); @@ -151,7 +151,7 @@ int main(int argc, const char* argv[]) { chromeos::onc::Validator::Result result; validator.ValidateAndRepairObject(signature, *onc_object, &result); - switch(result) { + switch (result) { case chromeos::onc::Validator::VALID: return kStatusValid; case chromeos::onc::Validator::VALID_WITH_WARNINGS: |