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

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

Issue 10872104: Make sure MockHostResolverWorks regardless of whether winsock has already been initialized yet. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move to mockhostresolver Created 8 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
« 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/base/mock_host_resolver.h" 5 #include "net/base/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.h" 12 #include "base/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "net/base/host_cache.h" 17 #include "net/base/host_cache.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
20 #include "net/base/test_completion_callback.h" 20 #include "net/base/test_completion_callback.h"
21 #if defined(OS_WIN)
22 #include "net/base/winsock_init.h"
23 #endif
21 24
22 namespace net { 25 namespace net {
23 26
24 namespace { 27 namespace {
25 28
26 // Cache size for the MockCachingHostResolver. 29 // Cache size for the MockCachingHostResolver.
27 const unsigned kMaxCacheEntries = 100; 30 const unsigned kMaxCacheEntries = 100;
28 // TTL for the successful resolutions. Failures are not cached. 31 // TTL for the successful resolutions. Failures are not cached.
29 const unsigned kCacheEntryTTLSeconds = 60; 32 const unsigned kCacheEntryTTLSeconds = 60;
30 33
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 320
318 // Remap to a new host. 321 // Remap to a new host.
319 const std::string& effective_host = 322 const std::string& effective_host =
320 r->replacement.empty() ? host : r->replacement; 323 r->replacement.empty() ? host : r->replacement;
321 324
322 // Apply the resolving function to the remapped hostname. 325 // Apply the resolving function to the remapped hostname.
323 switch (r->resolver_type) { 326 switch (r->resolver_type) {
324 case Rule::kResolverTypeFail: 327 case Rule::kResolverTypeFail:
325 return ERR_NAME_NOT_RESOLVED; 328 return ERR_NAME_NOT_RESOLVED;
326 case Rule::kResolverTypeSystem: 329 case Rule::kResolverTypeSystem:
330 #if defined(OS_WIN)
331 net::EnsureWinsockInit();
332 #endif
327 return SystemHostResolverProc(effective_host, 333 return SystemHostResolverProc(effective_host,
328 address_family, 334 address_family,
329 host_resolver_flags, 335 host_resolver_flags,
330 addrlist, os_error); 336 addrlist, os_error);
331 case Rule::kResolverTypeIPLiteral: 337 case Rule::kResolverTypeIPLiteral:
332 return ParseAddressList(effective_host, 338 return ParseAddressList(effective_host,
333 r->canonical_name, 339 r->canonical_name,
334 addrlist); 340 addrlist);
335 default: 341 default:
336 NOTREACHED(); 342 NOTREACHED();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 CHECK_EQ(old_proc, current_proc_); 390 CHECK_EQ(old_proc, current_proc_);
385 } 391 }
386 392
387 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 393 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
388 current_proc_ = proc; 394 current_proc_ = proc;
389 previous_proc_ = HostResolverProc::SetDefault(current_proc_); 395 previous_proc_ = HostResolverProc::SetDefault(current_proc_);
390 current_proc_->SetLastProc(previous_proc_); 396 current_proc_->SetLastProc(previous_proc_);
391 } 397 }
392 398
393 } // namespace net 399 } // 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