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

Side by Side Diff: net/base/host_resolver_proc.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/host_resolver_proc.h ('k') | net/base/mock_host_resolver.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) 2006-2008 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/host_resolver_proc.h" 5 #include "net/base/host_resolver_proc.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_LINUX) 9 #if defined(OS_LINUX)
10 #include <resolv.h> 10 #include <resolv.h>
11 #endif 11 #endif
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "net/base/address_list.h" 15 #include "net/base/address_list.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/sys_addrinfo.h" 17 #include "net/base/sys_addrinfo.h"
18 18
19 #if defined(OS_LINUX) 19 #if defined(OS_LINUX)
20 #include "base/singleton.h" 20 #include "base/singleton.h"
21 #include "base/thread_local_storage.h" 21 #include "base/thread_local_storage.h"
22 #endif 22 #endif
23 23
24 namespace net { 24 namespace net {
25 25
26 HostResolverProc* HostResolverProc::default_proc_ = NULL; 26 HostResolverProc* HostResolverProc::default_proc_ = NULL;
27 27
28 HostResolverProc::HostResolverProc(HostResolverProc* previous) { 28 HostResolverProc::HostResolverProc(HostResolverProc* previous) {
29 set_previous_proc(previous); 29 SetPreviousProc(previous);
30 30
31 // Implicitly fall-back to the global default procedure. 31 // Implicitly fall-back to the global default procedure.
32 if (!previous) 32 if (!previous)
33 set_previous_proc(default_proc_); 33 SetPreviousProc(default_proc_);
34 }
35
36 void HostResolverProc::SetPreviousProc(HostResolverProc* proc) {
37 HostResolverProc* current_previous = previous_proc_;
38 previous_proc_ = NULL;
39 // Now that we've guaranteed |this| is the last proc in a chain, we can
40 // detect potential cycles using GetLastProc().
41 previous_proc_ = (GetLastProc(proc) == this) ? current_previous : proc;
42 }
43
44 void HostResolverProc::SetLastProc(HostResolverProc* proc) {
45 GetLastProc(this)->SetPreviousProc(proc);
46 }
47
48 // static
49 HostResolverProc* HostResolverProc::GetLastProc(HostResolverProc* proc) {
50 if (proc == NULL)
51 return NULL;
52 HostResolverProc* last_proc = proc;
53 while (last_proc->previous_proc_ != NULL)
54 last_proc = last_proc->previous_proc_;
55 return last_proc;
34 } 56 }
35 57
36 // static 58 // static
37 HostResolverProc* HostResolverProc::SetDefault(HostResolverProc* proc) { 59 HostResolverProc* HostResolverProc::SetDefault(HostResolverProc* proc) {
38 HostResolverProc* old = default_proc_; 60 HostResolverProc* old = default_proc_;
39 default_proc_ = proc; 61 default_proc_ = proc;
40 return old; 62 return old;
41 } 63 }
42 64
43 // static 65 // static
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 #endif 216 #endif
195 217
196 if (err) 218 if (err)
197 return ERR_NAME_NOT_RESOLVED; 219 return ERR_NAME_NOT_RESOLVED;
198 220
199 addrlist->Adopt(ai); 221 addrlist->Adopt(ai);
200 return OK; 222 return OK;
201 } 223 }
202 224
203 } // namespace net 225 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_proc.h ('k') | net/base/mock_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698