OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // An implementation of cricket::PortAllocator for libjingle that is | |
6 // used by the remoting host. The only difference from | |
7 // cricket::HttpPortAllocator is that it uses Chromium's HTTP stack | |
8 // when creating relay sessions. | |
9 | |
10 #ifndef REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ | |
11 #define REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ | |
12 | |
13 #include <set> | |
14 | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "remoting/host/url_fetcher.h" | |
17 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" | |
18 | |
19 namespace net { | |
20 class URLRequestContextGetter; | |
21 } // namespace net | |
22 | |
23 namespace remoting { | |
24 | |
25 struct NetworkSettings; | |
26 | |
27 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.
| |
28 : public cricket::HttpPortAllocatorSessionBase { | |
29 public: | |
30 HostPortAllocatorSession( | |
31 cricket::HttpPortAllocatorBase* allocator, | |
32 const std::string& channel_name, | |
33 int component, | |
34 const std::vector<talk_base::SocketAddress>& stun_hosts, | |
35 const std::vector<std::string>& relay_hosts, | |
36 const std::string& relay, | |
37 const scoped_refptr<net::URLRequestContextGetter>& url_context); | |
38 virtual ~HostPortAllocatorSession(); | |
39 | |
40 // cricket::HttpPortAllocatorBase overrides. | |
41 virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; | |
42 virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE; | |
43 | |
44 private: | |
45 void OnRequestDone(UrlFetcher* url_fetcher, | |
46 const net::URLRequestStatus& status, | |
47 int response_code, | |
48 const std::string& response); | |
Wez
2012/04/27 23:23:21
OnRequestDone -> OnSessionRequestDone
Sergey Ulanov
2012/04/28 00:05:27
Done.
| |
49 | |
50 scoped_refptr<net::URLRequestContextGetter> url_context_; | |
51 std::set<UrlFetcher*> url_fetchers_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession); | |
54 }; | |
55 | |
56 class HostPortAllocator : public cricket::HttpPortAllocatorBase { | |
57 public: | |
58 static scoped_ptr<HostPortAllocator> Create( | |
59 const scoped_refptr<net::URLRequestContextGetter>& url_context, | |
60 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
| |
61 | |
62 virtual ~HostPortAllocator(); | |
63 | |
64 // cricket::HttpPortAllocatorBase overrides. | |
65 virtual cricket::PortAllocatorSession* CreateSession( | |
66 const std::string& channel_name, | |
67 int component) OVERRIDE; | |
68 | |
69 private: | |
70 HostPortAllocator( | |
71 const scoped_refptr<net::URLRequestContextGetter>& url_context, | |
72 scoped_ptr<talk_base::NetworkManager> network_manager, | |
73 scoped_ptr<talk_base::PacketSocketFactory> socket_factory); | |
74 | |
75 scoped_refptr<net::URLRequestContextGetter> url_context_; | |
76 scoped_ptr<talk_base::NetworkManager> network_manager_; | |
77 scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(HostPortAllocator); | |
80 }; | |
81 | |
82 } // namespace remoting | |
83 | |
84 #endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ | |
OLD | NEW |