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

Side by Side Diff: net/dns/host_resolver_impl.cc

Issue 1116263003: Remove unnecessary ScopedTrackers for what turned out to be IsGloballyReachable() jank. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return hostname.size() > kSuffixLenTrimmed && 180 return hostname.size() > kSuffixLenTrimmed &&
181 !hostname.compare(hostname.size() - kSuffixLenTrimmed, kSuffixLenTrimmed, 181 !hostname.compare(hostname.size() - kSuffixLenTrimmed, kSuffixLenTrimmed,
182 kSuffix, kSuffixLenTrimmed); 182 kSuffix, kSuffixLenTrimmed);
183 } 183 }
184 184
185 // Attempts to connect a UDP socket to |dest|:53. 185 // Attempts to connect a UDP socket to |dest|:53.
186 bool IsGloballyReachable(const IPAddressNumber& dest, 186 bool IsGloballyReachable(const IPAddressNumber& dest,
187 const BoundNetLog& net_log) { 187 const BoundNetLog& net_log) {
188 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed. 188 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
189 tracked_objects::ScopedTracker tracking_profile_1( 189 tracked_objects::ScopedTracker tracking_profile_1(
190 FROM_HERE_WITH_EXPLICIT_FUNCTION( 190 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 IsGloballyReachable"));
191 "455942 IsGloballyReachable (create udp socket)"));
192 191
193 scoped_ptr<DatagramClientSocket> socket( 192 scoped_ptr<DatagramClientSocket> socket(
194 ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket( 193 ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket(
195 DatagramSocket::DEFAULT_BIND, 194 DatagramSocket::DEFAULT_BIND,
196 RandIntCallback(), 195 RandIntCallback(),
197 net_log.net_log(), 196 net_log.net_log(),
198 net_log.source())); 197 net_log.source()));
199 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
200 tracked_objects::ScopedTracker tracking_profile_2(
201 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 IsGloballyReachable (connect)"));
202 int rv = socket->Connect(IPEndPoint(dest, 53)); 198 int rv = socket->Connect(IPEndPoint(dest, 53));
203 if (rv != OK) 199 if (rv != OK)
204 return false; 200 return false;
205 tracked_objects::ScopedTracker tracking_profile_3(
206 FROM_HERE_WITH_EXPLICIT_FUNCTION(
207 "455942 IsGloballyReachable (get local addr)"));
208 IPEndPoint endpoint; 201 IPEndPoint endpoint;
209 rv = socket->GetLocalAddress(&endpoint); 202 rv = socket->GetLocalAddress(&endpoint);
210 if (rv != OK) 203 if (rv != OK)
211 return false; 204 return false;
212 tracked_objects::ScopedTracker tracking_profile_4(
213 FROM_HERE_WITH_EXPLICIT_FUNCTION(
214 "455942 IsGloballyReachable (remainder)"));
215 DCHECK_EQ(ADDRESS_FAMILY_IPV6, endpoint.GetFamily()); 205 DCHECK_EQ(ADDRESS_FAMILY_IPV6, endpoint.GetFamily());
216 const IPAddressNumber& address = endpoint.address(); 206 const IPAddressNumber& address = endpoint.address();
217 bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80); 207 bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80);
218 if (is_link_local) 208 if (is_link_local)
219 return false; 209 return false;
220 const uint8 kTeredoPrefix[] = { 0x20, 0x01, 0, 0 }; 210 const uint8 kTeredoPrefix[] = { 0x20, 0x01, 0, 0 };
221 bool is_teredo = std::equal(kTeredoPrefix, 211 bool is_teredo = std::equal(kTeredoPrefix,
222 kTeredoPrefix + arraysize(kTeredoPrefix), 212 kTeredoPrefix + arraysize(kTeredoPrefix),
223 address.begin()); 213 address.begin());
224 if (is_teredo) 214 if (is_teredo)
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 DCHECK_GT(value, 0u); 1869 DCHECK_GT(value, 0u);
1880 max_queued_jobs_ = value; 1870 max_queued_jobs_ = value;
1881 } 1871 }
1882 1872
1883 int HostResolverImpl::Resolve(const RequestInfo& info, 1873 int HostResolverImpl::Resolve(const RequestInfo& info,
1884 RequestPriority priority, 1874 RequestPriority priority,
1885 AddressList* addresses, 1875 AddressList* addresses,
1886 const CompletionCallback& callback, 1876 const CompletionCallback& callback,
1887 RequestHandle* out_req, 1877 RequestHandle* out_req,
1888 const BoundNetLog& source_net_log) { 1878 const BoundNetLog& source_net_log) {
1889 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
1890 tracked_objects::ScopedTracker tracking_profile_1(
1891 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 HostResolverImpl::Resolve 1"));
1892
1893 DCHECK(addresses); 1879 DCHECK(addresses);
1894 DCHECK(CalledOnValidThread()); 1880 DCHECK(CalledOnValidThread());
1895 DCHECK_EQ(false, callback.is_null()); 1881 DCHECK_EQ(false, callback.is_null());
1896 1882
1897 // Check that the caller supplied a valid hostname to resolve. 1883 // Check that the caller supplied a valid hostname to resolve.
1898 std::string labeled_hostname; 1884 std::string labeled_hostname;
1899 if (!DNSDomainFromDot(info.hostname(), &labeled_hostname)) 1885 if (!DNSDomainFromDot(info.hostname(), &labeled_hostname))
1900 return ERR_NAME_NOT_RESOLVED; 1886 return ERR_NAME_NOT_RESOLVED;
1901 1887
1902 LogStartRequest(source_net_log, info); 1888 LogStartRequest(source_net_log, info);
1903 1889
1904 tracked_objects::ScopedTracker tracking_profile_1a(
1905 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 HostResolverImpl::Resolve 1a"));
1906
1907 IPAddressNumber ip_number; 1890 IPAddressNumber ip_number;
1908 IPAddressNumber* ip_number_ptr = nullptr; 1891 IPAddressNumber* ip_number_ptr = nullptr;
1909 if (ParseIPLiteralToNumber(info.hostname(), &ip_number)) 1892 if (ParseIPLiteralToNumber(info.hostname(), &ip_number))
1910 ip_number_ptr = &ip_number; 1893 ip_number_ptr = &ip_number;
1911 1894
1912 tracked_objects::ScopedTracker tracking_profile_1b(
1913 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 HostResolverImpl::Resolve 1b"));
1914
1915 // Build a key that identifies the request in the cache and in the 1895 // Build a key that identifies the request in the cache and in the
1916 // outstanding jobs map. 1896 // outstanding jobs map.
1917 Key key = GetEffectiveKeyForRequest(info, ip_number_ptr, source_net_log); 1897 Key key = GetEffectiveKeyForRequest(info, ip_number_ptr, source_net_log);
1918 1898
1919 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
1920 tracked_objects::ScopedTracker tracking_profile_2(
1921 FROM_HERE_WITH_EXPLICIT_FUNCTION("455942 HostResolverImpl::Resolve 2"));
1922
1923 int rv = ResolveHelper(key, info, ip_number_ptr, addresses, source_net_log); 1899 int rv = ResolveHelper(key, info, ip_number_ptr, addresses, source_net_log);
1924 if (rv != ERR_DNS_CACHE_MISS) { 1900 if (rv != ERR_DNS_CACHE_MISS) {
1925 LogFinishRequest(source_net_log, info, rv); 1901 LogFinishRequest(source_net_log, info, rv);
1926 RecordTotalTime(HaveDnsConfig(), info.is_speculative(), base::TimeDelta()); 1902 RecordTotalTime(HaveDnsConfig(), info.is_speculative(), base::TimeDelta());
1927 return rv; 1903 return rv;
1928 } 1904 }
1929 1905
1930 // Next we need to attach our request to a "job". This job is responsible for 1906 // Next we need to attach our request to a "job". This job is responsible for
1931 // calling "getaddrinfo(hostname)" on a worker thread. 1907 // calling "getaddrinfo(hostname)" on a worker thread.
1932 1908
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 dns_client_->SetConfig(dns_config); 2392 dns_client_->SetConfig(dns_config);
2417 num_dns_failures_ = 0; 2393 num_dns_failures_ = 0;
2418 if (dns_client_->GetConfig()) 2394 if (dns_client_->GetConfig())
2419 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); 2395 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
2420 } 2396 }
2421 2397
2422 AbortDnsTasks(); 2398 AbortDnsTasks();
2423 } 2399 }
2424 2400
2425 } // namespace net 2401 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698