| OLD | NEW |
| 1 // Copyright (c) 2010 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 "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 void MockHostResolverBase::RemoveObserver(Observer* observer) { | 75 void MockHostResolverBase::RemoveObserver(Observer* observer) { |
| 76 impl_->RemoveObserver(observer); | 76 impl_->RemoveObserver(observer); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MockHostResolverBase::Reset(HostResolverProc* interceptor) { | 79 void MockHostResolverBase::Reset(HostResolverProc* interceptor) { |
| 80 synchronous_mode_ = false; | 80 synchronous_mode_ = false; |
| 81 | 81 |
| 82 // At the root of the chain, map everything to localhost. | 82 // At the root of the chain, map everything to localhost. |
| 83 scoped_refptr<RuleBasedHostResolverProc> catchall = | 83 scoped_refptr<RuleBasedHostResolverProc> catchall( |
| 84 new RuleBasedHostResolverProc(NULL); | 84 new RuleBasedHostResolverProc(NULL)); |
| 85 catchall->AddRule("*", "127.0.0.1"); | 85 catchall->AddRule("*", "127.0.0.1"); |
| 86 | 86 |
| 87 // Next add a rules-based layer the use controls. | 87 // Next add a rules-based layer the use controls. |
| 88 rules_ = new RuleBasedHostResolverProc(catchall); | 88 rules_ = new RuleBasedHostResolverProc(catchall); |
| 89 | 89 |
| 90 HostResolverProc* proc = rules_; | 90 HostResolverProc* proc = rules_; |
| 91 | 91 |
| 92 // Lastly add the provided interceptor to the front of the chain. | 92 // Lastly add the provided interceptor to the front of the chain. |
| 93 if (interceptor) { | 93 if (interceptor) { |
| 94 interceptor->SetPreviousProc(proc); | 94 interceptor->SetPreviousProc(proc); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 CHECK_EQ(old_proc, current_proc_); | 294 CHECK_EQ(old_proc, current_proc_); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { | 297 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { |
| 298 current_proc_ = proc; | 298 current_proc_ = proc; |
| 299 previous_proc_ = HostResolverProc::SetDefault(current_proc_); | 299 previous_proc_ = HostResolverProc::SetDefault(current_proc_); |
| 300 current_proc_->SetLastProc(previous_proc_); | 300 current_proc_->SetLastProc(previous_proc_); |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace net | 303 } // namespace net |
| OLD | NEW |