OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ | 5 #ifndef REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ |
6 #define REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ | 6 #define REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "remoting/protocol/port_allocator_factory.h" |
12 #include "third_party/webrtc/p2p/client/httpportallocator.h" | 13 #include "third_party/webrtc/p2p/client/httpportallocator.h" |
13 | 14 |
| 15 namespace rtc { |
| 16 class NetworkManager; |
| 17 } // namespace rtc |
| 18 |
14 namespace remoting { | 19 namespace remoting { |
15 | 20 |
16 class FakeNetworkDispatcher; | 21 class FakeNetworkDispatcher; |
17 class FakePacketSocketFactory; | 22 class FakePacketSocketFactory; |
18 | 23 |
19 class FakePortAllocator : public cricket::HttpPortAllocatorBase { | 24 class FakePortAllocator : public cricket::HttpPortAllocatorBase { |
20 public: | 25 public: |
21 static scoped_ptr<FakePortAllocator> Create( | 26 FakePortAllocator(rtc::NetworkManager* network_manager, |
22 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher); | 27 FakePacketSocketFactory* socket_factory); |
23 | |
24 ~FakePortAllocator() override; | 28 ~FakePortAllocator() override; |
25 | 29 |
26 FakePacketSocketFactory* socket_factory() { return socket_factory_.get(); } | |
27 | |
28 // cricket::BasicPortAllocator overrides. | 30 // cricket::BasicPortAllocator overrides. |
29 cricket::PortAllocatorSession* CreateSessionInternal( | 31 cricket::PortAllocatorSession* CreateSessionInternal( |
30 const std::string& content_name, | 32 const std::string& content_name, |
31 int component, | 33 int component, |
32 const std::string& ice_username_fragment, | 34 const std::string& ice_username_fragment, |
33 const std::string& ice_password) override; | 35 const std::string& ice_password) override; |
34 | 36 |
35 private: | 37 private: |
36 FakePortAllocator(scoped_ptr<rtc::NetworkManager> network_manager, | 38 DISALLOW_COPY_AND_ASSIGN(FakePortAllocator); |
37 scoped_ptr<FakePacketSocketFactory> socket_factory); | 39 }; |
38 | 40 |
| 41 class FakePortAllocatorFactory : public protocol::PortAllocatorFactory { |
| 42 public: |
| 43 FakePortAllocatorFactory( |
| 44 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher); |
| 45 ~FakePortAllocatorFactory() override; |
| 46 |
| 47 FakePacketSocketFactory* socket_factory() { return socket_factory_.get(); } |
| 48 |
| 49 // PortAllocatorFactory interface. |
| 50 scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override; |
| 51 |
| 52 private: |
39 scoped_ptr<rtc::NetworkManager> network_manager_; | 53 scoped_ptr<rtc::NetworkManager> network_manager_; |
40 scoped_ptr<FakePacketSocketFactory> socket_factory_; | 54 scoped_ptr<FakePacketSocketFactory> socket_factory_; |
41 | 55 |
42 DISALLOW_COPY_AND_ASSIGN(FakePortAllocator); | 56 DISALLOW_COPY_AND_ASSIGN(FakePortAllocatorFactory); |
43 }; | 57 }; |
44 | 58 |
45 } // namespace remoting | 59 } // namespace remoting |
46 | 60 |
47 #endif // REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ | 61 #endif // REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_ |
OLD | NEW |