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

Unified Diff: net/proxy/proxy_resolver_factory_mojo_unittest.cc

Issue 2299963002: Reland "Change ProxyResolver::GetProxyForURL() to take a unique_ptr<Request>* " (Closed)
Patch Set: remove fields proposed by eroman Created 4 years, 2 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_factory_mojo.cc ('k') | net/proxy/proxy_resolver_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_factory_mojo_unittest.cc
diff --git a/net/proxy/proxy_resolver_factory_mojo_unittest.cc b/net/proxy/proxy_resolver_factory_mojo_unittest.cc
index ed9e0f5cc77951d4d6679bb4ceff7937a8c3fba0..a53bbd034e3f498872788c37868ac3a5871d1fca 100644
--- a/net/proxy/proxy_resolver_factory_mojo_unittest.cc
+++ b/net/proxy/proxy_resolver_factory_mojo_unittest.cc
@@ -299,14 +299,15 @@ class Request {
int WaitForResult();
const ProxyInfo& results() const { return results_; }
- LoadState load_state() { return resolver_->GetLoadState(handle_); }
+ LoadState load_state() { return request_->GetLoadState(); }
BoundTestNetLog& net_log() { return net_log_; }
+ const TestCompletionCallback& callback() const { return callback_; }
private:
ProxyResolver* resolver_;
const GURL url_;
ProxyInfo results_;
- ProxyResolver::RequestHandle handle_;
+ std::unique_ptr<ProxyResolver::Request> request_;
int error_;
TestCompletionCallback callback_;
BoundTestNetLog net_log_;
@@ -318,12 +319,12 @@ Request::Request(ProxyResolver* resolver, const GURL& url)
int Request::Resolve() {
error_ = resolver_->GetProxyForURL(url_, &results_, callback_.callback(),
- &handle_, net_log_.bound());
+ &request_, net_log_.bound());
return error_;
}
void Request::Cancel() {
- resolver_->CancelRequest(handle_);
+ request_.reset();
}
int Request::WaitForResult() {
@@ -788,6 +789,7 @@ TEST_F(ProxyResolverFactoryMojoTest, GetProxyForURL_Cancel) {
std::unique_ptr<Request> request(MakeRequest(GURL(kExampleUrl)));
EXPECT_THAT(request->Resolve(), IsError(ERR_IO_PENDING));
request->Cancel();
+ EXPECT_FALSE(request->callback().have_result());
// The Mojo request is still made.
mock_proxy_resolver_.WaitForNextRequest();
@@ -850,7 +852,7 @@ TEST_F(ProxyResolverFactoryMojoTest, GetProxyForURL_DeleteInCallback) {
ProxyInfo results;
TestCompletionCallback callback;
- ProxyResolver::RequestHandle handle;
+ std::unique_ptr<ProxyResolver::Request> request;
NetLogWithSource net_log;
EXPECT_EQ(
OK,
@@ -858,7 +860,7 @@ TEST_F(ProxyResolverFactoryMojoTest, GetProxyForURL_DeleteInCallback) {
GURL(kExampleUrl), &results,
base::Bind(&ProxyResolverFactoryMojoTest::DeleteProxyResolverCallback,
base::Unretained(this), callback.callback()),
- &handle, net_log)));
+ &request, net_log)));
on_delete_callback_.WaitForResult();
}
@@ -870,7 +872,7 @@ TEST_F(ProxyResolverFactoryMojoTest,
ProxyInfo results;
TestCompletionCallback callback;
- ProxyResolver::RequestHandle handle;
+ std::unique_ptr<ProxyResolver::Request> request;
NetLogWithSource net_log;
EXPECT_EQ(
ERR_PAC_SCRIPT_TERMINATED,
@@ -878,7 +880,7 @@ TEST_F(ProxyResolverFactoryMojoTest,
GURL(kExampleUrl), &results,
base::Bind(&ProxyResolverFactoryMojoTest::DeleteProxyResolverCallback,
base::Unretained(this), callback.callback()),
- &handle, net_log)));
+ &request, net_log)));
on_delete_callback_.WaitForResult();
}
« no previous file with comments | « net/proxy/proxy_resolver_factory_mojo.cc ('k') | net/proxy/proxy_resolver_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698