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

Side by Side Diff: webrtc/rtc_base/nethelpers.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/rtc_base/nethelpers.h ('k') | webrtc/rtc_tools/event_log_visualizer/analyzer.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 2008 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2008 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 } 78 }
79 } 79 }
80 freeaddrinfo(result); 80 freeaddrinfo(result);
81 return 0; 81 return 0;
82 #endif // !__native_client__ 82 #endif // !__native_client__
83 } 83 }
84 84
85 // AsyncResolver 85 // AsyncResolver
86 AsyncResolver::AsyncResolver() 86 AsyncResolver::AsyncResolver()
87 : SignalThread(false /* use_socket_server */), error_(-1) {} 87 : SignalThread(false /* use_socket_server */),
88 error_(-1), resolve_time_ms_(0) {}
88 89
89 AsyncResolver::~AsyncResolver() = default; 90 AsyncResolver::~AsyncResolver() = default;
90 91
91 void AsyncResolver::Start(const SocketAddress& addr) { 92 void AsyncResolver::Start(const SocketAddress& addr) {
92 addr_ = addr; 93 addr_ = addr;
93 // SignalThred Start will kickoff the resolve process. 94 // SignalThred Start will kickoff the resolve process.
94 SignalThread::Start(); 95 SignalThread::Start();
95 } 96 }
96 97
97 bool AsyncResolver::GetResolvedAddress(int family, SocketAddress* addr) const { 98 bool AsyncResolver::GetResolvedAddress(int family, SocketAddress* addr) const {
98 if (error_ != 0 || addresses_.empty()) 99 if (error_ != 0 || addresses_.empty())
99 return false; 100 return false;
100 101
101 *addr = addr_; 102 *addr = addr_;
102 for (size_t i = 0; i < addresses_.size(); ++i) { 103 for (size_t i = 0; i < addresses_.size(); ++i) {
103 if (family == addresses_[i].family()) { 104 if (family == addresses_[i].family()) {
104 addr->SetResolvedIP(addresses_[i]); 105 addr->SetResolvedIP(addresses_[i]);
105 return true; 106 return true;
106 } 107 }
107 } 108 }
108 return false; 109 return false;
109 } 110 }
110 111
112 int64_t AsyncResolver::GetResolveElapsedTimeMilliseconds() const {
113 return resolve_time_ms_;
114 }
115
111 int AsyncResolver::GetError() const { 116 int AsyncResolver::GetError() const {
112 return error_; 117 return error_;
113 } 118 }
114 119
115 void AsyncResolver::Destroy(bool wait) { 120 void AsyncResolver::Destroy(bool wait) {
116 SignalThread::Destroy(wait); 121 SignalThread::Destroy(wait);
117 } 122 }
118 123
119 void AsyncResolver::DoWork() { 124 void AsyncResolver::DoWork() {
125 int64_t start = rtc::TimeMillis();
120 error_ = ResolveHostname(addr_.hostname().c_str(), addr_.family(), 126 error_ = ResolveHostname(addr_.hostname().c_str(), addr_.family(),
121 &addresses_); 127 &addresses_);
128 int64_t stop = rtc::TimeMillis();
129 resolve_time_ms_ = stop - start;
122 } 130 }
123 131
124 void AsyncResolver::OnWorkDone() { 132 void AsyncResolver::OnWorkDone() {
125 SignalDone(this); 133 SignalDone(this);
126 } 134 }
127 135
128 const char* inet_ntop(int af, const void *src, char* dst, socklen_t size) { 136 const char* inet_ntop(int af, const void *src, char* dst, socklen_t size) {
129 #if defined(WEBRTC_WIN) 137 #if defined(WEBRTC_WIN)
130 return win32_inet_ntop(af, src, dst, size); 138 return win32_inet_ntop(af, src, dst, size);
131 #else 139 #else
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 break; 218 break;
211 } 219 }
212 } 220 }
213 freeifaddrs(ifa); 221 freeifaddrs(ifa);
214 return has_ipv6; 222 return has_ipv6;
215 #else 223 #else
216 return true; 224 return true;
217 #endif 225 #endif
218 } 226 }
219 } // namespace rtc 227 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/rtc_base/nethelpers.h ('k') | webrtc/rtc_tools/event_log_visualizer/analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698