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

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

Issue 23181010: Fast-fail WPAD detection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove SetHostResolverForTesting Created 7 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
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/mock_host_resolver.h" 5 #include "net/dns/mock_host_resolver.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 int* os_error) { 344 int* os_error) {
345 RuleList::iterator r; 345 RuleList::iterator r;
346 for (r = rules_.begin(); r != rules_.end(); ++r) { 346 for (r = rules_.begin(); r != rules_.end(); ++r) {
347 bool matches_address_family = 347 bool matches_address_family =
348 r->address_family == ADDRESS_FAMILY_UNSPECIFIED || 348 r->address_family == ADDRESS_FAMILY_UNSPECIFIED ||
349 r->address_family == address_family; 349 r->address_family == address_family;
350 // Flags match if all of the bitflags in host_resolver_flags are enabled 350 // Flags match if all of the bitflags in host_resolver_flags are enabled
351 // in the rule's host_resolver_flags. However, the rule may have additional 351 // in the rule's host_resolver_flags. However, the rule may have additional
352 // flags specified, in which case the flags should still be considered a 352 // flags specified, in which case the flags should still be considered a
353 // match. 353 // match.
354 bool matches_flags = (r->host_resolver_flags & host_resolver_flags) == 354 HostResolverFlags flags = host_resolver_flags & ~HOST_RESOLVER_SYSTEM_ONLY;
355 host_resolver_flags; 355 bool matches_flags = (r->host_resolver_flags & flags) == flags;
356 if (matches_flags && matches_address_family && 356 if (matches_flags && matches_address_family &&
357 MatchPattern(host, r->host_pattern)) { 357 MatchPattern(host, r->host_pattern)) {
358 if (r->latency_ms != 0) { 358 if (r->latency_ms != 0) {
359 base::PlatformThread::Sleep( 359 base::PlatformThread::Sleep(
360 base::TimeDelta::FromMilliseconds(r->latency_ms)); 360 base::TimeDelta::FromMilliseconds(r->latency_ms));
361 } 361 }
362 362
363 // Remap to a new host. 363 // Remap to a new host.
364 const std::string& effective_host = 364 const std::string& effective_host =
365 r->replacement.empty() ? host : r->replacement; 365 r->replacement.empty() ? host : r->replacement;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 CHECK_EQ(old_proc, current_proc_); 434 CHECK_EQ(old_proc, current_proc_);
435 } 435 }
436 436
437 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 437 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
438 current_proc_ = proc; 438 current_proc_ = proc;
439 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); 439 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get());
440 current_proc_->SetLastProc(previous_proc_.get()); 440 current_proc_->SetLastProc(previous_proc_.get());
441 } 441 }
442 442
443 } // namespace net 443 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698