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

Side by Side Diff: webrtc/p2p/base/turnport.cc

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.h ('k') | webrtc/p2p/base/turnport_unittest.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 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 #include "webrtc/p2p/base/turnport.h" 11 #include "webrtc/p2p/base/turnport.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <functional> 14 #include <functional>
15 15
16 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
16 #include "webrtc/p2p/base/common.h" 17 #include "webrtc/p2p/base/common.h"
17 #include "webrtc/p2p/base/stun.h" 18 #include "webrtc/p2p/base/stun.h"
18 #include "webrtc/rtc_base/asyncpacketsocket.h" 19 #include "webrtc/rtc_base/asyncpacketsocket.h"
19 #include "webrtc/rtc_base/byteorder.h" 20 #include "webrtc/rtc_base/byteorder.h"
20 #include "webrtc/rtc_base/checks.h" 21 #include "webrtc/rtc_base/checks.h"
21 #include "webrtc/rtc_base/logging.h" 22 #include "webrtc/rtc_base/logging.h"
22 #include "webrtc/rtc_base/nethelpers.h" 23 #include "webrtc/rtc_base/nethelpers.h"
23 #include "webrtc/rtc_base/ptr_util.h" 24 #include "webrtc/rtc_base/ptr_util.h"
24 #include "webrtc/rtc_base/socketaddress.h" 25 #include "webrtc/rtc_base/socketaddress.h"
25 #include "webrtc/rtc_base/stringencode.h" 26 #include "webrtc/rtc_base/stringencode.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 184
184 TurnPort::TurnPort(rtc::Thread* thread, 185 TurnPort::TurnPort(rtc::Thread* thread,
185 rtc::PacketSocketFactory* factory, 186 rtc::PacketSocketFactory* factory,
186 rtc::Network* network, 187 rtc::Network* network,
187 rtc::AsyncPacketSocket* socket, 188 rtc::AsyncPacketSocket* socket,
188 const std::string& username, 189 const std::string& username,
189 const std::string& password, 190 const std::string& password,
190 const ProtocolAddress& server_address, 191 const ProtocolAddress& server_address,
191 const RelayCredentials& credentials, 192 const RelayCredentials& credentials,
192 int server_priority, 193 int server_priority,
193 const std::string& origin) 194 const std::string& origin,
194 : Port(thread, 195 webrtc::RtcEventLog* event_log)
195 RELAY_PORT_TYPE, 196 : Port(thread, RELAY_PORT_TYPE, factory, network, username, password),
196 factory,
197 network,
198 username,
199 password),
200 server_address_(server_address), 197 server_address_(server_address),
201 credentials_(credentials), 198 credentials_(credentials),
202 socket_(socket), 199 socket_(socket),
203 resolver_(NULL), 200 resolver_(NULL),
204 error_(0), 201 error_(0),
205 request_manager_(thread), 202 request_manager_(thread),
206 next_channel_number_(TURN_CHANNEL_NUMBER_START), 203 next_channel_number_(TURN_CHANNEL_NUMBER_START),
207 state_(STATE_CONNECTING), 204 state_(STATE_CONNECTING),
208 server_priority_(server_priority), 205 server_priority_(server_priority),
209 allocate_mismatch_retries_(0) { 206 allocate_mismatch_retries_(0),
207 event_log_(event_log) {
210 request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket); 208 request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket);
211 request_manager_.set_origin(origin); 209 request_manager_.set_origin(origin);
212 } 210 }
213 211
214 TurnPort::TurnPort(rtc::Thread* thread, 212 TurnPort::TurnPort(rtc::Thread* thread,
215 rtc::PacketSocketFactory* factory, 213 rtc::PacketSocketFactory* factory,
216 rtc::Network* network, 214 rtc::Network* network,
217 uint16_t min_port, 215 uint16_t min_port,
218 uint16_t max_port, 216 uint16_t max_port,
219 const std::string& username, 217 const std::string& username,
220 const std::string& password, 218 const std::string& password,
221 const ProtocolAddress& server_address, 219 const ProtocolAddress& server_address,
222 const RelayCredentials& credentials, 220 const RelayCredentials& credentials,
223 int server_priority, 221 int server_priority,
224 const std::string& origin) 222 const std::string& origin,
223 webrtc::RtcEventLog* event_log)
225 : Port(thread, 224 : Port(thread,
226 RELAY_PORT_TYPE, 225 RELAY_PORT_TYPE,
227 factory, 226 factory,
228 network, 227 network,
229 min_port, 228 min_port,
230 max_port, 229 max_port,
231 username, 230 username,
232 password), 231 password),
233 server_address_(server_address), 232 server_address_(server_address),
234 credentials_(credentials), 233 credentials_(credentials),
235 socket_(NULL), 234 socket_(NULL),
236 resolver_(NULL), 235 resolver_(NULL),
237 error_(0), 236 error_(0),
238 request_manager_(thread), 237 request_manager_(thread),
239 next_channel_number_(TURN_CHANNEL_NUMBER_START), 238 next_channel_number_(TURN_CHANNEL_NUMBER_START),
240 state_(STATE_CONNECTING), 239 state_(STATE_CONNECTING),
241 server_priority_(server_priority), 240 server_priority_(server_priority),
242 allocate_mismatch_retries_(0) { 241 allocate_mismatch_retries_(0),
242 event_log_(event_log) {
243 request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket); 243 request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket);
244 request_manager_.set_origin(origin); 244 request_manager_.set_origin(origin);
245 } 245 }
246 246
247 TurnPort::~TurnPort() { 247 TurnPort::~TurnPort() {
248 // TODO(juberti): Should this even be necessary? 248 // TODO(juberti): Should this even be necessary?
249 249
250 // release the allocation by sending a refresh with 250 // release the allocation by sending a refresh with
251 // lifetime 0. 251 // lifetime 0.
252 if (ready()) { 252 if (ready()) {
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 if (resolver_->GetError() != 0 && server_address_.proto == PROTO_TCP) { 701 if (resolver_->GetError() != 0 && server_address_.proto == PROTO_TCP) {
702 if (!CreateTurnClientSocket()) { 702 if (!CreateTurnClientSocket()) {
703 OnAllocateError(); 703 OnAllocateError();
704 } 704 }
705 return; 705 return;
706 } 706 }
707 707
708 // Copy the original server address in |resolved_address|. For TLS based 708 // Copy the original server address in |resolved_address|. For TLS based
709 // sockets we need hostname along with resolved address. 709 // sockets we need hostname along with resolved address.
710 rtc::SocketAddress resolved_address = server_address_.address; 710 rtc::SocketAddress resolved_address = server_address_.address;
711 if (resolver_->GetError() != 0 || 711
712 !resolver_->GetResolvedAddress(Network()->GetBestIP().family(), 712 bool found = resolver_->GetError() == 0 &&
713 &resolved_address)) { 713 resolver_->GetResolvedAddress(Network()->GetBestIP().family(),
714 LOG_J(LS_WARNING, this) << "TURN host lookup received error " 714 &resolved_address);
715 << resolver_->GetError(); 715 if (event_log_) {
716 int error = resolver_->GetError();
717 event_log_->LogHostLookupResult(
718 found ? 0 : (error == 0 ? -1 : error),
719 resolver_->GetResolveElapsedTimeMilliseconds());
720 }
721
722 if (!found) {
723 LOG_J(LS_WARNING, this)
724 << "TURN host lookup for " << resolved_address.hostname()
725 << " received error " << resolver_->GetError() << " after "
726 << resolver_->GetResolveElapsedTimeMilliseconds() << " ms";
716 error_ = resolver_->GetError(); 727 error_ = resolver_->GetError();
717 OnAllocateError(); 728 OnAllocateError();
718 return; 729 return;
719 } 730 }
731
732 LOG_J(LS_INFO, this) << "TURN host lookup for " << resolved_address.hostname()
733 << " completed in "
734 << resolver_->GetResolveElapsedTimeMilliseconds()
735 << " ms";
736
720 // Signal needs both resolved and unresolved address. After signal is sent 737 // Signal needs both resolved and unresolved address. After signal is sent
721 // we can copy resolved address back into |server_address_|. 738 // we can copy resolved address back into |server_address_|.
722 SignalResolvedServerAddress(this, server_address_.address, 739 SignalResolvedServerAddress(this, server_address_.address,
723 resolved_address); 740 resolved_address);
724 server_address_.address = resolved_address; 741 server_address_.address = resolved_address;
725 PrepareAddress(); 742 PrepareAddress();
726 } 743 }
727 744
728 void TurnPort::OnSendStunPacket(const void* data, size_t size, 745 void TurnPort::OnSendStunPacket(const void* data, size_t size,
729 StunRequest* request) { 746 StunRequest* request) {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 } else { 1608 } else {
1592 state_ = STATE_UNBOUND; 1609 state_ = STATE_UNBOUND;
1593 port_->FailAndPruneConnection(ext_addr_); 1610 port_->FailAndPruneConnection(ext_addr_);
1594 } 1611 }
1595 } 1612 }
1596 void TurnEntry::OnChannelBindTimeout() { 1613 void TurnEntry::OnChannelBindTimeout() {
1597 state_ = STATE_UNBOUND; 1614 state_ = STATE_UNBOUND;
1598 port_->FailAndPruneConnection(ext_addr_); 1615 port_->FailAndPruneConnection(ext_addr_);
1599 } 1616 }
1600 } // namespace cricket 1617 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698