Index: remoting/host/host_port_allocator.h |
diff --git a/remoting/host/host_port_allocator.h b/remoting/host/host_port_allocator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..df02734ca6ff866e0393cb34fc530279cd30754f |
--- /dev/null |
+++ b/remoting/host/host_port_allocator.h |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// An implementation of cricket::PortAllocator for libjingle that is |
+// used by the remoting host. The only difference from |
+// cricket::HttpPortAllocator is that it uses Chromium's HTTP stack |
+// when creating relay sessions. |
+ |
+#ifndef REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ |
+#define REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ |
+ |
+#include <set> |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "remoting/host/url_fetcher.h" |
+#include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" |
+ |
+namespace net { |
+class URLRequestContextGetter; |
+} // namespace net |
+ |
+namespace remoting { |
+ |
+struct NetworkSettings; |
+ |
+class HostPortAllocatorSession |
Wez
2012/04/27 23:23:21
Does this need to be defined in the header? It's
Sergey Ulanov
2012/04/28 00:05:27
Done.
|
+ : public cricket::HttpPortAllocatorSessionBase { |
+ public: |
+ HostPortAllocatorSession( |
+ cricket::HttpPortAllocatorBase* allocator, |
+ const std::string& channel_name, |
+ int component, |
+ const std::vector<talk_base::SocketAddress>& stun_hosts, |
+ const std::vector<std::string>& relay_hosts, |
+ const std::string& relay, |
+ const scoped_refptr<net::URLRequestContextGetter>& url_context); |
+ virtual ~HostPortAllocatorSession(); |
+ |
+ // cricket::HttpPortAllocatorBase overrides. |
+ virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; |
+ virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE; |
+ |
+ private: |
+ void OnRequestDone(UrlFetcher* url_fetcher, |
+ const net::URLRequestStatus& status, |
+ int response_code, |
+ const std::string& response); |
Wez
2012/04/27 23:23:21
OnRequestDone -> OnSessionRequestDone
Sergey Ulanov
2012/04/28 00:05:27
Done.
|
+ |
+ scoped_refptr<net::URLRequestContextGetter> url_context_; |
+ std::set<UrlFetcher*> url_fetchers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession); |
+}; |
+ |
+class HostPortAllocator : public cricket::HttpPortAllocatorBase { |
+ public: |
+ static scoped_ptr<HostPortAllocator> Create( |
+ const scoped_refptr<net::URLRequestContextGetter>& url_context, |
+ const NetworkSettings& network_settings); |
Wez
2012/04/27 23:23:21
Add a comment explaining what this class does that
Sergey Ulanov
2012/04/28 00:05:27
There was already a comment about it at the top of
|
+ |
+ virtual ~HostPortAllocator(); |
+ |
+ // cricket::HttpPortAllocatorBase overrides. |
+ virtual cricket::PortAllocatorSession* CreateSession( |
+ const std::string& channel_name, |
+ int component) OVERRIDE; |
+ |
+ private: |
+ HostPortAllocator( |
+ const scoped_refptr<net::URLRequestContextGetter>& url_context, |
+ scoped_ptr<talk_base::NetworkManager> network_manager, |
+ scoped_ptr<talk_base::PacketSocketFactory> socket_factory); |
+ |
+ scoped_refptr<net::URLRequestContextGetter> url_context_; |
+ scoped_ptr<talk_base::NetworkManager> network_manager_; |
+ scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HostPortAllocator); |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ |