diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 01:58:27 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 01:58:27 +0000 |
commit | 3ee39623d21e7241af1359f7d8b7ef199e206db0 (patch) | |
tree | 6aa291097c52f2e3d84cacf882c7ad6da3e4245a /net/proxy | |
parent | 16b07a08ccc4ed7933548e43ae85f6fb941764b9 (diff) | |
download | chromium_src-3ee39623d21e7241af1359f7d8b7ef199e206db0.zip chromium_src-3ee39623d21e7241af1359f7d8b7ef199e206db0.tar.gz chromium_src-3ee39623d21e7241af1359f7d8b7ef199e206db0.tar.bz2 |
Fix memory leak introduced by unit test, unflake timing-dependent test.
Remove exclusions for TSAN and Dr. Memory.
BUG=87616,86756
TEST=net_unittests
Review URL: http://codereview.chromium.org/7277011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r-- | net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc index 09ffb66..baa3f26 100644 --- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc +++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc @@ -58,7 +58,9 @@ class RealFetchTester { } void RunTest() { - fetcher_->Fetch(&pac_text_, &completion_callback_); + int result = fetcher_->Fetch(&pac_text_, &completion_callback_); + if (result != ERR_IO_PENDING) + finished_ = true; } void RunTestWithCancel() { @@ -67,9 +69,12 @@ class RealFetchTester { } void RunTestWithDeferredCancel() { - RunTest(); - cancel_timer_.Start(base::TimeDelta::FromMilliseconds(1), + // Put the cancellation into the queue before even running the + // test to avoid the chance of one of the adapter fetcher worker + // threads completing before cancellation. See http://crbug.com/86756. + cancel_timer_.Start(base::TimeDelta::FromMilliseconds(0), this, &RealFetchTester::OnCancelTimer); + RunTest(); } void OnCompletion(int result) { @@ -297,6 +302,17 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { ResetTestState(); } + virtual ~MockDhcpProxyScriptFetcherWin() { + // Delete any adapter fetcher objects we didn't hand out. + std::vector<DhcpProxyScriptAdapterFetcher*>::const_iterator it + = adapter_fetchers_.begin(); + for (; it != adapter_fetchers_.end(); ++it) { + if (num_fetchers_created_-- <= 0) { + delete (*it); + } + } + } + // Adds a fetcher object to the queue of fetchers used by // |ImplCreateAdapterFetcher()|, and its name to the list of adapters // returned by ImplGetCandidateAdapterNames. @@ -347,8 +363,9 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { int next_adapter_fetcher_index_; - // Ownership is not here; it gets transferred to the implementation - // class via ImplCreateAdapterFetcher. + // Ownership gets transferred to the implementation class via + // ImplCreateAdapterFetcher, but any objects not handed out are + // deleted on destruction. std::vector<DhcpProxyScriptAdapterFetcher*> adapter_fetchers_; scoped_refptr<MockWorkerThread> worker_thread_; |