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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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 | « net/dns/mdns_client_impl.cc ('k') | net/dns/serial_worker.h » ('j') | 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/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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/pattern.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
17 #include "net/base/ip_endpoint.h" 18 #include "net/base/ip_endpoint.h"
18 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
19 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
20 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
21 #include "net/dns/host_cache.h" 22 #include "net/dns/host_cache.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 r->address_family == address_family; 357 r->address_family == address_family;
357 // Ignore HOST_RESOLVER_SYSTEM_ONLY, since it should have no impact on 358 // Ignore HOST_RESOLVER_SYSTEM_ONLY, since it should have no impact on
358 // whether a rule matches. 359 // whether a rule matches.
359 HostResolverFlags flags = host_resolver_flags & ~HOST_RESOLVER_SYSTEM_ONLY; 360 HostResolverFlags flags = host_resolver_flags & ~HOST_RESOLVER_SYSTEM_ONLY;
360 // Flags match if all of the bitflags in host_resolver_flags are enabled 361 // Flags match if all of the bitflags in host_resolver_flags are enabled
361 // in the rule's host_resolver_flags. However, the rule may have additional 362 // in the rule's host_resolver_flags. However, the rule may have additional
362 // flags specified, in which case the flags should still be considered a 363 // flags specified, in which case the flags should still be considered a
363 // match. 364 // match.
364 bool matches_flags = (r->host_resolver_flags & flags) == flags; 365 bool matches_flags = (r->host_resolver_flags & flags) == flags;
365 if (matches_flags && matches_address_family && 366 if (matches_flags && matches_address_family &&
366 MatchPattern(host, r->host_pattern)) { 367 base::MatchPattern(host, r->host_pattern)) {
367 if (r->latency_ms != 0) { 368 if (r->latency_ms != 0) {
368 base::PlatformThread::Sleep( 369 base::PlatformThread::Sleep(
369 base::TimeDelta::FromMilliseconds(r->latency_ms)); 370 base::TimeDelta::FromMilliseconds(r->latency_ms));
370 } 371 }
371 372
372 // Remap to a new host. 373 // Remap to a new host.
373 const std::string& effective_host = 374 const std::string& effective_host =
374 r->replacement.empty() ? host : r->replacement; 375 r->replacement.empty() ? host : r->replacement;
375 376
376 // Apply the resolving function to the remapped hostname. 377 // Apply the resolving function to the remapped hostname.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 CHECK_EQ(old_proc, current_proc_.get()); 444 CHECK_EQ(old_proc, current_proc_.get());
444 } 445 }
445 446
446 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 447 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
447 current_proc_ = proc; 448 current_proc_ = proc;
448 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); 449 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get());
449 current_proc_->SetLastProc(previous_proc_.get()); 450 current_proc_->SetLastProc(previous_proc_.get());
450 } 451 }
451 452
452 } // namespace net 453 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/mdns_client_impl.cc ('k') | net/dns/serial_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698