| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ | 11 #ifndef WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ |
| 12 #define WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ | 12 #define WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/p2p/client/basicportallocator.h" | 18 #include "webrtc/p2p/client/basicportallocator.h" |
| 19 | 19 |
| 20 class HttpPortAllocatorTest_TestSessionRequestUrl_Test; | 20 class HttpPortAllocatorTest_TestSessionRequestUrl_Test; |
| 21 | 21 |
| 22 namespace rtc { | 22 namespace rtc { |
| 23 class AsyncHttpRequest; | 23 class AsyncHttpRequest; |
| 24 class SignalThread; | 24 class SignalThread; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace cricket { | 27 namespace cricket { |
| 28 | 28 |
| 29 // TODO(pthatcher): Remove this. It's only used by chromoting, so we |
| 30 // should just move this code there. It's used in these places in |
| 31 // chromium: |
| 32 // src/remoting/protocol/chromium_port_allocator.cc |
| 33 // src/remoting/client/plugin/pepper_port_allocator.cc |
| 34 // src/remoting/protocol/libjingle_transport_factory.cc |
| 29 class HttpPortAllocatorBase : public BasicPortAllocator { | 35 class HttpPortAllocatorBase : public BasicPortAllocator { |
| 30 public: | 36 public: |
| 31 // The number of HTTP requests we should attempt before giving up. | 37 // The number of HTTP requests we should attempt before giving up. |
| 32 static const int kNumRetries; | 38 static const int kNumRetries; |
| 33 | 39 |
| 34 // Records the URL that we will GET in order to create a session. | 40 // Records the URL that we will GET in order to create a session. |
| 35 static const char kCreateSessionURL[]; | 41 static const char kCreateSessionURL[]; |
| 36 | 42 |
| 37 HttpPortAllocatorBase(rtc::NetworkManager* network_manager, | 43 HttpPortAllocatorBase(rtc::NetworkManager* network_manager, |
| 38 const std::string& user_agent); | 44 const std::string& user_agent); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 129 } |
| 124 | 130 |
| 125 private: | 131 private: |
| 126 std::vector<std::string> relay_hosts_; | 132 std::vector<std::string> relay_hosts_; |
| 127 std::vector<rtc::SocketAddress> stun_hosts_; | 133 std::vector<rtc::SocketAddress> stun_hosts_; |
| 128 std::string relay_token_; | 134 std::string relay_token_; |
| 129 std::string agent_; | 135 std::string agent_; |
| 130 int attempts_; | 136 int attempts_; |
| 131 }; | 137 }; |
| 132 | 138 |
| 133 class HttpPortAllocator : public HttpPortAllocatorBase { | |
| 134 public: | |
| 135 HttpPortAllocator(rtc::NetworkManager* network_manager, | |
| 136 const std::string& user_agent); | |
| 137 HttpPortAllocator(rtc::NetworkManager* network_manager, | |
| 138 rtc::PacketSocketFactory* socket_factory, | |
| 139 const std::string& user_agent); | |
| 140 virtual ~HttpPortAllocator(); | |
| 141 virtual PortAllocatorSession* CreateSessionInternal( | |
| 142 const std::string& content_name, | |
| 143 int component, | |
| 144 const std::string& ice_ufrag, const std::string& ice_pwd); | |
| 145 }; | |
| 146 | |
| 147 class HttpPortAllocatorSession : public HttpPortAllocatorSessionBase { | |
| 148 public: | |
| 149 HttpPortAllocatorSession( | |
| 150 HttpPortAllocator* allocator, | |
| 151 const std::string& content_name, | |
| 152 int component, | |
| 153 const std::string& ice_ufrag, | |
| 154 const std::string& ice_pwd, | |
| 155 const std::vector<rtc::SocketAddress>& stun_hosts, | |
| 156 const std::vector<std::string>& relay_hosts, | |
| 157 const std::string& relay, | |
| 158 const std::string& agent); | |
| 159 virtual ~HttpPortAllocatorSession(); | |
| 160 | |
| 161 virtual void SendSessionRequest(const std::string& host, int port); | |
| 162 | |
| 163 protected: | |
| 164 // Protected for diagnostics. | |
| 165 virtual void OnRequestDone(rtc::SignalThread* request); | |
| 166 | |
| 167 private: | |
| 168 std::list<rtc::AsyncHttpRequest*> requests_; | |
| 169 }; | |
| 170 | |
| 171 } // namespace cricket | 139 } // namespace cricket |
| 172 | 140 |
| 173 #endif // WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ | 141 #endif // WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_ |
| OLD | NEW |