Fix clang-tidy performance warnings in webservd.

* Use const reference type for parameters and
  for-loop index variables to avoid unnecessary copy.

Bug: 30407689
Bug: 30413223
Change-Id: I7e9c4906ae3f48baefe860d5cd1e651d3095f2b6
Test: build with WITH_TIDY=1
diff --git a/libwebserv/binder_server.cc b/libwebserv/binder_server.cc
index 3cce096..3018480 100644
--- a/libwebserv/binder_server.cc
+++ b/libwebserv/binder_server.cc
@@ -99,7 +99,7 @@
     ResetRemoteProtocolHandlers();
   }
 
-  bool AddRemote(sp<IProtocolHandler> handler) {
+  bool AddRemote(const sp<IProtocolHandler>& handler) {
     string name;
     int32_t port;
     string protocol;
@@ -138,7 +138,7 @@
     unique_ptr<RequestHandlerRegistration> registration(
         new RequestHandlerRegistration(url, method, std::move(handler)));
 
-    for (sp<IProtocolHandler> remote : remote_handlers_) {
+    for (const sp<IProtocolHandler>& remote : remote_handlers_) {
       registration->AddRemote(remote);
     }
 
@@ -257,7 +257,7 @@
   remote_server_.clear();
 }
 
-bool BinderServer::BuildLocalState(sp<IBinder> server) {
+bool BinderServer::BuildLocalState(const sp<IBinder>& server) {
   remote_server_ = android::interface_cast<RemoteServer>(server);
   vector<sp<IBinder>> remote_raw_binders;
   if (!remote_server_->GetProtocolHandlers("", &remote_raw_binders).isOk()) {
diff --git a/libwebserv/binder_server.h b/libwebserv/binder_server.h
index 2e21cfe..98da60b 100644
--- a/libwebserv/binder_server.h
+++ b/libwebserv/binder_server.h
@@ -66,7 +66,7 @@
 
   void TryConnecting();
   void ClearLocalState();
-  bool BuildLocalState(android::sp<android::IBinder> server);
+  bool BuildLocalState(const android::sp<android::IBinder>& server);
 
   // Used to poll for webservd availability and notify the user of changes
   brillo::MessageLoop* message_loop_;
diff --git a/libwebserv/request_utils.cc b/libwebserv/request_utils.cc
index 879f8b2..0c65025 100644
--- a/libwebserv/request_utils.cc
+++ b/libwebserv/request_utils.cc
@@ -32,7 +32,7 @@
   std::vector<uint8_t> data;
 };
 
-void OnCopySuccess(std::shared_ptr<RequestDataContainer> container,
+void OnCopySuccess(const std::shared_ptr<RequestDataContainer>& container,
                    brillo::StreamPtr /* in_stream */,
                    brillo::StreamPtr out_stream,
                    uint64_t /* size_copied */) {
@@ -44,7 +44,7 @@
                                   std::move(container->data));
 }
 
-void OnCopyError(std::shared_ptr<RequestDataContainer> container,
+void OnCopyError(const std::shared_ptr<RequestDataContainer>& container,
                  brillo::StreamPtr /* in_stream */,
                  brillo::StreamPtr /* out_stream */,
                  const brillo::Error* error) {
diff --git a/webservd/binder_server.cc b/webservd/binder_server.cc
index bc588cb..ede4854 100644
--- a/webservd/binder_server.cc
+++ b/webservd/binder_server.cc
@@ -282,7 +282,7 @@
     vector<sp<IBinder>>* result) {
   result->clear();
 
-  for (auto handler : protocol_handlers_) {
+  for (const auto& handler : protocol_handlers_) {
     string handler_name;
 
     if (name.empty()) {