Index: net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc |
diff --git a/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc |
index 946d4bf47a317013314e68fcbec4391fa25aa1cf..e3f23121798610f90ee7f394b58b7d6905c7dcff 100644 |
--- a/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc |
+++ b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc |
@@ -667,7 +667,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelAll) { |
const size_t kNumRequests = 5; |
ProxyInfo proxy_info[kNumRequests]; |
- ProxyResolver::RequestHandle request[kNumRequests]; |
+ scoped_ptr<ProxyResolver::Request> request[kNumRequests]; |
for (size_t i = 0; i < kNumRequests; ++i) { |
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i], |
@@ -677,7 +677,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelAll) { |
} |
for (size_t i = 0; i < kNumRequests; ++i) { |
- resolver->CancelRequest(request[i]); |
+ request[i].reset(); |
} |
} |
@@ -695,8 +695,8 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelSome) { |
ProxyInfo proxy_info1; |
ProxyInfo proxy_info2; |
- ProxyResolver::RequestHandle request1; |
- ProxyResolver::RequestHandle request2; |
+ scoped_ptr<ProxyResolver::Request> request1; |
+ scoped_ptr<ProxyResolver::Request> request2; |
TestCompletionCallback callback; |
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1, |
@@ -708,7 +708,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelSome) { |
callback.callback(), &request2, BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- resolver->CancelRequest(request1); |
+ request1.reset(); |
EXPECT_EQ(OK, callback.WaitForResult()); |
} |
@@ -726,8 +726,8 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhilePendingCompletionTask) { |
ProxyInfo proxy_info1; |
ProxyInfo proxy_info2; |
- ProxyResolver::RequestHandle request1; |
- ProxyResolver::RequestHandle request2; |
+ scoped_ptr<ProxyResolver::Request> request1; |
+ scoped_ptr<ProxyResolver::Request> request2; |
TestCompletionCallback callback; |
int rv = resolver->GetProxyForURL(GURL("http://throw-an-error/"), |
@@ -737,10 +737,10 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhilePendingCompletionTask) { |
// Wait until the first request has finished running on the worker thread. |
// Cancel the first request, while it has a pending completion task on |
- // the origin thread. |
- error_observer->RunOnError(base::Bind(&ProxyResolver::CancelRequest, |
- base::Unretained(resolver.get()), |
- request1)); |
+ // the origin thread. Reset deletes Request object which cancels the request. |
+ error_observer->RunOnError( |
+ base::Bind(&scoped_ptr<ProxyResolver::Request>::reset, |
+ base::Unretained(&request1), nullptr)); |
// Start another request, to make sure it is able to complete. |
rv = resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"), |
@@ -828,8 +828,8 @@ TEST_F(ProxyResolverV8TracingWrapperTest, |
ProxyInfo proxy_info1; |
ProxyInfo proxy_info2; |
- ProxyResolver::RequestHandle request1; |
- ProxyResolver::RequestHandle request2; |
+ scoped_ptr<ProxyResolver::Request> request1; |
+ scoped_ptr<ProxyResolver::Request> request2; |
int rv = resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1, |
base::Bind(&CrashCallback), &request1, |
@@ -847,8 +847,8 @@ TEST_F(ProxyResolverV8TracingWrapperTest, |
host_resolver.WaitUntilRequestIsReceived(); |
- resolver->CancelRequest(request1); |
- resolver->CancelRequest(request2); |
+ request1.reset(); |
+ request2.reset(); |
EXPECT_EQ(2, host_resolver.num_cancelled_requests()); |
@@ -857,9 +857,8 @@ TEST_F(ProxyResolverV8TracingWrapperTest, |
// should have been cancelled. |
} |
-void CancelRequestAndPause(ProxyResolver* resolver, |
- ProxyResolver::RequestHandle request) { |
- resolver->CancelRequest(request); |
+void CancelRequestAndPause(scoped_ptr<ProxyResolver::Request>* request) { |
+ request->reset(); |
// 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 |
@@ -878,7 +877,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns) { |
nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js"); |
ProxyInfo proxy_info; |
- ProxyResolver::RequestHandle request; |
+ scoped_ptr<ProxyResolver::Request> request; |
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
base::Bind(&CrashCallback), &request, |
@@ -886,8 +885,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- host_resolver.SetAction( |
- base::Bind(CancelRequestAndPause, resolver.get(), request)); |
+ host_resolver.SetAction(base::Bind(CancelRequestAndPause, &request)); |
host_resolver.WaitUntilRequestIsReceived(); |
} |
@@ -902,7 +900,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns2) { |
nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js"); |
ProxyInfo proxy_info; |
- ProxyResolver::RequestHandle request; |
+ scoped_ptr<ProxyResolver::Request> request; |
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
base::Bind(&CrashCallback), &request, |
@@ -914,7 +912,7 @@ TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns2) { |
// work whatever the delay is here, but it is most useful if the delay |
// is large enough to allow a task to be posted back. |
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
- resolver->CancelRequest(request); |
+ request.reset(); |
EXPECT_EQ(0u, host_resolver.num_resolve()); |
} |