Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: remoting/test/fake_port_allocator.cc

Issue 1521883006: Add TransportContext class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/test/fake_port_allocator.h ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "remoting/test/fake_port_allocator.h" 5 #include "remoting/test/fake_port_allocator.h"
6 6
7 #include "remoting/test/fake_network_dispatcher.h" 7 #include "remoting/test/fake_network_dispatcher.h"
8 #include "remoting/test/fake_network_manager.h" 8 #include "remoting/test/fake_network_manager.h"
9 #include "remoting/test/fake_socket_factory.h" 9 #include "remoting/test/fake_socket_factory.h"
10 #include "third_party/webrtc/p2p/client/basicportallocator.h"
10 11
11 namespace remoting { 12 namespace remoting {
12 13
13 namespace { 14 namespace {
14 15
15 class FakePortAllocatorSession 16 class FakePortAllocatorSession
16 : public cricket::HttpPortAllocatorSessionBase { 17 : public cricket::HttpPortAllocatorSessionBase {
17 public: 18 public:
18 FakePortAllocatorSession( 19 FakePortAllocatorSession(
19 cricket::HttpPortAllocatorBase* allocator, 20 cricket::HttpPortAllocatorBase* allocator,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 76 }
76 77
77 void FakePortAllocatorSession::SendSessionRequest( 78 void FakePortAllocatorSession::SendSessionRequest(
78 const std::string& host, 79 const std::string& host,
79 int port) { 80 int port) {
80 ReceiveSessionResponse(std::string()); 81 ReceiveSessionResponse(std::string());
81 } 82 }
82 83
83 } // namespace 84 } // namespace
84 85
85 // static 86 FakePortAllocator::FakePortAllocator(rtc::NetworkManager* network_manager,
86 scoped_ptr<FakePortAllocator> FakePortAllocator::Create( 87 FakePacketSocketFactory* socket_factory)
87 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher) { 88 : HttpPortAllocatorBase(network_manager, socket_factory, std::string()) {}
88 scoped_ptr<FakePacketSocketFactory> socket_factory( 89 FakePortAllocator::~FakePortAllocator() {}
89 new FakePacketSocketFactory(fake_network_dispatcher.get()));
90 scoped_ptr<rtc::NetworkManager> network_manager(
91 new FakeNetworkManager(socket_factory->GetAddress()));
92
93 return make_scoped_ptr(
94 new FakePortAllocator(network_manager.Pass(), socket_factory.Pass()));
95 }
96
97 FakePortAllocator::FakePortAllocator(
98 scoped_ptr<rtc::NetworkManager> network_manager,
99 scoped_ptr<FakePacketSocketFactory> socket_factory)
100 : HttpPortAllocatorBase(network_manager.get(),
101 socket_factory.get(),
102 std::string()),
103 network_manager_(network_manager.Pass()),
104 socket_factory_(socket_factory.Pass()) {
105 set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
106 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
107 cricket::PORTALLOCATOR_ENABLE_IPV6 |
108 cricket::PORTALLOCATOR_DISABLE_STUN |
109 cricket::PORTALLOCATOR_DISABLE_RELAY);
110 }
111
112 FakePortAllocator::~FakePortAllocator() {
113 }
114 90
115 cricket::PortAllocatorSession* FakePortAllocator::CreateSessionInternal( 91 cricket::PortAllocatorSession* FakePortAllocator::CreateSessionInternal(
116 const std::string& content_name, 92 const std::string& content_name,
117 int component, 93 int component,
118 const std::string& ice_username_fragment, 94 const std::string& ice_username_fragment,
119 const std::string& ice_password) { 95 const std::string& ice_password) {
120 return new FakePortAllocatorSession( 96 return new FakePortAllocatorSession(
121 this, content_name, component, ice_username_fragment, ice_password, 97 this, content_name, component, ice_username_fragment, ice_password,
122 stun_hosts(), relay_hosts(), relay_token()); 98 stun_hosts(), relay_hosts(), relay_token());
123 } 99 }
124 100
101 FakePortAllocatorFactory::FakePortAllocatorFactory(
102 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher) {
103 socket_factory_.reset(
104 new FakePacketSocketFactory(fake_network_dispatcher.get()));
105 network_manager_.reset(new FakeNetworkManager(socket_factory_->GetAddress()));
106 }
107
108 FakePortAllocatorFactory::~FakePortAllocatorFactory() {}
109
110 scoped_ptr<cricket::HttpPortAllocatorBase>
111 FakePortAllocatorFactory::CreatePortAllocator() {
112 return make_scoped_ptr(
113 new FakePortAllocator(network_manager_.get(), socket_factory_.get()));
114 }
115
125 } // namespace remoting 116 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/fake_port_allocator.h ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698