| 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& content_name, |
| 35 int component, | 36 int component, |
| 36 const std::string& ice_username_fragment, | 37 const std::string& ice_username_fragment, |
| 37 const std::string& ice_password, | 38 const std::string& ice_password, |
| 38 const std::vector<talk_base::SocketAddress>& stun_hosts, | 39 const std::vector<talk_base::SocketAddress>& stun_hosts, |
| 39 const std::vector<std::string>& relay_hosts, | 40 const std::vector<std::string>& relay_hosts, |
| 40 const std::string& relay_token, | 41 const std::string& relay_token, |
| 41 const pp::InstanceHandle& instance); | 42 const pp::InstanceHandle& instance); |
| 42 virtual ~PepperPortAllocatorSession(); | 43 virtual ~PepperPortAllocatorSession(); |
| 43 | 44 |
| 44 // cricket::HttpPortAllocatorBase overrides. | 45 // cricket::HttpPortAllocatorBase overrides. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 67 | 68 |
| 68 scoped_ptr<pp::URLLoader> relay_url_loader_; | 69 scoped_ptr<pp::URLLoader> relay_url_loader_; |
| 69 std::vector<char> relay_response_body_; | 70 std::vector<char> relay_response_body_; |
| 70 bool relay_response_received_; | 71 bool relay_response_received_; |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorSession); | 73 DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorSession); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 PepperPortAllocatorSession::PepperPortAllocatorSession( | 76 PepperPortAllocatorSession::PepperPortAllocatorSession( |
| 76 cricket::HttpPortAllocatorBase* allocator, | 77 cricket::HttpPortAllocatorBase* allocator, |
| 78 const std::string& content_name, |
| 77 int component, | 79 int component, |
| 78 const std::string& ice_username_fragment, | 80 const std::string& ice_username_fragment, |
| 79 const std::string& ice_password, | 81 const std::string& ice_password, |
| 80 const std::vector<talk_base::SocketAddress>& stun_hosts, | 82 const std::vector<talk_base::SocketAddress>& stun_hosts, |
| 81 const std::vector<std::string>& relay_hosts, | 83 const std::vector<std::string>& relay_hosts, |
| 82 const std::string& relay_token, | 84 const std::string& relay_token, |
| 83 const pp::InstanceHandle& instance) | 85 const pp::InstanceHandle& instance) |
| 84 : HttpPortAllocatorSessionBase( | 86 : HttpPortAllocatorSessionBase( |
| 85 allocator, component, ice_username_fragment, ice_password, | 87 allocator, content_name, component, ice_username_fragment, ice_password, |
| 86 stun_hosts, relay_hosts, relay_token, ""), | 88 stun_hosts, relay_hosts, relay_token, ""), |
| 87 instance_(instance), | 89 instance_(instance), |
| 88 stun_address_resolver_(instance_), | 90 stun_address_resolver_(instance_), |
| 89 stun_port_(0), | 91 stun_port_(0), |
| 90 relay_response_received_(false) { | 92 relay_response_received_(false) { |
| 91 if (stun_hosts.size() > 0) { | 93 if (stun_hosts.size() > 0) { |
| 92 stun_address_ = stun_hosts[0]; | 94 stun_address_ = stun_hosts[0]; |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // username fragment is shared between all candidates for this | 331 // username fragment is shared between all candidates for this |
| 330 // channel. | 332 // channel. |
| 331 set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 333 set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 332 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); | 334 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
| 333 } | 335 } |
| 334 | 336 |
| 335 PepperPortAllocator::~PepperPortAllocator() { | 337 PepperPortAllocator::~PepperPortAllocator() { |
| 336 } | 338 } |
| 337 | 339 |
| 338 cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal( | 340 cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal( |
| 341 const std::string& content_name, |
| 339 int component, | 342 int component, |
| 340 const std::string& ice_username_fragment, | 343 const std::string& ice_username_fragment, |
| 341 const std::string& ice_password) { | 344 const std::string& ice_password) { |
| 342 return new PepperPortAllocatorSession( | 345 return new PepperPortAllocatorSession( |
| 343 this, component, ice_username_fragment, ice_password, | 346 this, content_name, component, ice_username_fragment, ice_password, |
| 344 stun_hosts(), relay_hosts(), relay_token(), instance_); | 347 stun_hosts(), relay_hosts(), relay_token(), instance_); |
| 345 } | 348 } |
| 346 | 349 |
| 347 } // namespace remoting | 350 } // namespace remoting |
| OLD | NEW |