| 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 config_(config) { | 63 config_(config) { |
| 64 uint32 flags = 0; | 64 uint32 flags = 0; |
| 65 if (config_.disable_tcp_transport) | 65 if (config_.disable_tcp_transport) |
| 66 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; | 66 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; |
| 67 set_flags(flags); | 67 set_flags(flags); |
| 68 } | 68 } |
| 69 | 69 |
| 70 P2PPortAllocator::~P2PPortAllocator() { | 70 P2PPortAllocator::~P2PPortAllocator() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 cricket::PortAllocatorSession* P2PPortAllocator::CreateSession( | 73 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( |
| 74 const std::string& channel_name, | 74 int component, |
| 75 int component) { | 75 const std::string& ice_username_fragment, |
| 76 return new P2PPortAllocatorSession(this, channel_name, component); | 76 const std::string& ice_password) { |
| 77 return new P2PPortAllocatorSession( |
| 78 this, component, ice_username_fragment, ice_password); |
| 77 } | 79 } |
| 78 | 80 |
| 79 P2PPortAllocatorSession::P2PPortAllocatorSession( | 81 P2PPortAllocatorSession::P2PPortAllocatorSession( |
| 80 P2PPortAllocator* allocator, | 82 P2PPortAllocator* allocator, |
| 81 const std::string& channel_name, | 83 int component, |
| 82 int component) | 84 const std::string& ice_username_fragment, |
| 83 : cricket::BasicPortAllocatorSession(allocator, channel_name, component), | 85 const std::string& ice_password) |
| 86 : cricket::BasicPortAllocatorSession( |
| 87 allocator, component, |
| 88 ice_username_fragment, ice_password), |
| 84 allocator_(allocator), | 89 allocator_(allocator), |
| 85 relay_session_attempts_(0), | 90 relay_session_attempts_(0), |
| 86 relay_udp_port_(0), | 91 relay_udp_port_(0), |
| 87 relay_tcp_port_(0), | 92 relay_tcp_port_(0), |
| 88 relay_ssltcp_port_(0) { | 93 relay_ssltcp_port_(0) { |
| 89 } | 94 } |
| 90 | 95 |
| 91 P2PPortAllocatorSession::~P2PPortAllocatorSession() { | 96 P2PPortAllocatorSession::~P2PPortAllocatorSession() { |
| 92 if (stun_address_request_) | 97 if (stun_address_request_) |
| 93 stun_address_request_->Cancel(); | 98 stun_address_request_->Cancel(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 request.setURL(WebURL(GURL(url))); | 218 request.setURL(WebURL(GURL(url))); |
| 214 request.setAllowStoredCredentials(false); | 219 request.setAllowStoredCredentials(false); |
| 215 request.setCachePolicy(WebURLRequest::ReloadIgnoringCacheData); | 220 request.setCachePolicy(WebURLRequest::ReloadIgnoringCacheData); |
| 216 request.setHTTPMethod("GET"); | 221 request.setHTTPMethod("GET"); |
| 217 request.addHTTPHeaderField( | 222 request.addHTTPHeaderField( |
| 218 WebString::fromUTF8("X-Talk-Google-Relay-Auth"), | 223 WebString::fromUTF8("X-Talk-Google-Relay-Auth"), |
| 219 WebString::fromUTF8(allocator_->config_.relay_password)); | 224 WebString::fromUTF8(allocator_->config_.relay_password)); |
| 220 request.addHTTPHeaderField( | 225 request.addHTTPHeaderField( |
| 221 WebString::fromUTF8("X-Google-Relay-Auth"), | 226 WebString::fromUTF8("X-Google-Relay-Auth"), |
| 222 WebString::fromUTF8(allocator_->config_.relay_password)); | 227 WebString::fromUTF8(allocator_->config_.relay_password)); |
| 223 request.addHTTPHeaderField(WebString::fromUTF8("X-Stream-Type"), | |
| 224 WebString::fromUTF8(channel_name())); | |
| 225 | 228 |
| 226 relay_session_request_->loadAsynchronously(request, this); | 229 relay_session_request_->loadAsynchronously(request, this); |
| 227 } | 230 } |
| 228 | 231 |
| 229 void P2PPortAllocatorSession::ParseRelayResponse() { | 232 void P2PPortAllocatorSession::ParseRelayResponse() { |
| 230 std::vector<std::pair<std::string, std::string> > value_pairs; | 233 std::vector<std::pair<std::string, std::string> > value_pairs; |
| 231 if (!base::SplitStringIntoKeyValuePairs(relay_session_response_, '=', '\n', | 234 if (!base::SplitStringIntoKeyValuePairs(relay_session_response_, '=', '\n', |
| 232 &value_pairs)) { | 235 &value_pairs)) { |
| 233 LOG(ERROR) << "Received invalid response from relay server"; | 236 LOG(ERROR) << "Received invalid response from relay server"; |
| 234 return; | 237 return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); | 301 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); |
| 299 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); | 302 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); |
| 300 } | 303 } |
| 301 if (!ports.empty()) | 304 if (!ports.empty()) |
| 302 config->AddRelay(ports, 0.0f); | 305 config->AddRelay(ports, 0.0f); |
| 303 } | 306 } |
| 304 ConfigReady(config); | 307 ConfigReady(config); |
| 305 } | 308 } |
| 306 | 309 |
| 307 } // namespace content | 310 } // namespace content |
| OLD | NEW |