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

Unified Diff: net/proxy/proxy_resolver_v8_tracing_unittest.cc

Issue 1439053002: Change ProxyResolver::GetProxyForURL() to take a scoped_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 4 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
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 888dd18af57d30ddf26219bf0aa4b8166c4a607e..863e7ab0e257c0310d8388dbb30dd7630a31e84f 100644
--- a/net/proxy/proxy_resolver_v8_tracing_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_tracing_unittest.cc
@@ -587,7 +587,7 @@ TEST_F(ProxyResolverV8TracingTest, 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) {
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i],
@@ -596,7 +596,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelAll) {
}
for (size_t i = 0; i < kNumRequests; ++i) {
- resolver->CancelRequest(request[i]);
+ request[i].reset();
}
}
@@ -614,8 +614,8 @@ TEST_F(ProxyResolverV8TracingTest, 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;
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1,
@@ -625,7 +625,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelSome) {
callback.callback(), &request2,
mock_bindings.CreateBindings());
- resolver->CancelRequest(request1);
+ request1.reset();
EXPECT_EQ(OK, callback.WaitForResult());
}
@@ -643,8 +643,8 @@ TEST_F(ProxyResolverV8TracingTest, 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;
resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info1,
@@ -653,10 +653,10 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) {
// Wait until the first request has finished running on the worker thread.
// Cancel the first request, while it is running its completion task on
- // the origin thread.
- mock_bindings.RunOnError(base::Bind(&ProxyResolverV8Tracing::CancelRequest,
- base::Unretained(resolver.get()),
- request1));
+ // the origin thread. Reset deletes Request opject which cancels the request.
+ mock_bindings.RunOnError(
+ base::Bind(&scoped_ptr<ProxyResolver::Request>::reset,
+ base::Unretained(&request1), nullptr));
// Start another request, to make sure it is able to complete.
resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"),
@@ -746,8 +746,8 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
ProxyInfo proxy_info1;
ProxyInfo proxy_info2;
- ProxyResolver::RequestHandle request1;
- ProxyResolver::RequestHandle request2;
+ scoped_ptr<ProxyResolver::Request> request1;
+ scoped_ptr<ProxyResolver::Request> request2;
resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1,
base::Bind(&CrashCallback), &request1,
@@ -761,8 +761,8 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
host_resolver.WaitUntilRequestIsReceived();
- resolver->CancelRequest(request1);
- resolver->CancelRequest(request2);
+ request1.reset();
+ request2.reset();
EXPECT_EQ(2, host_resolver.num_cancelled_requests());
@@ -771,9 +771,8 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
// should have been cancelled.
}
-void CancelRequestAndPause(ProxyResolverV8Tracing* 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
@@ -792,14 +791,13 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) {
CreateResolver(mock_bindings.CreateBindings(), "dns.js");
ProxyInfo proxy_info;
- ProxyResolver::RequestHandle request;
+ scoped_ptr<ProxyResolver::Request> request;
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
base::Bind(&CrashCallback), &request,
mock_bindings.CreateBindings());
- host_resolver.SetAction(
- base::Bind(CancelRequestAndPause, resolver.get(), request));
+ host_resolver.SetAction(base::Bind(CancelRequestAndPause, &request));
host_resolver.WaitUntilRequestIsReceived();
}
@@ -814,7 +812,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns2) {
CreateResolver(mock_bindings.CreateBindings(), "dns.js");
ProxyInfo proxy_info;
- ProxyResolver::RequestHandle request;
+ scoped_ptr<ProxyResolver::Request> request;
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
base::Bind(&CrashCallback), &request,
@@ -824,7 +822,7 @@ TEST_F(ProxyResolverV8TracingTest, 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());
}

Powered by Google App Engine
This is Rietveld 408576698