| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/p2p/port_allocator.h" | 5 #include "content/renderer/p2p/port_allocator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 request.addHTTPHeaderField( | 195 request.addHTTPHeaderField( |
| 196 WebString::fromUTF8("X-Google-Relay-Auth"), | 196 WebString::fromUTF8("X-Google-Relay-Auth"), |
| 197 WebString::fromUTF8(relay_config.username)); | 197 WebString::fromUTF8(relay_config.username)); |
| 198 request.addHTTPHeaderField(WebString::fromUTF8("X-Stream-Type"), | 198 request.addHTTPHeaderField(WebString::fromUTF8("X-Stream-Type"), |
| 199 WebString::fromUTF8("chromoting")); | 199 WebString::fromUTF8("chromoting")); |
| 200 | 200 |
| 201 relay_session_request_->loadAsynchronously(request, this); | 201 relay_session_request_->loadAsynchronously(request, this); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void P2PPortAllocatorSession::ParseRelayResponse() { | 204 void P2PPortAllocatorSession::ParseRelayResponse() { |
| 205 std::vector<std::pair<std::string, std::string> > value_pairs; | 205 base::StringPairs value_pairs; |
| 206 if (!base::SplitStringIntoKeyValuePairs(relay_session_response_, '=', '\n', | 206 if (!base::SplitStringIntoKeyValuePairs(relay_session_response_, '=', '\n', |
| 207 &value_pairs)) { | 207 &value_pairs)) { |
| 208 LOG(ERROR) << "Received invalid response from relay server"; | 208 LOG(ERROR) << "Received invalid response from relay server"; |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 | 211 |
| 212 relay_ip_.Clear(); | 212 relay_ip_.Clear(); |
| 213 relay_udp_port_ = 0; | 213 relay_udp_port_ = 0; |
| 214 relay_tcp_port_ = 0; | 214 relay_tcp_port_ = 0; |
| 215 relay_ssltcp_port_ = 0; | 215 relay_ssltcp_port_ = 0; |
| 216 | 216 |
| 217 for (std::vector<std::pair<std::string, std::string> >::iterator | 217 for (base::StringPairs::iterator it = value_pairs.begin(); |
| 218 it = value_pairs.begin(); | |
| 219 it != value_pairs.end(); ++it) { | 218 it != value_pairs.end(); ++it) { |
| 220 std::string key; | 219 std::string key; |
| 221 std::string value; | 220 std::string value; |
| 222 base::TrimWhitespaceASCII(it->first, base::TRIM_ALL, &key); | 221 base::TrimWhitespaceASCII(it->first, base::TRIM_ALL, &key); |
| 223 base::TrimWhitespaceASCII(it->second, base::TRIM_ALL, &value); | 222 base::TrimWhitespaceASCII(it->second, base::TRIM_ALL, &value); |
| 224 | 223 |
| 225 if (key == "username") { | 224 if (key == "username") { |
| 226 if (value != username()) { | 225 if (value != username()) { |
| 227 LOG(ERROR) << "When creating relay session received user name " | 226 LOG(ERROR) << "When creating relay session received user name " |
| 228 " that was different from the value specified in the query."; | 227 " that was different from the value specified in the query."; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 config.relays[i].port), | 279 config.relays[i].port), |
| 281 protocol, | 280 protocol, |
| 282 config.relays[i].secure)); | 281 config.relays[i].secure)); |
| 283 relay_server.credentials = credentials; | 282 relay_server.credentials = credentials; |
| 284 port_config->AddRelay(relay_server); | 283 port_config->AddRelay(relay_server); |
| 285 } | 284 } |
| 286 ConfigReady(port_config); | 285 ConfigReady(port_config); |
| 287 } | 286 } |
| 288 | 287 |
| 289 } // namespace content | 288 } // namespace content |
| OLD | NEW |