diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 23:00:19 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 23:00:19 +0000 |
commit | cd07257813fae874442864f65092ed882c37959c (patch) | |
tree | 10c85606fd7b274eb0121e7847b7460c8159c05e /net | |
parent | a4c488fc126b3c02ef8031dea6651d68d96a5e4b (diff) | |
download | chromium_src-cd07257813fae874442864f65092ed882c37959c.zip chromium_src-cd07257813fae874442864f65092ed882c37959c.tar.gz chromium_src-cd07257813fae874442864f65092ed882c37959c.tar.bz2 |
Work around a Purify bug by moving initialization from constructor to Inititialize().
BUG=7467
Review URL: http://codereview.chromium.org/24006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_resolver_unittest.h | 8 | ||||
-rw-r--r-- | net/base/run_all_unittests.cc | 16 |
2 files changed, 16 insertions, 8 deletions
diff --git a/net/base/host_resolver_unittest.h b/net/base/host_resolver_unittest.h index 5531bd0..e7a9c1a 100644 --- a/net/base/host_resolver_unittest.h +++ b/net/base/host_resolver_unittest.h @@ -125,12 +125,20 @@ class ScopedHostMapper { current_host_mapper_->set_previous_mapper(previous_host_mapper_.get()); } + ScopedHostMapper() {} + ~ScopedHostMapper() { HostMapper* old_mapper = SetHostMapper(previous_host_mapper_.get()); // The lifetimes of multiple instances must be nested. CHECK(old_mapper == current_host_mapper_.get()); } + void Init(HostMapper* mapper) { + current_host_mapper_ = mapper; + previous_host_mapper_ = SetHostMapper(current_host_mapper_.get()); + current_host_mapper_->set_previous_mapper(previous_host_mapper_.get()); + } + private: scoped_refptr<HostMapper> current_host_mapper_; scoped_refptr<HostMapper> previous_host_mapper_; diff --git a/net/base/run_all_unittests.cc b/net/base/run_all_unittests.cc index 15741e4..6c60e2d 100644 --- a/net/base/run_all_unittests.cc +++ b/net/base/run_all_unittests.cc @@ -34,19 +34,19 @@ class NetTestSuite : public TestSuite { public: - NetTestSuite(int argc, char** argv) - : TestSuite(argc, argv), - host_mapper_(new net::RuleBasedHostMapper()), - scoped_host_mapper_(host_mapper_.get()) { - // In case any attempts are made to resolve host names, force them all to - // be mapped to localhost. This prevents DNS queries from being sent in - // the process of running these unit tests. - host_mapper_->AddRule("*", "127.0.0.1"); + NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) { } virtual void Initialize() { TestSuite::Initialize(); + host_mapper_ = new net::RuleBasedHostMapper(); + scoped_host_mapper_.Init(host_mapper_.get()); + // In case any attempts are made to resolve host names, force them all to + // be mapped to localhost. This prevents DNS queries from being sent in + // the process of running these unit tests. + host_mapper_->AddRule("*", "127.0.0.1"); + message_loop_.reset(new MessageLoopForIO()); } |