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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/host_resolver_proc.h ('k') | net/base/mock_host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_proc.cc
===================================================================
--- net/base/host_resolver_proc.cc (revision 35740)
+++ net/base/host_resolver_proc.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -26,14 +26,36 @@
HostResolverProc* HostResolverProc::default_proc_ = NULL;
HostResolverProc::HostResolverProc(HostResolverProc* previous) {
- set_previous_proc(previous);
+ SetPreviousProc(previous);
// Implicitly fall-back to the global default procedure.
if (!previous)
- set_previous_proc(default_proc_);
+ SetPreviousProc(default_proc_);
}
+void HostResolverProc::SetPreviousProc(HostResolverProc* proc) {
+ HostResolverProc* current_previous = previous_proc_;
+ previous_proc_ = NULL;
+ // Now that we've guaranteed |this| is the last proc in a chain, we can
+ // detect potential cycles using GetLastProc().
+ previous_proc_ = (GetLastProc(proc) == this) ? current_previous : proc;
+}
+
+void HostResolverProc::SetLastProc(HostResolverProc* proc) {
+ GetLastProc(this)->SetPreviousProc(proc);
+}
+
// static
+HostResolverProc* HostResolverProc::GetLastProc(HostResolverProc* proc) {
+ if (proc == NULL)
+ return NULL;
+ HostResolverProc* last_proc = proc;
+ while (last_proc->previous_proc_ != NULL)
+ last_proc = last_proc->previous_proc_;
+ return last_proc;
+}
+
+// static
HostResolverProc* HostResolverProc::SetDefault(HostResolverProc* proc) {
HostResolverProc* old = default_proc_;
default_proc_ = proc;
« 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