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

Side by Side Diff: webrtc/p2p/client/basicportallocator.h

Issue 2996933003: Add logging of host lookups made by TurnPort to the RtcEventLog. (Closed)
Patch Set: review Created 3 years, 3 months 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 | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/client/basicportallocator.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 /* 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_BASICPORTALLOCATOR_H_ 11 #ifndef WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
12 #define WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 12 #define WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/p2p/base/portallocator.h" 18 #include "webrtc/p2p/base/portallocator.h"
19 #include "webrtc/rtc_base/checks.h" 19 #include "webrtc/rtc_base/checks.h"
20 #include "webrtc/rtc_base/messagequeue.h" 20 #include "webrtc/rtc_base/messagequeue.h"
21 #include "webrtc/rtc_base/network.h" 21 #include "webrtc/rtc_base/network.h"
22 #include "webrtc/rtc_base/thread.h" 22 #include "webrtc/rtc_base/thread.h"
23 23
24 namespace webrtc {
25 class RtcEventLog;
26 } // namespace webrtc
27
24 namespace cricket { 28 namespace cricket {
25 29
26 class BasicPortAllocator : public PortAllocator { 30 class BasicPortAllocator : public PortAllocator {
27 public: 31 public:
28 BasicPortAllocator(rtc::NetworkManager* network_manager, 32 BasicPortAllocator(rtc::NetworkManager* network_manager,
29 rtc::PacketSocketFactory* socket_factory); 33 rtc::PacketSocketFactory* socket_factory,
34 webrtc::RtcEventLog* event_log);
30 explicit BasicPortAllocator(rtc::NetworkManager* network_manager); 35 explicit BasicPortAllocator(rtc::NetworkManager* network_manager);
31 BasicPortAllocator(rtc::NetworkManager* network_manager, 36 BasicPortAllocator(rtc::NetworkManager* network_manager,
32 rtc::PacketSocketFactory* socket_factory, 37 rtc::PacketSocketFactory* socket_factory,
33 const ServerAddresses& stun_servers); 38 const ServerAddresses& stun_servers);
34 BasicPortAllocator(rtc::NetworkManager* network_manager, 39 BasicPortAllocator(rtc::NetworkManager* network_manager,
35 const ServerAddresses& stun_servers, 40 const ServerAddresses& stun_servers,
36 const rtc::SocketAddress& relay_server_udp, 41 const rtc::SocketAddress& relay_server_udp,
37 const rtc::SocketAddress& relay_server_tcp, 42 const rtc::SocketAddress& relay_server_tcp,
38 const rtc::SocketAddress& relay_server_ssl); 43 const rtc::SocketAddress& relay_server_ssl);
39 virtual ~BasicPortAllocator(); 44 virtual ~BasicPortAllocator();
40 45
41 // Set to kDefaultNetworkIgnoreMask by default. 46 // Set to kDefaultNetworkIgnoreMask by default.
42 void SetNetworkIgnoreMask(int network_ignore_mask) override { 47 void SetNetworkIgnoreMask(int network_ignore_mask) override {
43 // TODO(phoglund): implement support for other types than loopback. 48 // TODO(phoglund): implement support for other types than loopback.
44 // See https://code.google.com/p/webrtc/issues/detail?id=4288. 49 // See https://code.google.com/p/webrtc/issues/detail?id=4288.
45 // Then remove set_network_ignore_list from NetworkManager. 50 // Then remove set_network_ignore_list from NetworkManager.
46 network_ignore_mask_ = network_ignore_mask; 51 network_ignore_mask_ = network_ignore_mask;
47 } 52 }
48 53
49 int network_ignore_mask() const { return network_ignore_mask_; } 54 int network_ignore_mask() const { return network_ignore_mask_; }
50 55
51 rtc::NetworkManager* network_manager() const { return network_manager_; } 56 rtc::NetworkManager* network_manager() const { return network_manager_; }
57 webrtc::RtcEventLog* event_log() const { return event_log_; }
52 58
53 // If socket_factory() is set to NULL each PortAllocatorSession 59 // If socket_factory() is set to NULL each PortAllocatorSession
54 // creates its own socket factory. 60 // creates its own socket factory.
55 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 61 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
56 62
57 PortAllocatorSession* CreateSessionInternal( 63 PortAllocatorSession* CreateSessionInternal(
58 const std::string& content_name, 64 const std::string& content_name,
59 int component, 65 int component,
60 const std::string& ice_ufrag, 66 const std::string& ice_ufrag,
61 const std::string& ice_pwd) override; 67 const std::string& ice_pwd) override;
62 68
63 // Convenience method that adds a TURN server to the configuration. 69 // Convenience method that adds a TURN server to the configuration.
64 void AddTurnServer(const RelayServerConfig& turn_server); 70 void AddTurnServer(const RelayServerConfig& turn_server);
65 71
66 private: 72 private:
67 void Construct(); 73 void Construct();
68 74
69 void OnIceRegathering(PortAllocatorSession* session, 75 void OnIceRegathering(PortAllocatorSession* session,
70 IceRegatheringReason reason); 76 IceRegatheringReason reason);
71 77
72 rtc::NetworkManager* network_manager_; 78 rtc::NetworkManager* network_manager_;
73 rtc::PacketSocketFactory* socket_factory_; 79 rtc::PacketSocketFactory* socket_factory_;
80 webrtc::RtcEventLog* event_log_;
74 bool allow_tcp_listen_; 81 bool allow_tcp_listen_;
75 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask; 82 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask;
76 }; 83 };
77 84
78 struct PortConfiguration; 85 struct PortConfiguration;
79 class AllocationSequence; 86 class AllocationSequence;
80 87
81 enum class SessionState { 88 enum class SessionState {
82 GATHERING, // Actively allocating ports and gathering candidates. 89 GATHERING, // Actively allocating ports and gathering candidates.
83 CLEARED, // Current allocation process has been stopped but may start 90 CLEARED, // Current allocation process has been stopped but may start
84 // new ones. 91 // new ones.
85 STOPPED // This session has completely stopped, no new allocation 92 STOPPED // This session has completely stopped, no new allocation
86 // process will be started. 93 // process will be started.
87 }; 94 };
88 95
89 class BasicPortAllocatorSession : public PortAllocatorSession, 96 class BasicPortAllocatorSession : public PortAllocatorSession,
90 public rtc::MessageHandler { 97 public rtc::MessageHandler {
91 public: 98 public:
92 BasicPortAllocatorSession(BasicPortAllocator* allocator, 99 BasicPortAllocatorSession(BasicPortAllocator* allocator,
93 const std::string& content_name, 100 const std::string& content_name,
94 int component, 101 int component,
95 const std::string& ice_ufrag, 102 const std::string& ice_ufrag,
96 const std::string& ice_pwd); 103 const std::string& ice_pwd);
97 ~BasicPortAllocatorSession(); 104 ~BasicPortAllocatorSession();
98 105
99 virtual BasicPortAllocator* allocator() { return allocator_; } 106 virtual BasicPortAllocator* allocator() { return allocator_; }
100 rtc::Thread* network_thread() { return network_thread_; } 107 rtc::Thread* network_thread() { return network_thread_; }
101 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 108 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
109 webrtc::RtcEventLog* event_log() { return allocator_->event_log(); }
102 110
103 void SetCandidateFilter(uint32_t filter) override; 111 void SetCandidateFilter(uint32_t filter) override;
104 void StartGettingPorts() override; 112 void StartGettingPorts() override;
105 void StopGettingPorts() override; 113 void StopGettingPorts() override;
106 void ClearGettingPorts() override; 114 void ClearGettingPorts() override;
107 bool IsGettingPorts() override { return state_ == SessionState::GATHERING; } 115 bool IsGettingPorts() override { return state_ == SessionState::GATHERING; }
108 bool IsCleared() const override { return state_ == SessionState::CLEARED; } 116 bool IsCleared() const override { return state_ == SessionState::CLEARED; }
109 bool IsStopped() const override { return state_ == SessionState::STOPPED; } 117 bool IsStopped() const override { return state_ == SessionState::STOPPED; }
110 // These will all be cricket::Ports. 118 // These will all be cricket::Ports.
111 std::vector<PortInterface*> ReadyPorts() const override; 119 std::vector<PortInterface*> ReadyPorts() const override;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; 382 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_;
375 // There will be only one udp port per AllocationSequence. 383 // There will be only one udp port per AllocationSequence.
376 UDPPort* udp_port_; 384 UDPPort* udp_port_;
377 std::vector<TurnPort*> turn_ports_; 385 std::vector<TurnPort*> turn_ports_;
378 int phase_; 386 int phase_;
379 }; 387 };
380 388
381 } // namespace cricket 389 } // namespace cricket
382 390
383 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 391 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698