Chromium Code Reviews| 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 "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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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"; | |
|
Sergey Ulanov
2012/05/17 17:35:32
In talk/p2p/client/httpportallocator.cc this field
Mallinath (Gone from Chromium)
2012/05/17 18:03:05
I think its not needed, but i am not sure. To be s
Sergey Ulanov
2012/05/17 18:24:27
Ok, please add it in host_port_allocator.cc too.
Mallinath (Gone from Chromium)
2012/05/17 18:39:10
Done.
| |
| 208 request_info.SetHeaders(headers.str()); | 209 request_info.SetHeaders(headers.str()); |
| 209 | 210 |
| 210 int result = relay_url_loader_->Open(request_info, pp::CompletionCallback( | 211 int result = relay_url_loader_->Open(request_info, pp::CompletionCallback( |
| 211 &PepperPortAllocatorSession::UrlLoaderOpenCallback, this)); | 212 &PepperPortAllocatorSession::UrlLoaderOpenCallback, this)); |
| 212 DCHECK_EQ(result, PP_OK_COMPLETIONPENDING); | 213 DCHECK_EQ(result, PP_OK_COMPLETIONPENDING); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void PepperPortAllocatorSession::OnUrlOpened(int32_t result) { | 216 void PepperPortAllocatorSession::OnUrlOpened(int32_t result) { |
| 216 if (result == PP_ERROR_ABORTED) { | 217 if (result == PP_ERROR_ABORTED) { |
| 217 return; | 218 return; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 scoped_ptr<talk_base::PacketSocketFactory> socket_factory) | 322 scoped_ptr<talk_base::PacketSocketFactory> socket_factory) |
| 322 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""), | 323 : HttpPortAllocatorBase(network_manager.get(), socket_factory.get(), ""), |
| 323 instance_(instance), | 324 instance_(instance), |
| 324 network_manager_(network_manager.Pass()), | 325 network_manager_(network_manager.Pass()), |
| 325 socket_factory_(socket_factory.Pass()) { | 326 socket_factory_(socket_factory.Pass()) { |
| 326 } | 327 } |
| 327 | 328 |
| 328 PepperPortAllocator::~PepperPortAllocator() { | 329 PepperPortAllocator::~PepperPortAllocator() { |
| 329 } | 330 } |
| 330 | 331 |
| 331 cricket::PortAllocatorSession* PepperPortAllocator::CreateSession( | 332 cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal( |
| 332 const std::string& channel_name, | 333 int component, |
| 333 int component) { | 334 const std::string& ice_username_fragment, |
| 334 return new PepperPortAllocatorSession( | 335 const std::string& ice_password) { |
| 335 this, channel_name, component, stun_hosts(), | 336 return new PepperPortAllocatorSession( |
| 336 relay_hosts(), relay_token(), instance_); | 337 this, component, ice_username_fragment, ice_password, |
| 338 stun_hosts(), relay_hosts(), relay_token(), instance_); | |
| 337 } | 339 } |
| 338 | 340 |
| 339 } // namespace remoting | 341 } // namespace remoting |
| OLD | NEW |