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

Unified Diff: net/proxy/proxy_resolver_v8_tracing_unittest.cc

Issue 12088090: Fix a memory error in ProxyResolverV8Tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a bad DCHECK Created 7 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/proxy/proxy_resolver_v8_tracing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8_tracing_unittest.cc
diff --git a/net/proxy/proxy_resolver_v8_tracing_unittest.cc b/net/proxy/proxy_resolver_v8_tracing_unittest.cc
index 36e6087f6f541df1cc4c27e594048b947276e2d2..1d823cd69e7d049bd3eee7e0c09e4fe568a0e5e0 100644
--- a/net/proxy/proxy_resolver_v8_tracing_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_tracing_unittest.cc
@@ -761,7 +761,6 @@ class BlockableHostResolver : public HostResolver {
const BoundNetLog& net_log) OVERRIDE {
EXPECT_FALSE(callback.is_null());
EXPECT_TRUE(out_req);
- *out_req = reinterpret_cast<RequestHandle*>(1); // Magic value.
if (!action_.is_null())
action_.Run();
@@ -770,6 +769,11 @@ class BlockableHostResolver : public HostResolver {
EXPECT_TRUE(waiting_for_resolve_);
MessageLoop::current()->Quit();
+ // This line is intentionally after action_.Run(), since one of the
+ // tests does a cancellation inside of Resolve(), and it is more
+ // interesting if *out_req hasn't been written yet at that point.
+ *out_req = reinterpret_cast<RequestHandle*>(1); // Magic value.
+
// Return ERR_IO_PENDING as this request will NEVER be completed.
// Expectation is for the caller to later cancel the request.
return ERR_IO_PENDING;
@@ -849,6 +853,16 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
// should have been cancelled.
}
+void CancelRequestAndPause(ProxyResolverV8Tracing* resolver,
+ ProxyResolver::RequestHandle request) {
+ resolver->CancelRequest(request);
+
+ // Sleep for a little bit. This makes it more likely for the worker
+ // thread to have returned from its call, and serves as a regression
+ // test for http://crbug.com/173373.
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30));
+}
+
// In non-blocking mode, the worker thread actually does block for
// a short time to see if the result is in the DNS cache. Test
// cancellation while the worker thread is waiting on this event.
@@ -868,8 +882,8 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) {
EXPECT_EQ(ERR_IO_PENDING, rv);
- host_resolver.SetAction(base::Bind(&ProxyResolverV8Tracing::CancelRequest,
- base::Unretained(&resolver), request));
+ host_resolver.SetAction(
+ base::Bind(CancelRequestAndPause, &resolver, request));
host_resolver.WaitUntilRequestIsReceived();
« no previous file with comments | « net/proxy/proxy_resolver_v8_tracing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698