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