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

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

Issue 303026: Refactor: Change the interface HostResolver::DisableIPv6() to HostResolver::SetDefaultA... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add another comment by the switch Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/base/host_resolver_impl.h ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ws2tcpip.h> 8 #include <ws2tcpip.h>
9 #include <wspiapi.h> // Needed for Win2k compat. 9 #include <wspiapi.h> // Needed for Win2k compat.
10 #elif defined(OS_POSIX) 10 #elif defined(OS_POSIX)
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 }; 286 };
287 287
288 //----------------------------------------------------------------------------- 288 //-----------------------------------------------------------------------------
289 289
290 HostResolverImpl::HostResolverImpl(HostResolverProc* resolver_proc, 290 HostResolverImpl::HostResolverImpl(HostResolverProc* resolver_proc,
291 int max_cache_entries, 291 int max_cache_entries,
292 int cache_duration_ms) 292 int cache_duration_ms)
293 : cache_(max_cache_entries, cache_duration_ms), 293 : cache_(max_cache_entries, cache_duration_ms),
294 next_request_id_(0), 294 next_request_id_(0),
295 resolver_proc_(resolver_proc), 295 resolver_proc_(resolver_proc),
296 disable_ipv6_(false), 296 default_address_family_(ADDRESS_FAMILY_UNSPECIFIED),
297 shutdown_(false) { 297 shutdown_(false) {
298 #if defined(OS_WIN) 298 #if defined(OS_WIN)
299 EnsureWinsockInit(); 299 EnsureWinsockInit();
300 #endif 300 #endif
301 } 301 }
302 302
303 HostResolverImpl::~HostResolverImpl() { 303 HostResolverImpl::~HostResolverImpl() {
304 // Cancel the outstanding jobs. Those jobs may contain several attached 304 // Cancel the outstanding jobs. Those jobs may contain several attached
305 // requests, which will also be cancelled. 305 // requests, which will also be cancelled.
306 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it) 306 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
(...skipping 16 matching lines...) Expand all
323 323
324 // Choose a unique ID number for observers to see. 324 // Choose a unique ID number for observers to see.
325 int request_id = next_request_id_++; 325 int request_id = next_request_id_++;
326 326
327 // Update the load log and notify registered observers. 327 // Update the load log and notify registered observers.
328 OnStartRequest(load_log, request_id, info); 328 OnStartRequest(load_log, request_id, info);
329 329
330 // Build a key that identifies the request in the cache and in the 330 // Build a key that identifies the request in the cache and in the
331 // outstanding jobs map. 331 // outstanding jobs map.
332 Key key(info.hostname(), info.address_family()); 332 Key key(info.hostname(), info.address_family());
333 if (disable_ipv6_) 333 if (key.address_family == ADDRESS_FAMILY_UNSPECIFIED)
334 key.address_family = ADDRESS_FAMILY_IPV4; 334 key.address_family = default_address_family_;
335 335
336 // If we have an unexpired cache entry, use it. 336 // If we have an unexpired cache entry, use it.
337 if (info.allow_cached_response()) { 337 if (info.allow_cached_response()) {
338 const HostCache::Entry* cache_entry = cache_.Lookup( 338 const HostCache::Entry* cache_entry = cache_.Lookup(
339 key, base::TimeTicks::Now()); 339 key, base::TimeTicks::Now());
340 if (cache_entry) { 340 if (cache_entry) {
341 addresses->SetFrom(cache_entry->addrlist, info.port()); 341 addresses->SetFrom(cache_entry->addrlist, info.port());
342 int error = cache_entry->error; 342 int error = cache_entry->error;
343 343
344 // Update the load log and notify registered observers. 344 // Update the load log and notify registered observers.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 557 }
558 558
559 LoadLog::EndEvent( 559 LoadLog::EndEvent(
560 load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL); 560 load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
561 } 561 }
562 562
563 LoadLog::EndEvent(load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL); 563 LoadLog::EndEvent(load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL);
564 } 564 }
565 565
566 } // namespace net 566 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698