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

Unified Diff: net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http_stream_factory_impl_job_controller_unittest RequestHandle* to unique_ptr Created 4 years, 5 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_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 24399e60268ddfa5194f9095438613c7b80d8dc5..e2d1e24a65b111206e1c9b9b32fd480e8fc6a0c4 100644
--- a/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
@@ -771,7 +771,7 @@ class BlockableHostResolver : public HostResolver {
RequestPriority priority,
AddressList* addresses,
const CompletionCallback& callback,
- RequestHandle* out_req,
+ std::unique_ptr<Request>* out_req,
const BoundNetLog& net_log) override {
EXPECT_FALSE(callback.is_null());
EXPECT_TRUE(out_req);
@@ -786,7 +786,7 @@ class BlockableHostResolver : public HostResolver {
// 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.
+ out_req->reset(new RequestImpl(this));
// Return ERR_IO_PENDING as this request will NEVER be completed.
// Expectation is for the caller to later cancel the request.
@@ -800,10 +800,7 @@ class BlockableHostResolver : public HostResolver {
return ERR_DNS_CACHE_MISS;
}
- void CancelRequest(RequestHandle req) override {
- EXPECT_EQ(reinterpret_cast<RequestHandle*>(1), req);
- num_cancelled_requests_++;
- }
+ void IncreaseNumOfCancelledRequests() { num_cancelled_requests_++; }
void SetAction(const base::Callback<void(void)>& action) { action_ = action; }
@@ -818,6 +815,23 @@ class BlockableHostResolver : public HostResolver {
int num_cancelled_requests() const { return num_cancelled_requests_; }
private:
+ class RequestImpl : public HostResolver::Request {
+ public:
+ RequestImpl(BlockableHostResolver* resolver) : resolver_(resolver) {}
+
+ ~RequestImpl() override {
+ if (resolver_)
+ resolver_->IncreaseNumOfCancelledRequests();
+ }
+
+ void ChangeRequestPriority(RequestPriority priority) override {}
+
+ private:
+ BlockableHostResolver* resolver_;
+
+ DISALLOW_COPY_AND_ASSIGN(RequestImpl);
+ };
+
int num_cancelled_requests_;
bool waiting_for_resolve_;
base::Callback<void(void)> action_;

Powered by Google App Engine
This is Rietveld 408576698