Use std::string references instead of copying contents.

This CL improves the memory footprint a bit by using string references
instead of creating a copy.

Review URL: https://codereview.webrtc.org/1241973002

Cr-Commit-Position: refs/heads/master@{#9592}
diff --git a/talk/app/webrtc/jsepsessiondescription.cc b/talk/app/webrtc/jsepsessiondescription.cc
index 697f332..d1428d0 100644
--- a/talk/app/webrtc/jsepsessiondescription.cc
+++ b/talk/app/webrtc/jsepsessiondescription.cc
@@ -130,7 +130,7 @@
   }
   if (mediasection_index >= number_of_mediasections())
     return false;
-  const std::string content_name =
+  const std::string& content_name =
       description_->contents()[mediasection_index].name;
   const cricket::TransportInfo* transport_info =
       description_->GetTransportInfoByName(content_name);
diff --git a/talk/app/webrtc/webrtcsdp.cc b/talk/app/webrtc/webrtcsdp.cc
index b6f23ca..30db437 100644
--- a/talk/app/webrtc/webrtcsdp.cc
+++ b/talk/app/webrtc/webrtcsdp.cc
@@ -716,7 +716,7 @@
 // Update |mline|'s default destination and append a c line after it.
 static void UpdateMediaDefaultDestination(
     const std::vector<Candidate>& candidates,
-    const std::string mline,
+    const std::string& mline,
     std::string* message) {
   std::string new_lines;
   AddLine(mline, &new_lines);
@@ -808,9 +808,9 @@
   // <unicast-address>
   std::ostringstream os;
   InitLine(kLineTypeOrigin, kSessionOriginUsername, &os);
-  const std::string session_id = jdesc.session_id().empty() ?
+  const std::string& session_id = jdesc.session_id().empty() ?
       kSessionOriginSessionId : jdesc.session_id();
-  const std::string session_version = jdesc.session_version().empty() ?
+  const std::string& session_version = jdesc.session_version().empty() ?
       kSessionOriginSessionVersion : jdesc.session_version();
   os << " " << session_id << " " << session_version << " "
      << kSessionOriginNettype << " " << kSessionOriginAddrtype << " "
@@ -1001,18 +1001,18 @@
       (fields[6] != kAttributeCandidateTyp)) {
     return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error);
   }
-  std::string foundation = fields[0];
+  const std::string& foundation = fields[0];
 
   int component_id = 0;
   if (!GetValueFromString(first_line, fields[1], &component_id, error)) {
     return false;
   }
-  const std::string transport = fields[2];
+  const std::string& transport = fields[2];
   uint32 priority = 0;
   if (!GetValueFromString(first_line, fields[3], &priority, error)) {
     return false;
   }
-  const std::string connection_address = fields[4];
+  const std::string& connection_address = fields[4];
   int port = 0;
   if (!GetValueFromString(first_line, fields[5], &port, error)) {
     return false;
@@ -1025,7 +1025,7 @@
   }
 
   std::string candidate_type;
-  const std::string type = fields[7];
+  const std::string& type = fields[7];
   if (type == kCandidateHost) {
     candidate_type = cricket::LOCAL_PORT_TYPE;
   } else if (type == kCandidateSrflx) {
@@ -1260,7 +1260,7 @@
   // RFC 3264
   // To reject an offered stream, the port number in the corresponding stream in
   // the answer MUST be set to zero.
-  const std::string port = content_info->rejected ?
+  const std::string& port = content_info->rejected ?
       kMediaPortRejected : kDummyPort;
 
   rtc::SSLFingerprint* fp = (transport_info) ?
@@ -2845,8 +2845,8 @@
   if (!GetValueFromString(line, tag_value, &tag, error)) {
     return false;
   }
-  const std::string crypto_suite = fields[1];
-  const std::string key_params = fields[2];
+  const std::string& crypto_suite = fields[1];
+  const std::string& key_params = fields[2];
   std::string session_params;
   if (fields.size() > 3) {
     session_params = fields[3];
@@ -2926,7 +2926,7 @@
                     << "<fmt> of the m-line: " << line;
     return true;
   }
-  const std::string encoder = fields[1];
+  const std::string& encoder = fields[1];
   std::vector<std::string> codec_params;
   rtc::split(encoder, '/', &codec_params);
   // <encoding name>/<clock rate>[/<encodingparameters>]
@@ -2937,7 +2937,7 @@
                        "[/<encodingparameters>]\".",
                        error);
   }
-  const std::string encoding_name = codec_params[0];
+  const std::string& encoding_name = codec_params[0];
   int clock_rate = 0;
   if (!GetValueFromString(line, codec_params[1], &clock_rate, error)) {
     return false;
diff --git a/talk/media/webrtc/webrtcvideocapturer.cc b/talk/media/webrtc/webrtcvideocapturer.cc
index f8c373d..8ef920e 100644
--- a/talk/media/webrtc/webrtcvideocapturer.cc
+++ b/talk/media/webrtc/webrtcvideocapturer.cc
@@ -265,7 +265,7 @@
   // calls, can't take lock.
   DCHECK(module_);
 
-  const std::string group_name =
+  const std::string& group_name =
       webrtc::field_trial::FindFullName("WebRTC-CVO");
 
   if (group_name == "Disabled") {
diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc
index 9199795..121db14 100644
--- a/talk/media/webrtc/webrtcvideoengine2.cc
+++ b/talk/media/webrtc/webrtcvideoengine2.cc
@@ -154,7 +154,7 @@
     return true;
   }
   if (CodecNamesEq(codec_name, kVp9CodecName)) {
-    const std::string group_name =
+    const std::string& group_name =
         webrtc::field_trial::FindFullName("WebRTC-SupportVP9");
     return group_name == "Enabled" || group_name == "EnabledByFlag";
   }
diff --git a/talk/session/media/mediasession.cc b/talk/session/media/mediasession.cc
index dc4f408..8d07e95 100644
--- a/talk/session/media/mediasession.cc
+++ b/talk/session/media/mediasession.cc
@@ -529,7 +529,7 @@
   }
 
   // We should definitely have a transport for the first content.
-  std::string selected_content_name = *bundle_group.FirstContentName();
+  const std::string& selected_content_name = *bundle_group.FirstContentName();
   const TransportInfo* selected_transport_info =
       sdesc->GetTransportInfoByName(selected_content_name);
   if (!selected_transport_info) {
@@ -537,9 +537,9 @@
   }
 
   // Set the other contents to use the same ICE credentials.
-  const std::string selected_ufrag =
+  const std::string& selected_ufrag =
       selected_transport_info->description.ice_ufrag;
-  const std::string selected_pwd =
+  const std::string& selected_pwd =
       selected_transport_info->description.ice_pwd;
   for (TransportInfos::iterator it =
            sdesc->transport_infos().begin();