| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |