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

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

Issue 525079: Add autodetection of "intranet" redirection, for ISPs etc. that send typos an... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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/mock_host_resolver.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "googleurl/src/url_canon_ip.h" 10 #include "googleurl/src/url_canon_ip.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 new RuleBasedHostResolverProc(NULL); 82 new RuleBasedHostResolverProc(NULL);
83 catchall->AddRule("*", "127.0.0.1"); 83 catchall->AddRule("*", "127.0.0.1");
84 84
85 // Next add a rules-based layer the use controls. 85 // Next add a rules-based layer the use controls.
86 rules_ = new RuleBasedHostResolverProc(catchall); 86 rules_ = new RuleBasedHostResolverProc(catchall);
87 87
88 HostResolverProc* proc = rules_; 88 HostResolverProc* proc = rules_;
89 89
90 // Lastly add the provided interceptor to the front of the chain. 90 // Lastly add the provided interceptor to the front of the chain.
91 if (interceptor) { 91 if (interceptor) {
92 interceptor->set_previous_proc(proc); 92 interceptor->SetPreviousProc(proc);
93 proc = interceptor; 93 proc = interceptor;
94 } 94 }
95 95
96 HostCache* cache = NULL; 96 HostCache* cache = NULL;
97 97
98 if (use_caching_) { 98 if (use_caching_) {
99 cache = new HostCache( 99 cache = new HostCache(
100 100, // max entries. 100 100, // max entries.
101 base::TimeDelta::FromMinutes(1), 101 base::TimeDelta::FromMinutes(1),
102 base::TimeDelta::FromSeconds(0)); 102 base::TimeDelta::FromSeconds(0));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return ERR_UNEXPECTED; 218 return ERR_UNEXPECTED;
219 } 219 }
220 } 220 }
221 } 221 }
222 return ResolveUsingPrevious(host, address_family, addrlist); 222 return ResolveUsingPrevious(host, address_family, addrlist);
223 } 223 }
224 224
225 //----------------------------------------------------------------------------- 225 //-----------------------------------------------------------------------------
226 226
227 ScopedDefaultHostResolverProc::ScopedDefaultHostResolverProc( 227 ScopedDefaultHostResolverProc::ScopedDefaultHostResolverProc(
228 HostResolverProc* proc) : current_proc_(proc) { 228 HostResolverProc* proc) {
229 previous_proc_ = HostResolverProc::SetDefault(current_proc_); 229 Init(proc);
230 current_proc_->set_previous_proc(previous_proc_);
231 } 230 }
232 231
233 ScopedDefaultHostResolverProc::~ScopedDefaultHostResolverProc() { 232 ScopedDefaultHostResolverProc::~ScopedDefaultHostResolverProc() {
234 HostResolverProc* old_proc = HostResolverProc::SetDefault(previous_proc_); 233 HostResolverProc* old_proc = HostResolverProc::SetDefault(previous_proc_);
235 // The lifetimes of multiple instances must be nested. 234 // The lifetimes of multiple instances must be nested.
236 CHECK(old_proc == current_proc_); 235 CHECK(old_proc == current_proc_);
237 } 236 }
238 237
239 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 238 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
240 current_proc_ = proc; 239 current_proc_ = proc;
241 previous_proc_ = HostResolverProc::SetDefault(current_proc_); 240 previous_proc_ = HostResolverProc::SetDefault(current_proc_);
242 current_proc_->set_previous_proc(previous_proc_); 241 current_proc_->SetLastProc(previous_proc_);
243 } 242 }
244 243
245 } // namespace net 244 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mock_host_resolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698