Chromium Code Reviews| Index: remoting/protocol/native_port_allocator.cc |
| diff --git a/remoting/host/host_port_allocator.cc b/remoting/protocol/native_port_allocator.cc |
| similarity index 85% |
| rename from remoting/host/host_port_allocator.cc |
| rename to remoting/protocol/native_port_allocator.cc |
| index 4fdd790ae5857b47d006189601b45d07ef1430c5..65f199f25d7140c050e7630b10d84fb5e8801186 100644 |
| --- a/remoting/host/host_port_allocator.cc |
| +++ b/remoting/protocol/native_port_allocator.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "remoting/host/host_port_allocator.h" |
| +#include "remoting/protocol/native_port_allocator.h" |
| #include "base/bind.h" |
| #include "base/stl_util.h" |
| @@ -12,18 +12,20 @@ |
| #include "net/url_request/url_fetcher.h" |
| #include "net/url_request/url_fetcher_delegate.h" |
| #include "net/url_request/url_request_context_getter.h" |
| -#include "remoting/host/network_settings.h" |
| #include "remoting/jingle_glue/chromium_socket_factory.h" |
| +#include "remoting/protocol/network_settings.h" |
| namespace remoting { |
| +namespace protocol { |
| + |
| namespace { |
| -class HostPortAllocatorSession |
| +class NativePortAllocatorSession |
|
Sergey Ulanov
2013/06/20 19:37:53
I think this code belongs to jingle_glue layer, an
|
| : public cricket::HttpPortAllocatorSessionBase, |
| public net::URLFetcherDelegate { |
| public: |
| - HostPortAllocatorSession( |
| + NativePortAllocatorSession( |
| cricket::HttpPortAllocatorBase* allocator, |
| const std::string& content_name, |
| int component, |
| @@ -33,7 +35,7 @@ class HostPortAllocatorSession |
| const std::vector<std::string>& relay_hosts, |
| const std::string& relay, |
| const scoped_refptr<net::URLRequestContextGetter>& url_context); |
| - virtual ~HostPortAllocatorSession(); |
| + virtual ~NativePortAllocatorSession(); |
| // cricket::HttpPortAllocatorBase overrides. |
| virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; |
| @@ -46,10 +48,10 @@ class HostPortAllocatorSession |
| scoped_refptr<net::URLRequestContextGetter> url_context_; |
| std::set<const net::URLFetcher*> url_fetchers_; |
| - DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession); |
| + DISALLOW_COPY_AND_ASSIGN(NativePortAllocatorSession); |
| }; |
| -HostPortAllocatorSession::HostPortAllocatorSession( |
| +NativePortAllocatorSession::NativePortAllocatorSession( |
| cricket::HttpPortAllocatorBase* allocator, |
| const std::string& content_name, |
| int component, |
| @@ -70,11 +72,12 @@ HostPortAllocatorSession::HostPortAllocatorSession( |
| std::string()), |
| url_context_(url_context) {} |
| -HostPortAllocatorSession::~HostPortAllocatorSession() { |
| +NativePortAllocatorSession::~NativePortAllocatorSession() { |
| STLDeleteElements(&url_fetchers_); |
| } |
| -void HostPortAllocatorSession::ConfigReady(cricket::PortConfiguration* config) { |
| +void NativePortAllocatorSession::ConfigReady( |
| + cricket::PortConfiguration* config) { |
| // Filter out non-UDP relay ports, so that we don't try using TCP. |
| for (cricket::PortConfiguration::RelayList::iterator relay = |
| config->relays.begin(); relay != config->relays.end(); ++relay) { |
| @@ -90,7 +93,7 @@ void HostPortAllocatorSession::ConfigReady(cricket::PortConfiguration* config) { |
| cricket::BasicPortAllocatorSession::ConfigReady(config); |
| } |
| -void HostPortAllocatorSession::SendSessionRequest(const std::string& host, |
| +void NativePortAllocatorSession::SendSessionRequest(const std::string& host, |
| int port) { |
|
Sergey Ulanov
2013/06/20 19:37:53
nit: indentation
|
| GURL url("https://" + host + ":" + base::IntToString(port) + |
| GetSessionRequestUrl() + "&sn=1"); |
| @@ -105,7 +108,7 @@ void HostPortAllocatorSession::SendSessionRequest(const std::string& host, |
| url_fetchers_.insert(url_fetcher.release()); |
| } |
| -void HostPortAllocatorSession::OnURLFetchComplete( |
| +void NativePortAllocatorSession::OnURLFetchComplete( |
| const net::URLFetcher* source) { |
| int response_code = source->GetResponseCode(); |
| std::string response; |
| @@ -127,15 +130,15 @@ void HostPortAllocatorSession::OnURLFetchComplete( |
| } // namespace |
| // static |
| -scoped_ptr<HostPortAllocator> HostPortAllocator::Create( |
| +scoped_ptr<NativePortAllocator> NativePortAllocator::Create( |
| const scoped_refptr<net::URLRequestContextGetter>& url_context, |
| const NetworkSettings& network_settings) { |
| scoped_ptr<talk_base::NetworkManager> network_manager( |
| new talk_base::BasicNetworkManager()); |
| scoped_ptr<talk_base::PacketSocketFactory> socket_factory( |
| new remoting::ChromiumPacketSocketFactory()); |
| - scoped_ptr<HostPortAllocator> result( |
| - new HostPortAllocator(url_context, network_manager.Pass(), |
| + scoped_ptr<NativePortAllocator> result( |
| + new NativePortAllocator(url_context, network_manager.Pass(), |
| socket_factory.Pass())); |
| // We always use PseudoTcp to provide a reliable channel. It |
| @@ -158,7 +161,7 @@ scoped_ptr<HostPortAllocator> HostPortAllocator::Create( |
| return result.Pass(); |
| } |
| -HostPortAllocator::HostPortAllocator( |
| +NativePortAllocator::NativePortAllocator( |
| const scoped_refptr<net::URLRequestContextGetter>& url_context, |
| scoped_ptr<talk_base::NetworkManager> network_manager, |
| scoped_ptr<talk_base::PacketSocketFactory> socket_factory) |
| @@ -169,17 +172,19 @@ HostPortAllocator::HostPortAllocator( |
| network_manager_(network_manager.Pass()), |
| socket_factory_(socket_factory.Pass()) {} |
| -HostPortAllocator::~HostPortAllocator() { |
| +NativePortAllocator::~NativePortAllocator() { |
| } |
| -cricket::PortAllocatorSession* HostPortAllocator::CreateSessionInternal( |
| +cricket::PortAllocatorSession* NativePortAllocator::CreateSessionInternal( |
| const std::string& content_name, |
| int component, |
| const std::string& ice_username_fragment, |
| const std::string& ice_password) { |
| - return new HostPortAllocatorSession( |
| + return new NativePortAllocatorSession( |
| this, content_name, component, ice_username_fragment, ice_password, |
| stun_hosts(), relay_hosts(), relay_token(), url_context_); |
| } |
| +} // namespace protocol |
| + |
| } // namespace remoting |