Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: remoting/host/host_port_allocator.cc

Issue 10382003: Changes needed to roll libjingle r141 (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "remoting/host/host_port_allocator.h" 5 #include "remoting/host/host_port_allocator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "net/http/http_status_code.h" 11 #include "net/http/http_status_code.h"
12 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
13 #include "remoting/host/network_settings.h" 13 #include "remoting/host/network_settings.h"
14 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" 14 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 namespace { 18 namespace {
19 19
20 class HostPortAllocatorSession 20 class HostPortAllocatorSession
21 : public cricket::HttpPortAllocatorSessionBase { 21 : public cricket::HttpPortAllocatorSessionBase {
22 public: 22 public:
23 HostPortAllocatorSession( 23 HostPortAllocatorSession(
24 cricket::HttpPortAllocatorBase* allocator, 24 cricket::HttpPortAllocatorBase* allocator,
25 const std::string& channel_name, 25 const std::string& channel_name,
26 int component, 26 int component,
27 const std::string& ice_username_fragment,
28 const std::string& ice_password,
27 const std::vector<talk_base::SocketAddress>& stun_hosts, 29 const std::vector<talk_base::SocketAddress>& stun_hosts,
28 const std::vector<std::string>& relay_hosts, 30 const std::vector<std::string>& relay_hosts,
29 const std::string& relay, 31 const std::string& relay,
30 const scoped_refptr<net::URLRequestContextGetter>& url_context); 32 const scoped_refptr<net::URLRequestContextGetter>& url_context);
31 virtual ~HostPortAllocatorSession(); 33 virtual ~HostPortAllocatorSession();
32 34
33 // cricket::HttpPortAllocatorBase overrides. 35 // cricket::HttpPortAllocatorBase overrides.
34 virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; 36 virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE;
35 virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE; 37 virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE;
36 38
37 private: 39 private:
38 void OnSessionRequestDone(UrlFetcher* url_fetcher, 40 void OnSessionRequestDone(UrlFetcher* url_fetcher,
39 const net::URLRequestStatus& status, 41 const net::URLRequestStatus& status,
40 int response_code, 42 int response_code,
41 const std::string& response); 43 const std::string& response);
42 44
43 scoped_refptr<net::URLRequestContextGetter> url_context_; 45 scoped_refptr<net::URLRequestContextGetter> url_context_;
44 std::set<UrlFetcher*> url_fetchers_; 46 std::set<UrlFetcher*> url_fetchers_;
45 47
46 DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession); 48 DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession);
47 }; 49 };
48 50
49 HostPortAllocatorSession::HostPortAllocatorSession( 51 HostPortAllocatorSession::HostPortAllocatorSession(
50 cricket::HttpPortAllocatorBase* allocator, 52 cricket::HttpPortAllocatorBase* allocator,
51 const std::string& channel_name, 53 const std::string& channel_name,
52 int component, 54 int component,
55 const std::string& ice_username_fragment,
56 const std::string& ice_password,
53 const std::vector<talk_base::SocketAddress>& stun_hosts, 57 const std::vector<talk_base::SocketAddress>& stun_hosts,
54 const std::vector<std::string>& relay_hosts, 58 const std::vector<std::string>& relay_hosts,
55 const std::string& relay, 59 const std::string& relay,
56 const scoped_refptr<net::URLRequestContextGetter>& url_context) 60 const scoped_refptr<net::URLRequestContextGetter>& url_context)
57 : HttpPortAllocatorSessionBase( 61 : HttpPortAllocatorSessionBase(
58 allocator, channel_name, component, stun_hosts, relay_hosts, relay, ""), 62 allocator, channel_name, component, ice_username_fragment, ice_password,
63 stun_hosts, relay_hosts, relay, ""),
59 url_context_(url_context) { 64 url_context_(url_context) {
60 } 65 }
61 66
62 HostPortAllocatorSession::~HostPortAllocatorSession() { 67 HostPortAllocatorSession::~HostPortAllocatorSession() {
63 STLDeleteElements(&url_fetchers_); 68 STLDeleteElements(&url_fetchers_);
64 } 69 }
65 70
66 void HostPortAllocatorSession::ConfigReady(cricket::PortConfiguration* config) { 71 void HostPortAllocatorSession::ConfigReady(cricket::PortConfiguration* config) {
67 // Filter out non-UDP relay ports, so that we don't try using TCP. 72 // Filter out non-UDP relay ports, so that we don't try using TCP.
68 for (cricket::PortConfiguration::RelayList::iterator relay = 73 for (cricket::PortConfiguration::RelayList::iterator relay =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 scoped_ptr<talk_base::PacketSocketFactory> socket_factory) 152 scoped_ptr<talk_base::PacketSocketFactory> socket_factory)
148 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""), 153 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""),
149 url_context_(url_context), 154 url_context_(url_context),
150 network_manager_(network_manager.Pass()), 155 network_manager_(network_manager.Pass()),
151 socket_factory_(socket_factory.Pass()) { 156 socket_factory_(socket_factory.Pass()) {
152 } 157 }
153 158
154 HostPortAllocator::~HostPortAllocator() { 159 HostPortAllocator::~HostPortAllocator() {
155 } 160 }
156 161
157 cricket::PortAllocatorSession* HostPortAllocator::CreateSession( 162 cricket::PortAllocatorSession* HostPortAllocator::CreateSessionInternal(
158 const std::string& channel_name, 163 const std::string& channel_name,
159 int component) { 164 int component,
165 const std::string& ice_username_fragment,
166 const std::string& ice_password) {
160 return new HostPortAllocatorSession( 167 return new HostPortAllocatorSession(
161 this, channel_name, component, stun_hosts(), 168 this, channel_name, component, ice_username_fragment, ice_password,
162 relay_hosts(), relay_token(), url_context_); 169 stun_hosts(), relay_hosts(), relay_token(), url_context_);
163 } 170 }
164 171
165 } // namespace remoting 172 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698