Chromium Code Reviews| Index: net/socket/socks_client_socket_unittest.cc |
| diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc |
| index e287783955403c26408ae7fc20f8059701455da9..175b26f40c427f49394f18557c384fac5ef554d0 100644 |
| --- a/net/socket/socks_client_socket_unittest.cc |
| +++ b/net/socket/socks_client_socket_unittest.cc |
| @@ -104,6 +104,9 @@ std::unique_ptr<SOCKSClientSocket> SOCKSClientSocketTest::BuildMockSocket( |
| // We use this in the test "DisconnectWhileHostResolveInProgress" to make |
| // sure that the outstanding resolve request gets cancelled. |
| class HangingHostResolverWithCancel : public HostResolver { |
| + private: |
| + class RequestImpl; |
|
mmenke
2016/07/19 19:03:56
Can't have a private section before the public sec
maksims (do not use this acc)
2016/07/21 07:12:46
Done.
|
| + |
| public: |
| HangingHostResolverWithCancel() : outstanding_request_(NULL) {} |
| @@ -111,13 +114,13 @@ class HangingHostResolverWithCancel : public HostResolver { |
| RequestPriority priority, |
| AddressList* addresses, |
| const CompletionCallback& callback, |
| - RequestHandle* out_req, |
| + std::unique_ptr<Request>* out_req, |
| const BoundNetLog& net_log) override { |
| DCHECK(addresses); |
| DCHECK_EQ(false, callback.is_null()); |
| EXPECT_FALSE(HasOutstandingRequest()); |
| - outstanding_request_ = reinterpret_cast<RequestHandle>(1); |
| - *out_req = outstanding_request_; |
| + outstanding_request_ = new RequestImpl(this); |
| + (*out_req).reset(outstanding_request_); |
|
mmenke
2016/07/19 19:03:56
out_req->reset
maksims (do not use this acc)
2016/07/21 07:12:46
Done.
|
| return ERR_IO_PENDING; |
| } |
| @@ -128,18 +131,31 @@ class HangingHostResolverWithCancel : public HostResolver { |
| return ERR_UNEXPECTED; |
| } |
| - void CancelRequest(RequestHandle req) override { |
| + void RemoveRequest(RequestImpl* req) { |
| EXPECT_TRUE(HasOutstandingRequest()); |
| EXPECT_EQ(outstanding_request_, req); |
| - outstanding_request_ = NULL; |
| + outstanding_request_ = nullptr; |
| } |
| - bool HasOutstandingRequest() { |
| - return outstanding_request_ != NULL; |
| - } |
| + bool HasOutstandingRequest() { return outstanding_request_ != nullptr; } |
| private: |
| - RequestHandle outstanding_request_; |
| + class RequestImpl : public HostResolver::Request { |
| + public: |
| + RequestImpl(HangingHostResolverWithCancel* resolver) |
| + : resolver_(resolver) {} |
| + ~RequestImpl() override { |
| + DCHECK(resolver_); |
| + resolver_->RemoveRequest(this); |
| + } |
| + |
| + void ChangeRequestPriority(RequestPriority priority) override {} |
| + |
| + private: |
| + HangingHostResolverWithCancel* resolver_; |
| + }; |
| + |
| + RequestImpl* outstanding_request_; |
| DISALLOW_COPY_AND_ASSIGN(HangingHostResolverWithCancel); |
| }; |