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

Side by Side Diff: remoting/client/plugin/pepper_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
« no previous file with comments | « remoting/client/plugin/pepper_port_allocator.h ('k') | remoting/host/host_port_allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/client/plugin/pepper_port_allocator.h" 5 #include "remoting/client/plugin/pepper_port_allocator.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "net/base/net_util.h" 8 #include "net/base/net_util.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/completion_callback.h" 10 #include "ppapi/cpp/completion_callback.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Read buffer we allocate per read when reading response from 26 // Read buffer we allocate per read when reading response from
27 // URLLoader. Normally the response from URL loader is smaller than 1kB. 27 // URLLoader. Normally the response from URL loader is smaller than 1kB.
28 const int kReadSize = 1024; 28 const int kReadSize = 1024;
29 29
30 class PepperPortAllocatorSession 30 class PepperPortAllocatorSession
31 : public cricket::HttpPortAllocatorSessionBase { 31 : public cricket::HttpPortAllocatorSessionBase {
32 public: 32 public:
33 PepperPortAllocatorSession( 33 PepperPortAllocatorSession(
34 cricket::HttpPortAllocatorBase* allocator, 34 cricket::HttpPortAllocatorBase* allocator,
35 const std::string& channel_name,
36 int component, 35 int component,
36 const std::string& ice_username_fragment,
37 const std::string& ice_password,
37 const std::vector<talk_base::SocketAddress>& stun_hosts, 38 const std::vector<talk_base::SocketAddress>& stun_hosts,
38 const std::vector<std::string>& relay_hosts, 39 const std::vector<std::string>& relay_hosts,
39 const std::string& relay_token, 40 const std::string& relay_token,
40 const pp::InstanceHandle& instance); 41 const pp::InstanceHandle& instance);
41 virtual ~PepperPortAllocatorSession(); 42 virtual ~PepperPortAllocatorSession();
42 43
43 // cricket::HttpPortAllocatorBase overrides. 44 // cricket::HttpPortAllocatorBase overrides.
44 virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; 45 virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE;
45 virtual void GetPortConfigurations() OVERRIDE; 46 virtual void GetPortConfigurations() OVERRIDE;
46 virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE; 47 virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE;
(...skipping 19 matching lines...) Expand all
66 67
67 scoped_ptr<pp::URLLoader> relay_url_loader_; 68 scoped_ptr<pp::URLLoader> relay_url_loader_;
68 std::vector<char> relay_response_body_; 69 std::vector<char> relay_response_body_;
69 bool relay_response_received_; 70 bool relay_response_received_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorSession); 72 DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorSession);
72 }; 73 };
73 74
74 PepperPortAllocatorSession::PepperPortAllocatorSession( 75 PepperPortAllocatorSession::PepperPortAllocatorSession(
75 cricket::HttpPortAllocatorBase* allocator, 76 cricket::HttpPortAllocatorBase* allocator,
76 const std::string& channel_name,
77 int component, 77 int component,
78 const std::string& ice_username_fragment,
79 const std::string& ice_password,
78 const std::vector<talk_base::SocketAddress>& stun_hosts, 80 const std::vector<talk_base::SocketAddress>& stun_hosts,
79 const std::vector<std::string>& relay_hosts, 81 const std::vector<std::string>& relay_hosts,
80 const std::string& relay_token, 82 const std::string& relay_token,
81 const pp::InstanceHandle& instance) 83 const pp::InstanceHandle& instance)
82 : cricket::HttpPortAllocatorSessionBase( 84 : HttpPortAllocatorSessionBase(
83 allocator, channel_name, component, stun_hosts, 85 allocator, component, ice_username_fragment, ice_password,
84 relay_hosts, relay_token, ""), 86 stun_hosts, relay_hosts, relay_token, ""),
85 instance_(instance), 87 instance_(instance),
86 stun_address_resolver_(instance_), 88 stun_address_resolver_(instance_),
87 stun_port_(0), 89 stun_port_(0),
88 relay_response_received_(false) { 90 relay_response_received_(false) {
89 set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); 91 set_flags(cricket::PORTALLOCATOR_DISABLE_TCP);
90 if (stun_hosts.size() > 0) { 92 if (stun_hosts.size() > 0) {
91 stun_address_ = stun_hosts[0]; 93 stun_address_ = stun_hosts[0];
92 } 94 }
93 } 95 }
94 96
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 int port) { 199 int port) {
198 relay_url_loader_.reset(new pp::URLLoader(instance_)); 200 relay_url_loader_.reset(new pp::URLLoader(instance_));
199 pp::URLRequestInfo request_info(instance_); 201 pp::URLRequestInfo request_info(instance_);
200 std::string url = "https://" + host + ":" + base::IntToString(port) + 202 std::string url = "https://" + host + ":" + base::IntToString(port) +
201 GetSessionRequestUrl() + "&sn=1"; 203 GetSessionRequestUrl() + "&sn=1";
202 request_info.SetURL(url); 204 request_info.SetURL(url);
203 request_info.SetMethod("GET"); 205 request_info.SetMethod("GET");
204 std::stringstream headers; 206 std::stringstream headers;
205 headers << "X-Talk-Google-Relay-Auth: " << relay_token() << "\n\r"; 207 headers << "X-Talk-Google-Relay-Auth: " << relay_token() << "\n\r";
206 headers << "X-Google-Relay-Auth: " << relay_token() << "\n\r"; 208 headers << "X-Google-Relay-Auth: " << relay_token() << "\n\r";
207 headers << "X-StreamType: " << channel_name() << "\n\r"; 209 headers << "X-Stream-Type: " << "chromoting" << "\n\r";
208 request_info.SetHeaders(headers.str()); 210 request_info.SetHeaders(headers.str());
209 211
210 int result = relay_url_loader_->Open(request_info, pp::CompletionCallback( 212 int result = relay_url_loader_->Open(request_info, pp::CompletionCallback(
211 &PepperPortAllocatorSession::UrlLoaderOpenCallback, this)); 213 &PepperPortAllocatorSession::UrlLoaderOpenCallback, this));
212 DCHECK_EQ(result, PP_OK_COMPLETIONPENDING); 214 DCHECK_EQ(result, PP_OK_COMPLETIONPENDING);
213 } 215 }
214 216
215 void PepperPortAllocatorSession::OnUrlOpened(int32_t result) { 217 void PepperPortAllocatorSession::OnUrlOpened(int32_t result) {
216 if (result == PP_ERROR_ABORTED) { 218 if (result == PP_ERROR_ABORTED) {
217 return; 219 return;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 scoped_ptr<talk_base::PacketSocketFactory> socket_factory) 323 scoped_ptr<talk_base::PacketSocketFactory> socket_factory)
322 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""), 324 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""),
323 instance_(instance), 325 instance_(instance),
324 network_manager_(network_manager.Pass()), 326 network_manager_(network_manager.Pass()),
325 socket_factory_(socket_factory.Pass()) { 327 socket_factory_(socket_factory.Pass()) {
326 } 328 }
327 329
328 PepperPortAllocator::~PepperPortAllocator() { 330 PepperPortAllocator::~PepperPortAllocator() {
329 } 331 }
330 332
331 cricket::PortAllocatorSession* PepperPortAllocator::CreateSession( 333 cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal(
332 const std::string& channel_name, 334 int component,
333 int component) { 335 const std::string& ice_username_fragment,
334 return new PepperPortAllocatorSession( 336 const std::string& ice_password) {
335 this, channel_name, component, stun_hosts(), 337 return new PepperPortAllocatorSession(
336 relay_hosts(), relay_token(), instance_); 338 this, component, ice_username_fragment, ice_password,
339 stun_hosts(), relay_hosts(), relay_token(), instance_);
337 } 340 }
338 341
339 } // namespace remoting 342 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_port_allocator.h ('k') | remoting/host/host_port_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698