Fix clang-tidy performance warnings in shill.
am: ec5aa476af
Change-Id: I6985e582b5aa76b82796e80e855b5edfbd24c7f1
diff --git a/connection_health_checker.cc b/connection_health_checker.cc
index 9291e57..7626e45 100644
--- a/connection_health_checker.cc
+++ b/connection_health_checker.cc
@@ -127,7 +127,7 @@
return health_check_in_progress_;
}
-void ConnectionHealthChecker::AddRemoteIP(IPAddress ip) {
+void ConnectionHealthChecker::AddRemoteIP(const IPAddress& ip) {
remote_ips_->AddUnique(ip);
}
@@ -206,7 +206,7 @@
num_tx_queue_polling_attempts_ = 0;
}
-void ConnectionHealthChecker::SetConnection(ConnectionRefPtr connection) {
+void ConnectionHealthChecker::SetConnection(const ConnectionRefPtr& connection) {
SLOG(connection_.get(), 3) << __func__;
connection_ = connection;
tcp_connection_.reset(new AsyncConnection(connection_->interface_name(),
diff --git a/connection_health_checker.h b/connection_health_checker.h
index 791d7a5..6208fa5 100644
--- a/connection_health_checker.h
+++ b/connection_health_checker.h
@@ -77,12 +77,12 @@
// Name resolution can fail in conditions -(1)- and -(2)-. Add an IP address
// to attempt the TCP connection with.
- virtual void AddRemoteIP(IPAddress ip);
+ virtual void AddRemoteIP(const IPAddress& ip);
// Change the associated Connection on the Device.
// This will restart any ongoing health check. Any ongoing DNS query will be
// dropped (not restarted).
- virtual void SetConnection(ConnectionRefPtr connection);
+ virtual void SetConnection(const ConnectionRefPtr& connection);
// Start a connection health check. The health check involves one or more
// attempts at establishing and using a TCP connection. |result_callback_| is
diff --git a/connection_health_checker_unittest.cc b/connection_health_checker_unittest.cc
index 3a8edaf..09ca059 100644
--- a/connection_health_checker_unittest.cc
+++ b/connection_health_checker_unittest.cc
@@ -256,7 +256,7 @@
// This only works if GetSocketInfo is called with kProxyFD.
// If no matching sock_info is provided (Does not belong to proxy socket),
// GetSocketInfo will (correctly) return false.
- void ExpectGetSocketInfoReturns(SocketInfo sock_info) {
+ void ExpectGetSocketInfoReturns(const SocketInfo& sock_info) {
vector<SocketInfo> info_list;
info_list.push_back(sock_info);
EXPECT_CALL(*socket_, GetSockName(kProxyFD, _, _))
diff --git a/connection_info_unittest.cc b/connection_info_unittest.cc
index c1b182d..09634d1 100644
--- a/connection_info_unittest.cc
+++ b/connection_info_unittest.cc
@@ -75,7 +75,7 @@
ByteString(kIPAddress4, sizeof(kIPAddress4))),
kPort4);
- ConnectionInfo info_copy(info);
+ const ConnectionInfo& info_copy(info);
ExpectConnectionInfoEqual(info, info_copy);
}
@@ -96,7 +96,7 @@
ByteString(kIPAddress4, sizeof(kIPAddress4))),
kPort4);
- ConnectionInfo info_copy = info;
+ const ConnectionInfo& info_copy = info;
ExpectConnectionInfoEqual(info, info_copy);
}
diff --git a/connection_unittest.cc b/connection_unittest.cc
index db4ee3e..7fe2556 100644
--- a/connection_unittest.cc
+++ b/connection_unittest.cc
@@ -123,7 +123,7 @@
connection_ = nullptr;
}
- void ReplaceSingletons(ConnectionRefPtr connection) {
+ void ReplaceSingletons(const ConnectionRefPtr& connection) {
#if !defined(__ANDROID__)
connection->resolver_ = &resolver_;
#else
@@ -141,21 +141,21 @@
ip6config_->UpdateProperties(ipv6_properties_, true);
}
- bool PinHostRoute(ConnectionRefPtr connection,
- const IPAddress trusted_ip,
- const IPAddress gateway) {
+ bool PinHostRoute(const ConnectionRefPtr& connection,
+ const IPAddress& trusted_ip,
+ const IPAddress& gateway) {
return connection->PinHostRoute(trusted_ip, gateway);
}
- const IPAddress& GetLocalAddress(ConnectionRefPtr connection) {
+ const IPAddress& GetLocalAddress(const ConnectionRefPtr& connection) {
return connection->local_;
}
- const IPAddress& GetGatewayAddress(ConnectionRefPtr connection) {
+ const IPAddress& GetGatewayAddress(const ConnectionRefPtr& connection) {
return connection->gateway_;
}
- bool GetHasBroadcastDomain(ConnectionRefPtr connection) {
+ bool GetHasBroadcastDomain(const ConnectionRefPtr& connection) {
return connection->has_broadcast_domain_;
}
diff --git a/crypto_util_proxy_unittest.cc b/crypto_util_proxy_unittest.cc
index d942f98..8e7e398 100644
--- a/crypto_util_proxy_unittest.cc
+++ b/crypto_util_proxy_unittest.cc
@@ -105,7 +105,7 @@
pid_t HandleStartInMinijailWithPipes(
const tracked_objects::Location& /* spawn_source */,
const base::FilePath& /* program */,
- vector<string> /* program_args */,
+ const vector<string>& /* program_args */,
const std::string& /* run_as_user */,
const std::string& /* run_as_group */,
uint64_t /* capabilities_mask */,
diff --git a/dbus/chromeos_manager_dbus_adaptor.cc b/dbus/chromeos_manager_dbus_adaptor.cc
index 0aea07e..0762ad6 100644
--- a/dbus/chromeos_manager_dbus_adaptor.cc
+++ b/dbus/chromeos_manager_dbus_adaptor.cc
@@ -49,7 +49,7 @@
ChromeosManagerDBusAdaptor::ChromeosManagerDBusAdaptor(
const scoped_refptr<dbus::Bus>& adaptor_bus,
- const scoped_refptr<dbus::Bus> proxy_bus,
+ const scoped_refptr<dbus::Bus>& proxy_bus,
Manager* manager)
: org::chromium::flimflam::ManagerAdaptor(this),
ChromeosDBusAdaptor(adaptor_bus, kPath),
diff --git a/dbus/chromeos_manager_dbus_adaptor.h b/dbus/chromeos_manager_dbus_adaptor.h
index aa6278f..1ab4caf 100644
--- a/dbus/chromeos_manager_dbus_adaptor.h
+++ b/dbus/chromeos_manager_dbus_adaptor.h
@@ -48,7 +48,7 @@
static const char kPath[];
ChromeosManagerDBusAdaptor(const scoped_refptr<dbus::Bus>& adaptor_bus,
- const scoped_refptr<dbus::Bus> proxy_bus,
+ const scoped_refptr<dbus::Bus>& proxy_bus,
Manager* manager);
~ChromeosManagerDBusAdaptor() override;
diff --git a/dbus/dbus_service_watcher_factory.cc b/dbus/dbus_service_watcher_factory.cc
index 2493703..3036add 100644
--- a/dbus/dbus_service_watcher_factory.cc
+++ b/dbus/dbus_service_watcher_factory.cc
@@ -33,7 +33,7 @@
}
ChromeosDBusServiceWatcher* DBusServiceWatcherFactory::CreateDBusServiceWatcher(
- scoped_refptr<dbus::Bus> bus, const std::string& connection_name,
+ const scoped_refptr<dbus::Bus>& bus, const std::string& connection_name,
const base::Closure& on_connection_vanish) {
return new ChromeosDBusServiceWatcher(bus, connection_name,
on_connection_vanish);
diff --git a/dbus/dbus_service_watcher_factory.h b/dbus/dbus_service_watcher_factory.h
index f005d16..14bffe8 100644
--- a/dbus/dbus_service_watcher_factory.h
+++ b/dbus/dbus_service_watcher_factory.h
@@ -36,7 +36,7 @@
static DBusServiceWatcherFactory* GetInstance();
virtual ChromeosDBusServiceWatcher* CreateDBusServiceWatcher(
- scoped_refptr<dbus::Bus> bus, const std::string& connection_name,
+ const scoped_refptr<dbus::Bus>& bus, const std::string& connection_name,
const base::Closure& on_connection_vanish);
protected:
diff --git a/dbus/mock_dbus_service_watcher_factory.h b/dbus/mock_dbus_service_watcher_factory.h
index 00194f0..ebf8126 100644
--- a/dbus/mock_dbus_service_watcher_factory.h
+++ b/dbus/mock_dbus_service_watcher_factory.h
@@ -30,7 +30,7 @@
MOCK_METHOD3(
CreateDBusServiceWatcher,
- ChromeosDBusServiceWatcher*(scoped_refptr<dbus::Bus> bus,
+ ChromeosDBusServiceWatcher*(const scoped_refptr<dbus::Bus>& bus,
const std::string& connection_name,
const base::Closure& on_connection_vanish));
diff --git a/device_unittest.cc b/device_unittest.cc
index 82da3fe..e7be6f6 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -211,11 +211,11 @@
device_->OnIPConfigExpired(ipconfig);
}
- void SelectService(const ServiceRefPtr service) {
+ void SelectService(const ServiceRefPtr& service) {
device_->SelectService(service);
}
- void SetConnection(ConnectionRefPtr connection) {
+ void SetConnection(const ConnectionRefPtr& connection) {
device_->connection_ = connection;
}
@@ -2666,7 +2666,7 @@
return true;
}
- bool ExpectByteCounts(DeviceRefPtr device,
+ bool ExpectByteCounts(const DeviceRefPtr& device,
int64_t expected_rx, int64_t expected_tx) {
int64_t actual_rx = device->GetReceiveByteCount();
int64_t actual_tx = device->GetTransmitByteCount();
@@ -2675,7 +2675,7 @@
return expected_rx == actual_rx && expected_tx == actual_tx;
}
- void ExpectSavedCounts(DeviceRefPtr device,
+ void ExpectSavedCounts(const DeviceRefPtr& device,
int64_t expected_rx, int64_t expected_tx) {
EXPECT_CALL(storage_,
SetUint64(_, Device::kStorageReceiveByteCount, expected_rx))
diff --git a/dhcp/dhcpv4_config.cc b/dhcp/dhcpv4_config.cc
index 1d3411f..d62a743 100644
--- a/dhcp/dhcpv4_config.cc
+++ b/dhcp/dhcpv4_config.cc
@@ -343,7 +343,7 @@
properties->address_family = IPAddress::kFamilyIPv4;
string classless_static_routes;
bool default_gateway_parse_error = false;
- for (const auto it : configuration.properties()) {
+ for (const auto& it : configuration.properties()) {
const string& key = it.first;
const brillo::Any& value = it.second;
SLOG(nullptr, 2) << "Processing key: " << key;
diff --git a/dhcp/dhcpv4_config_unittest.cc b/dhcp/dhcpv4_config_unittest.cc
index ebe607a..7ac534a 100644
--- a/dhcp/dhcpv4_config_unittest.cc
+++ b/dhcp/dhcpv4_config_unittest.cc
@@ -93,7 +93,7 @@
config_->process_manager_ = &process_manager_;
}
- bool StartInstance(DHCPv4ConfigRefPtr config) {
+ bool StartInstance(const DHCPv4ConfigRefPtr& config) {
return config->Start();
}
@@ -109,7 +109,7 @@
const string& vendorclass,
const string& lease_suffix,
bool arp_gateway);
- void StopRunningConfigAndExpect(DHCPv4ConfigRefPtr config,
+ void StopRunningConfigAndExpect(const DHCPv4ConfigRefPtr& config,
bool lease_file_exists);
protected:
@@ -222,7 +222,7 @@
return config;
}
-void DHCPv4ConfigTest::StopRunningConfigAndExpect(DHCPv4ConfigRefPtr config,
+void DHCPv4ConfigTest::StopRunningConfigAndExpect(const DHCPv4ConfigRefPtr& config,
bool lease_file_exists) {
ScopedMockLog log;
// We use a non-zero exit status so that we get the log message.
diff --git a/manager.cc b/manager.cc
index 9ff3d4e..fb77e18 100644
--- a/manager.cc
+++ b/manager.cc
@@ -1662,8 +1662,8 @@
}
#endif // DISABLE_WIFI
-int Manager::CalcConnectionId(std::string gateway_ip,
- std::string gateway_mac) {
+int Manager::CalcConnectionId(const std::string& gateway_ip,
+ const std::string& gateway_mac) {
return static_cast<int>(std::hash<std::string>()(gateway_ip + gateway_mac +
std::to_string(props_.connection_id_salt)));
}
@@ -2532,8 +2532,8 @@
return nullptr;
}
-void Manager::SetupServiceInProfile(ServiceRefPtr service,
- ProfileRefPtr profile,
+void Manager::SetupServiceInProfile(const ServiceRefPtr& service,
+ const ProfileRefPtr& profile,
const KeyValueStore& args,
Error* error) {
service->SetProfile(profile);
@@ -2672,7 +2672,7 @@
#endif // DISABLE_WIMAX
}
-DeviceRefPtr Manager::GetDeviceConnectedToService(ServiceRefPtr service) {
+DeviceRefPtr Manager::GetDeviceConnectedToService(const ServiceRefPtr& service) {
for (DeviceRefPtr device : devices_) {
if (device->IsConnectedToService(service)) {
return device;
diff --git a/manager.h b/manager.h
index 1415c88..4b6f262 100644
--- a/manager.h
+++ b/manager.h
@@ -505,7 +505,7 @@
// Calculate connection identifier, which is hash of salt value, gateway IP
// address, and gateway MAC address.
- int CalcConnectionId(std::string gateway_ip, std::string gateway_mac);
+ int CalcConnectionId(const std::string& gateway_ip, const std::string& gateway_mac);
// Report the number of services associated with given connection
// |connection_id|.
@@ -734,8 +734,8 @@
// the resulting configuration to |profile|. This method is useful
// when copying a service configuration from one profile to another,
// or writing a newly created service config to a specific profile.
- static void SetupServiceInProfile(ServiceRefPtr service,
- ProfileRefPtr profile,
+ static void SetupServiceInProfile(const ServiceRefPtr& service,
+ const ProfileRefPtr& profile,
const KeyValueStore& args,
Error* error);
@@ -787,7 +787,7 @@
power_manager_.reset(power_manager);
}
- DeviceRefPtr GetDeviceConnectedToService(ServiceRefPtr service);
+ DeviceRefPtr GetDeviceConnectedToService(const ServiceRefPtr& service);
void DeregisterDeviceByLinkName(const std::string& link_name);
diff --git a/manager_unittest.cc b/manager_unittest.cc
index fbed967..2de1d52 100644
--- a/manager_unittest.cc
+++ b/manager_unittest.cc
@@ -202,9 +202,9 @@
auto devices = manager()->FilterByTechnology(tech);
return (devices.size() == 1 && devices[0].get() == device.get());
}
- bool ServiceOrderIs(ServiceRefPtr svc1, ServiceRefPtr svc2);
+ bool ServiceOrderIs(const ServiceRefPtr& svc1, const ServiceRefPtr& svc2);
- void AdoptProfile(Manager* manager, ProfileRefPtr profile) {
+ void AdoptProfile(Manager* manager, const ProfileRefPtr& profile) {
manager->profiles_.push_back(profile);
}
@@ -518,7 +518,7 @@
const char ManagerTest::TerminationActionTest::kActionName[] = "action";
-bool ManagerTest::ServiceOrderIs(ServiceRefPtr svc0, ServiceRefPtr svc1) {
+bool ManagerTest::ServiceOrderIs(const ServiceRefPtr& svc0, const ServiceRefPtr& svc1) {
if (!manager()->sort_services_task_.IsCancelled()) {
manager()->SortServicesTask();
}
diff --git a/mock_connection_health_checker.h b/mock_connection_health_checker.h
index 062c6bb..fc2a399 100644
--- a/mock_connection_health_checker.h
+++ b/mock_connection_health_checker.h
@@ -35,7 +35,7 @@
~MockConnectionHealthChecker() override;
MOCK_METHOD1(AddRemoteURL, void(const std::string& url_string));
- MOCK_METHOD1(AddRemoteIP, void(IPAddress ip));
+ MOCK_METHOD1(AddRemoteIP, void(const IPAddress& ip));
MOCK_METHOD0(Start, void());
MOCK_METHOD0(Stop, void());
MOCK_CONST_METHOD0(health_check_in_progress, bool());
diff --git a/net/attribute_list.cc b/net/attribute_list.cc
index 6065c49..e0844a7 100644
--- a/net/attribute_list.cc
+++ b/net/attribute_list.cc
@@ -38,7 +38,7 @@
namespace shill {
bool AttributeList::CreateAttribute(
- int id, AttributeList::NewFromIdMethod factory) {
+ int id, const AttributeList::NewFromIdMethod& factory) {
if (ContainsKey(attributes_, id)) {
VLOG(7) << "Trying to re-add attribute " << id << ", not overwriting";
return true;
@@ -300,7 +300,7 @@
return true;
}
-bool AttributeList::SetStringAttributeValue(int id, string value) {
+bool AttributeList::SetStringAttributeValue(int id, const string& value) {
NetlinkAttribute* attribute = GetAttribute(id);
if (!attribute)
return false;
@@ -361,7 +361,7 @@
return true;
}
-bool AttributeList::SetRawAttributeValue(int id, ByteString value) {
+bool AttributeList::SetRawAttributeValue(int id, const ByteString& value) {
NetlinkAttribute* attribute = GetAttribute(id);
if (!attribute)
return false;
diff --git a/net/attribute_list.h b/net/attribute_list.h
index 18f325b..6d1a45d 100644
--- a/net/attribute_list.h
+++ b/net/attribute_list.h
@@ -49,7 +49,7 @@
// Instantiates an NetlinkAttribute of the appropriate type from |id|,
// and adds it to |attributes_|.
- bool CreateAttribute(int id, NewFromIdMethod factory);
+ bool CreateAttribute(int id, const NewFromIdMethod& factory);
// Helper function for creating control attribute.
bool CreateControlAttribute(int id);
@@ -117,7 +117,7 @@
bool CreateStringAttribute(int id, const char* id_string);
// SSID attributes are derived from string attributes.
bool CreateSsidAttribute(int id, const char* id_string);
- bool SetStringAttributeValue(int id, std::string value);
+ bool SetStringAttributeValue(int id, const std::string& value);
bool GetStringAttributeValue(int id, std::string* value) const;
bool CreateNestedAttribute(int id, const char* id_string);
@@ -129,7 +129,7 @@
bool CreateRawAttribute(int id, const char* id_string);
// |value| should point to the data (after the |nlattr| header, if there is
// one).
- bool SetRawAttributeValue(int id, ByteString value);
+ bool SetRawAttributeValue(int id, const ByteString& value);
bool GetRawAttributeValue(int id, ByteString* output) const;
// This retrieves a string from any kind of attribute.
diff --git a/net/event_history.cc b/net/event_history.cc
index cd269f7..c099285 100644
--- a/net/event_history.cc
+++ b/net/event_history.cc
@@ -50,7 +50,7 @@
return strings;
}
-void EventHistory::RecordEventInternal(Timestamp now) {
+void EventHistory::RecordEventInternal(const Timestamp& now) {
events_.push_back(now);
while (!events_.empty() && max_events_specified_ &&
(events_.size() > static_cast<size_t>(max_events_saved_))) {
diff --git a/net/event_history.h b/net/event_history.h
index 615262d..9b2ac87 100644
--- a/net/event_history.h
+++ b/net/event_history.h
@@ -82,7 +82,7 @@
friend class ServiceTest; // RecordEventInternal, time_
friend class WakeOnWiFiTest; // time_
- void RecordEventInternal(Timestamp now);
+ void RecordEventInternal(const Timestamp& now);
void ExpireEventsBeforeInternal(int seconds_ago, Timestamp now,
ClockType clock_type);
diff --git a/net/event_history_unittest.cc b/net/event_history_unittest.cc
index fe4eb15..80c8f54 100644
--- a/net/event_history_unittest.cc
+++ b/net/event_history_unittest.cc
@@ -61,18 +61,18 @@
deque<Timestamp>* GetEvents() { return &event_history_->events_; }
- void RecordEvent(Timestamp now) {
+ void RecordEvent(const Timestamp& now) {
EXPECT_CALL(time_, GetNow()).WillOnce(Return(now));
event_history_->RecordEvent();
}
- void ExpireEventsBefore(int seconds_ago, Timestamp now,
+ void ExpireEventsBefore(int seconds_ago, const Timestamp& now,
EventHistory::ClockType clock_type) {
EXPECT_CALL(time_, GetNow()).WillOnce(Return(now));
event_history_->ExpireEventsBefore(seconds_ago, clock_type);
}
- void RecordEventAndExpireEventsBefore(int seconds_ago, Timestamp now,
+ void RecordEventAndExpireEventsBefore(int seconds_ago, const Timestamp& now,
EventHistory::ClockType clock_type) {
EXPECT_CALL(time_, GetNow()).WillOnce(Return(now));
event_history_->RecordEventAndExpireEventsBefore(seconds_ago, clock_type);
@@ -91,7 +91,7 @@
int CountEventsWithinInterval(int seconds_ago,
EventHistory::ClockType clock_type,
- Timestamp now) {
+ const Timestamp& now) {
EXPECT_CALL(time_, GetNow()).WillOnce(Return(now));
return event_history_->CountEventsWithinInterval(seconds_ago, clock_type);
}
diff --git a/net/netlink_attribute.cc b/net/netlink_attribute.cc
index 3248a49..2d3d195 100644
--- a/net/netlink_attribute.cc
+++ b/net/netlink_attribute.cc
@@ -356,7 +356,7 @@
return false;
}
-bool NetlinkAttribute::SetStringValue(string value) {
+bool NetlinkAttribute::SetStringValue(const string& value) {
LOG(ERROR) << "Attribute is not of type 'String'";
return false;
}
@@ -382,7 +382,7 @@
return false;
}
-bool NetlinkAttribute::SetRawValue(const ByteString new_value) {
+bool NetlinkAttribute::SetRawValue(const ByteString& new_value) {
LOG(ERROR) << "Attribute is not of type 'Raw'";
return false;
}
@@ -745,7 +745,7 @@
return true;
}
-bool NetlinkStringAttribute::SetStringValue(const string new_value) {
+bool NetlinkStringAttribute::SetStringValue(const string& new_value) {
value_ = new_value;
has_a_value_ = true;
return true;
@@ -1049,7 +1049,7 @@
return true;
}
-bool NetlinkRawAttribute::SetRawValue(const ByteString new_value) {
+bool NetlinkRawAttribute::SetRawValue(const ByteString& new_value) {
data_ = new_value;
has_a_value_ = true;
return true;
diff --git a/net/netlink_attribute.h b/net/netlink_attribute.h
index b1ab150..2736c64 100644
--- a/net/netlink_attribute.h
+++ b/net/netlink_attribute.h
@@ -90,7 +90,7 @@
virtual bool SetFlagValue(bool value);
virtual bool GetStringValue(std::string* value) const;
- virtual bool SetStringValue(const std::string value);
+ virtual bool SetStringValue(const std::string& value);
virtual bool GetNestedAttributeList(AttributeListRefPtr* value);
virtual bool ConstGetNestedAttributeList(
@@ -98,7 +98,7 @@
virtual bool SetNestedHasAValue();
virtual bool GetRawValue(ByteString* value) const;
- virtual bool SetRawValue(const ByteString value);
+ virtual bool SetRawValue(const ByteString& value);
// Prints the attribute info -- for debugging.
virtual void Print(int log_level, int indent) const;
@@ -243,7 +243,7 @@
: NetlinkAttribute(id, id_string, kType, kMyTypeString) {}
virtual bool InitFromValue(const ByteString& data);
virtual bool GetStringValue(std::string* value) const;
- virtual bool SetStringValue(const std::string new_value);
+ virtual bool SetStringValue(const std::string& new_value);
virtual bool ToString(std::string* value) const;
virtual ByteString Encode() const;
std::string value() const { return value_; }
@@ -292,7 +292,7 @@
struct NestedData {
typedef base::Callback<bool (AttributeList* list, size_t id,
const std::string& attribute_name,
- ByteString data)> AttributeParser;
+ const ByteString& data)> AttributeParser;
typedef std::map<size_t, NestedData> NestedDataMap;
NestedData();
@@ -369,7 +369,7 @@
// Gets the value of the data (the header is not stored).
virtual bool GetRawValue(ByteString* value) const;
// Should set the value of the data (not the attribute header).
- virtual bool SetRawValue(const ByteString value);
+ virtual bool SetRawValue(const ByteString& value);
virtual bool ToString(std::string* value) const;
virtual ByteString Encode() const;
diff --git a/net/netlink_message.cc b/net/netlink_message.cc
index 752f098..a4469a3 100644
--- a/net/netlink_message.cc
+++ b/net/netlink_message.cc
@@ -267,7 +267,7 @@
//
bool NetlinkMessageFactory::AddFactoryMethod(uint16_t message_type,
- FactoryMethod factory) {
+ const FactoryMethod& factory) {
if (ContainsKey(factories_, message_type)) {
LOG(WARNING) << "Message type " << message_type << " already exists.";
return false;
diff --git a/net/netlink_message.h b/net/netlink_message.h
index 5a87954..37e84c7 100644
--- a/net/netlink_message.h
+++ b/net/netlink_message.h
@@ -243,7 +243,7 @@
// Adds a message factory for a specific message_type. Intended to be used
// at initialization.
- bool AddFactoryMethod(uint16_t message_type, FactoryMethod factory);
+ bool AddFactoryMethod(uint16_t message_type, const FactoryMethod& factory);
// Ownership of the message is passed to the caller and, as such, he should
// delete it.
diff --git a/net/nl80211_attribute.cc b/net/nl80211_attribute.cc
index 89600c1..54b5877 100644
--- a/net/nl80211_attribute.cc
+++ b/net/nl80211_attribute.cc
@@ -123,7 +123,7 @@
bool Nl80211AttributeBss::ParseInformationElements(
AttributeList* attribute_list, size_t id, const string& attribute_name,
- ByteString data) {
+ const ByteString& data) {
if (!attribute_list) {
LOG(ERROR) << "NULL |attribute_list| parameter";
return false;
diff --git a/net/nl80211_attribute.h b/net/nl80211_attribute.h
index b9a793a..71c0e7a 100644
--- a/net/nl80211_attribute.h
+++ b/net/nl80211_attribute.h
@@ -581,7 +581,7 @@
static bool ParseInformationElements(AttributeList* attribute_list,
size_t id,
const std::string& attribute_name,
- ByteString data);
+ const ByteString& data);
DISALLOW_COPY_AND_ASSIGN(Nl80211AttributeBss);
};
diff --git a/net/rtnl_message_unittest.cc b/net/rtnl_message_unittest.cc
index 3e74d93..9824526 100644
--- a/net/rtnl_message_unittest.cc
+++ b/net/rtnl_message_unittest.cc
@@ -389,10 +389,10 @@
int interface_index,
unsigned int flags,
unsigned int change,
- ByteString address,
- ByteString name,
+ const ByteString& address,
+ const ByteString& name,
uint32_t mtu,
- ByteString qdisc,
+ const ByteString& qdisc,
int oper_state) {
RTNLMessage msg;
EXPECT_TRUE(msg.Decode(packet));
diff --git a/scope_logger.cc b/scope_logger.cc
index 815503f..a5b515b 100644
--- a/scope_logger.cc
+++ b/scope_logger.cc
@@ -154,7 +154,7 @@
}
void ScopeLogger::RegisterScopeEnableChangedCallback(
- Scope scope, ScopeEnableChangedCallback callback) {
+ Scope scope, const ScopeEnableChangedCallback& callback) {
CHECK_GE(scope, 0);
CHECK_LT(scope, kNumScopes);
log_scope_callbacks_[scope].push_back(callback);
diff --git a/scope_logger.h b/scope_logger.h
index 3d5a817..4432097 100644
--- a/scope_logger.h
+++ b/scope_logger.h
@@ -116,7 +116,7 @@
// Register for log scope enable/disable state changes for |scope|.
void RegisterScopeEnableChangedCallback(
- Scope scope, ScopeEnableChangedCallback callback);
+ Scope scope, const ScopeEnableChangedCallback& callback);
// Sets the verbose level for all scopes to |verbose_level|.
void set_verbose_level(int verbose_level) { verbose_level_ = verbose_level; }
diff --git a/service.cc b/service.cc
index 256ec55..94bb99e 100644
--- a/service.cc
+++ b/service.cc
@@ -656,7 +656,7 @@
}
void Service::Configure(const KeyValueStore& args, Error* error) {
- for (const auto it : args.properties()) {
+ for (const auto& it : args.properties()) {
if (it.second.IsTypeCompatible<bool>()) {
if (ContainsKey(parameters_ignored_for_configure_, it.first)) {
SLOG(this, 5) << "Ignoring bool property: " << it.first;
@@ -1061,8 +1061,8 @@
// static
bool Service::Compare(Manager* manager,
- ServiceRefPtr a,
- ServiceRefPtr b,
+ const ServiceRefPtr& a,
+ const ServiceRefPtr& b,
bool compare_connectivity_state,
const vector<Technology::Identifier>& tech_order,
const char** reason) {
diff --git a/service.h b/service.h
index e35d17d..2cfe7ad 100644
--- a/service.h
+++ b/service.h
@@ -448,8 +448,8 @@
// difference. |reason| is populated with the exact criteria used for the
// ultimate comparison.
static bool Compare(Manager* manager,
- ServiceRefPtr a,
- ServiceRefPtr b,
+ const ServiceRefPtr& a,
+ const ServiceRefPtr& b,
bool compare_connectivity_state,
const std::vector<Technology::Identifier>& tech_order,
const char** reason);
@@ -686,9 +686,9 @@
friend class WiFiServiceTest;
friend class WiMaxProviderTest;
friend class WiMaxServiceTest;
- friend void TestCommonPropertyChanges(ServiceRefPtr, ServiceMockAdaptor*);
- friend void TestCustomSetterNoopChange(ServiceRefPtr, MockManager*);
- friend void TestNamePropertyChange(ServiceRefPtr, ServiceMockAdaptor*);
+ friend void TestCommonPropertyChanges(const ServiceRefPtr&, ServiceMockAdaptor*);
+ friend void TestCustomSetterNoopChange(const ServiceRefPtr&, MockManager*);
+ friend void TestNamePropertyChange(const ServiceRefPtr&, ServiceMockAdaptor*);
FRIEND_TEST(AllMockServiceTest, AutoConnectWithFailures);
FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier);
FRIEND_TEST(CellularServiceTest, IsAutoConnectable);
diff --git a/service_property_change_notifier.cc b/service_property_change_notifier.cc
index 97888c1..2e9d704 100644
--- a/service_property_change_notifier.cc
+++ b/service_property_change_notifier.cc
@@ -34,7 +34,7 @@
ServicePropertyChangeNotifier::~ServicePropertyChangeNotifier() {}
void ServicePropertyChangeNotifier::AddBoolPropertyObserver(
- const string& name, BoolAccessor accessor) {
+ const string& name, const BoolAccessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<bool>(
accessor,
@@ -44,7 +44,7 @@
}
void ServicePropertyChangeNotifier::AddUint8PropertyObserver(
- const string& name, Uint8Accessor accessor) {
+ const string& name, const Uint8Accessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<uint8_t>(
accessor,
@@ -54,7 +54,7 @@
}
void ServicePropertyChangeNotifier::AddUint16PropertyObserver(
- const string& name, Uint16Accessor accessor) {
+ const string& name, const Uint16Accessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<uint16_t>(
accessor,
@@ -64,7 +64,7 @@
}
void ServicePropertyChangeNotifier::AddUint16sPropertyObserver(
- const string& name, Uint16sAccessor accessor) {
+ const string& name, const Uint16sAccessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<Uint16s>(
accessor,
@@ -74,7 +74,7 @@
}
void ServicePropertyChangeNotifier::AddUintPropertyObserver(
- const string& name, Uint32Accessor accessor) {
+ const string& name, const Uint32Accessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<uint32_t>(
accessor,
@@ -84,7 +84,7 @@
}
void ServicePropertyChangeNotifier::AddIntPropertyObserver(
- const string& name, Int32Accessor accessor) {
+ const string& name, const Int32Accessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<int32_t>(
accessor,
@@ -94,7 +94,7 @@
}
void ServicePropertyChangeNotifier::AddRpcIdentifierPropertyObserver(
- const string& name, RpcIdentifierAccessor accessor) {
+ const string& name, const RpcIdentifierAccessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<string>(
accessor,
@@ -104,7 +104,7 @@
}
void ServicePropertyChangeNotifier::AddStringPropertyObserver(
- const string& name, StringAccessor accessor) {
+ const string& name, const StringAccessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<string>(
accessor,
@@ -114,7 +114,7 @@
}
void ServicePropertyChangeNotifier::AddStringmapPropertyObserver(
- const string& name, StringmapAccessor accessor) {
+ const string& name, const StringmapAccessor& accessor) {
property_observers_.emplace_back(
new PropertyObserver<Stringmap>(
accessor,
diff --git a/service_property_change_notifier.h b/service_property_change_notifier.h
index d60ee5e..ff7814d 100644
--- a/service_property_change_notifier.h
+++ b/service_property_change_notifier.h
@@ -42,23 +42,23 @@
virtual ~ServicePropertyChangeNotifier();
virtual void AddBoolPropertyObserver(const std::string& name,
- BoolAccessor accessor);
+ const BoolAccessor& accessor);
virtual void AddUint8PropertyObserver(const std::string& name,
- Uint8Accessor accessor);
+ const Uint8Accessor& accessor);
virtual void AddUint16PropertyObserver(const std::string& name,
- Uint16Accessor accessor);
+ const Uint16Accessor& accessor);
virtual void AddUint16sPropertyObserver(const std::string& name,
- Uint16sAccessor accessor);
+ const Uint16sAccessor& accessor);
virtual void AddUintPropertyObserver(const std::string& name,
- Uint32Accessor accessor);
+ const Uint32Accessor& accessor);
virtual void AddIntPropertyObserver(const std::string& name,
- Int32Accessor accessor);
+ const Int32Accessor& accessor);
virtual void AddRpcIdentifierPropertyObserver(const std::string& name,
- RpcIdentifierAccessor accessor);
+ const RpcIdentifierAccessor& accessor);
virtual void AddStringPropertyObserver(const std::string& name,
- StringAccessor accessor);
+ const StringAccessor& accessor);
virtual void AddStringmapPropertyObserver(const std::string& name,
- StringmapAccessor accessor);
+ const StringmapAccessor& accessor);
virtual void UpdatePropertyObservers();
private:
diff --git a/service_property_change_test.cc b/service_property_change_test.cc
index 4f214ff..22abae4 100644
--- a/service_property_change_test.cc
+++ b/service_property_change_test.cc
@@ -45,7 +45,7 @@
// for specific setters. However, it's convenient to have all the property
// change notifications documented (and tested) in one place.
-void TestCommonPropertyChanges(ServiceRefPtr service,
+void TestCommonPropertyChanges(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor) {
Error error;
@@ -119,7 +119,7 @@
Mock::VerifyAndClearExpectations(adaptor);
}
-void TestAutoConnectPropertyChange(ServiceRefPtr service,
+void TestAutoConnectPropertyChange(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor) {
bool auto_connect = service->auto_connect();
EXPECT_CALL(*adaptor, EmitBoolChanged(kAutoConnectProperty, _));
@@ -127,7 +127,7 @@
Mock::VerifyAndClearExpectations(adaptor);
}
-void TestNamePropertyChange(ServiceRefPtr service,
+void TestNamePropertyChange(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor) {
Error error;
string name = service->GetNameProperty(&error);
@@ -136,7 +136,7 @@
Mock::VerifyAndClearExpectations(adaptor);
}
-void TestCustomSetterNoopChange(ServiceRefPtr service,
+void TestCustomSetterNoopChange(const ServiceRefPtr& service,
MockManager* mock_manager) {
// SetAutoConnectFull
{
diff --git a/service_property_change_test.h b/service_property_change_test.h
index a49aa5c..adb5658 100644
--- a/service_property_change_test.h
+++ b/service_property_change_test.h
@@ -26,15 +26,15 @@
// Test property change notifications that are implemented by all
// Services.
-void TestCommonPropertyChanges(ServiceRefPtr service,
+void TestCommonPropertyChanges(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor);
// Test AutoConnect property change notification. Implemented by
// all Services except EthernetService.
-void TestAutoConnectPropertyChange(ServiceRefPtr service,
+void TestAutoConnectPropertyChange(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor);
// Test Name property change notification. Only VPNService allows
// changing the name property.
-void TestNamePropertyChange(ServiceRefPtr service,
+void TestNamePropertyChange(const ServiceRefPtr& service,
ServiceMockAdaptor* adaptor);
// Test that the common customer setters (for all Services) return
// false if setting to the same as the current value.
diff --git a/service_sorter.h b/service_sorter.h
index eb56b99..d9a9237 100644
--- a/service_sorter.h
+++ b/service_sorter.h
@@ -38,7 +38,7 @@
: manager_(manager),
compare_connectivity_state_(compare_connectivity_state),
technology_order_(tech_order) {}
- bool operator() (ServiceRefPtr a, ServiceRefPtr b) {
+ bool operator() (const ServiceRefPtr& a, const ServiceRefPtr& b) {
const char* reason;
return Service::Compare(manager_, a, b, compare_connectivity_state_,
technology_order_, &reason);
diff --git a/socket_info_unittest.cc b/socket_info_unittest.cc
index e9f53f7..6594762 100644
--- a/socket_info_unittest.cc
+++ b/socket_info_unittest.cc
@@ -57,7 +57,7 @@
20,
SocketInfo::kTimerStateRetransmitTimerPending);
- SocketInfo info_copy(info);
+ const SocketInfo& info_copy(info);
ExpectSocketInfoEqual(info, info_copy);
}
@@ -73,7 +73,7 @@
20,
SocketInfo::kTimerStateRetransmitTimerPending);
- SocketInfo info_copy = info;
+ const SocketInfo& info_copy = info;
ExpectSocketInfoEqual(info, info_copy);
}
diff --git a/test-rpc-proxy/proxy_rpc_in_data_types.cc b/test-rpc-proxy/proxy_rpc_in_data_types.cc
index 1e24f5d..b9746d0 100644
--- a/test-rpc-proxy/proxy_rpc_in_data_types.cc
+++ b/test-rpc-proxy/proxy_rpc_in_data_types.cc
@@ -23,7 +23,7 @@
void AssertStructTypeStringFromXmlRpcValue(
XmlRpc::XmlRpcValue* xml_rpc_value_in,
- std::string expected_type) {
+ const std::string& expected_type) {
if ((*xml_rpc_value_in)[kXmlRpcStructTypeKey] != expected_type) {
LOG(FATAL) << "Unexpected object received. Expected: " << expected_type
<< "Recieved: " << (*xml_rpc_value_in)[kXmlRpcStructTypeKey];
diff --git a/vpn/vpn_provider.cc b/vpn/vpn_provider.cc
index b9965b6..163037c 100644
--- a/vpn/vpn_provider.cc
+++ b/vpn/vpn_provider.cc
@@ -181,7 +181,7 @@
return false;
}
-void VPNProvider::RemoveService(VPNServiceRefPtr service) {
+void VPNProvider::RemoveService(const VPNServiceRefPtr& service) {
const auto it = std::find(services_.begin(), services_.end(), service);
if (it != services_.end()) {
services_.erase(it);
diff --git a/vpn/vpn_provider.h b/vpn/vpn_provider.h
index 08c8923..3bd2d90 100644
--- a/vpn/vpn_provider.h
+++ b/vpn/vpn_provider.h
@@ -68,7 +68,7 @@
// Clean up a VPN services that has been unloaded and will be deregistered.
// This removes the VPN provider's reference to this service in its
// services_ vector.
- void RemoveService(VPNServiceRefPtr service);
+ void RemoveService(const VPNServiceRefPtr& service);
// Returns true if any of the managed VPN services is connecting or connected.
virtual bool HasActiveService() const;