forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_port_allocator.h
63 lines (47 loc) · 1.92 KB
/
fake_port_allocator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_
#define REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_
#include <memory>
#include <set>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "remoting/protocol/port_allocator_factory.h"
#include "third_party/webrtc/p2p/client/basicportallocator.h"
namespace remoting {
class FakeNetworkDispatcher;
class FakePacketSocketFactory;
class FakePortAllocator : public cricket::BasicPortAllocator {
public:
FakePortAllocator(
rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
scoped_refptr<protocol::TransportContext> transport_context_);
~FakePortAllocator() override;
// cricket::BasicPortAllocator overrides.
cricket::PortAllocatorSession* CreateSessionInternal(
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
const std::string& ice_password) override;
private:
scoped_refptr<protocol::TransportContext> transport_context_;
DISALLOW_COPY_AND_ASSIGN(FakePortAllocator);
};
class FakePortAllocatorFactory : public protocol::PortAllocatorFactory {
public:
FakePortAllocatorFactory(
scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher);
~FakePortAllocatorFactory() override;
FakePacketSocketFactory* socket_factory() { return socket_factory_.get(); }
// PortAllocatorFactory interface.
std::unique_ptr<cricket::PortAllocator> CreatePortAllocator(
scoped_refptr<protocol::TransportContext> transport_context) override;
private:
std::unique_ptr<rtc::NetworkManager> network_manager_;
std::unique_ptr<FakePacketSocketFactory> socket_factory_;
DISALLOW_COPY_AND_ASSIGN(FakePortAllocatorFactory);
};
} // namespace remoting
#endif // REMOTING_TEST_FAKE_PORT_ALLOCATOR_H_