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

Unified Diff: net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc

Issue 1745133002: Revert of 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: Created 4 years, 10 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_wrapper.cc ('k') | net/proxy/proxy_resolver_winhttp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 66fdc9e57647b988bb8d714b08931c5bb882a254..946d4bf47a317013314e68fcbec4391fa25aa1cf 100644
--- a/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
@@ -128,10 +128,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -160,10 +159,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult());
@@ -210,10 +208,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -259,10 +256,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -317,10 +313,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -383,10 +378,9 @@
TestCompletionCallback callback2;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info,
- callback1.callback(), &req, request_log.bound());
+ callback1.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback1.WaitForResult());
@@ -397,10 +391,9 @@
// The first request took 2 restarts, hence on g_iteration=3.
EXPECT_EQ("166.155.144.11:3", proxy_info.proxy_server().ToURI());
- scoped_ptr<ProxyResolver::Request> req2;
- rv = resolver->GetProxyForURL(GURL("http://foopy/req2"), &proxy_info,
- callback2.callback(), &req2,
- request_log.bound());
+ rv =
+ resolver->GetProxyForURL(GURL("http://foopy/req2"), &proxy_info,
+ callback2.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback2.WaitForResult());
@@ -437,10 +430,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -492,10 +484,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -531,10 +522,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -577,10 +567,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -622,10 +611,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -679,7 +667,7 @@
const size_t kNumRequests = 5;
ProxyInfo proxy_info[kNumRequests];
- scoped_ptr<ProxyResolver::Request> request[kNumRequests];
+ ProxyResolver::RequestHandle request[kNumRequests];
for (size_t i = 0; i < kNumRequests; ++i) {
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i],
@@ -689,7 +677,7 @@
}
for (size_t i = 0; i < kNumRequests; ++i) {
- request[i].reset();
+ resolver->CancelRequest(request[i]);
}
}
@@ -707,8 +695,8 @@
ProxyInfo proxy_info1;
ProxyInfo proxy_info2;
- scoped_ptr<ProxyResolver::Request> request1;
- scoped_ptr<ProxyResolver::Request> request2;
+ ProxyResolver::RequestHandle request1;
+ ProxyResolver::RequestHandle request2;
TestCompletionCallback callback;
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1,
@@ -720,7 +708,7 @@
callback.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- request1.reset();
+ resolver->CancelRequest(request1);
EXPECT_EQ(OK, callback.WaitForResult());
}
@@ -738,8 +726,8 @@
ProxyInfo proxy_info1;
ProxyInfo proxy_info2;
- scoped_ptr<ProxyResolver::Request> request1;
- scoped_ptr<ProxyResolver::Request> request2;
+ ProxyResolver::RequestHandle request1;
+ ProxyResolver::RequestHandle request2;
TestCompletionCallback callback;
int rv = resolver->GetProxyForURL(GURL("http://throw-an-error/"),
@@ -749,10 +737,10 @@
// 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. Reset deletes Request object which cancels the request.
- error_observer->RunOnError(
- base::Bind(&scoped_ptr<ProxyResolver::Request>::reset,
- base::Unretained(&request1), nullptr));
+ // the origin thread.
+ error_observer->RunOnError(base::Bind(&ProxyResolver::CancelRequest,
+ base::Unretained(resolver.get()),
+ request1));
// Start another request, to make sure it is able to complete.
rv = resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"),
@@ -840,8 +828,8 @@
ProxyInfo proxy_info1;
ProxyInfo proxy_info2;
- scoped_ptr<ProxyResolver::Request> request1;
- scoped_ptr<ProxyResolver::Request> request2;
+ ProxyResolver::RequestHandle request1;
+ ProxyResolver::RequestHandle request2;
int rv = resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1,
base::Bind(&CrashCallback), &request1,
@@ -859,8 +847,8 @@
host_resolver.WaitUntilRequestIsReceived();
- request1.reset();
- request2.reset();
+ resolver->CancelRequest(request1);
+ resolver->CancelRequest(request2);
EXPECT_EQ(2, host_resolver.num_cancelled_requests());
@@ -869,8 +857,9 @@
// should have been cancelled.
}
-void CancelRequestAndPause(scoped_ptr<ProxyResolver::Request>* request) {
- request->reset();
+void CancelRequestAndPause(ProxyResolver* 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
@@ -889,7 +878,7 @@
nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> request;
+ ProxyResolver::RequestHandle request;
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
base::Bind(&CrashCallback), &request,
@@ -897,7 +886,8 @@
EXPECT_EQ(ERR_IO_PENDING, rv);
- host_resolver.SetAction(base::Bind(CancelRequestAndPause, &request));
+ host_resolver.SetAction(
+ base::Bind(CancelRequestAndPause, resolver.get(), request));
host_resolver.WaitUntilRequestIsReceived();
}
@@ -912,7 +902,7 @@
nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> request;
+ ProxyResolver::RequestHandle request;
int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
base::Bind(&CrashCallback), &request,
@@ -924,7 +914,7 @@
// 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));
- request.reset();
+ resolver->CancelRequest(request);
EXPECT_EQ(0u, host_resolver.num_resolve());
}
@@ -1011,10 +1001,9 @@
TestCompletionCallback callback;
ProxyInfo proxy_info;
- scoped_ptr<ProxyResolver::Request> req;
int rv =
resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info,
- callback.callback(), &req, request_log.bound());
+ callback.callback(), NULL, request_log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
@@ -1092,13 +1081,12 @@
const size_t kNumResults = kNumResolvers * kNumIterations;
TestCompletionCallback callback[kNumResults];
ProxyInfo proxy_info[kNumResults];
- scoped_ptr<ProxyResolver::Request> request[kNumResults];
for (size_t i = 0; i < kNumResults; ++i) {
size_t resolver_i = i % kNumResolvers;
int rv = resolver[resolver_i]->GetProxyForURL(
- GURL("http://foo/"), &proxy_info[i], callback[i].callback(),
- &request[i], BoundNetLog());
+ GURL("http://foo/"), &proxy_info[i], callback[i].callback(), NULL,
+ BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
}
« no previous file with comments | « net/proxy/proxy_resolver_v8_tracing_wrapper.cc ('k') | net/proxy/proxy_resolver_winhttp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698