OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // sure that the outstanding resolve request gets cancelled. | 94 // sure that the outstanding resolve request gets cancelled. |
95 class HangingHostResolverWithCancel : public HostResolver { | 95 class HangingHostResolverWithCancel : public HostResolver { |
96 public: | 96 public: |
97 HangingHostResolverWithCancel() : outstanding_request_(NULL) {} | 97 HangingHostResolverWithCancel() : outstanding_request_(NULL) {} |
98 | 98 |
99 virtual int Resolve(const RequestInfo& info, | 99 virtual int Resolve(const RequestInfo& info, |
100 RequestPriority priority, | 100 RequestPriority priority, |
101 AddressList* addresses, | 101 AddressList* addresses, |
102 const CompletionCallback& callback, | 102 const CompletionCallback& callback, |
103 RequestHandle* out_req, | 103 RequestHandle* out_req, |
104 const BoundNetLog& net_log) OVERRIDE { | 104 const BoundNetLog& net_log) override { |
105 DCHECK(addresses); | 105 DCHECK(addresses); |
106 DCHECK_EQ(false, callback.is_null()); | 106 DCHECK_EQ(false, callback.is_null()); |
107 EXPECT_FALSE(HasOutstandingRequest()); | 107 EXPECT_FALSE(HasOutstandingRequest()); |
108 outstanding_request_ = reinterpret_cast<RequestHandle>(1); | 108 outstanding_request_ = reinterpret_cast<RequestHandle>(1); |
109 *out_req = outstanding_request_; | 109 *out_req = outstanding_request_; |
110 return ERR_IO_PENDING; | 110 return ERR_IO_PENDING; |
111 } | 111 } |
112 | 112 |
113 virtual int ResolveFromCache(const RequestInfo& info, | 113 virtual int ResolveFromCache(const RequestInfo& info, |
114 AddressList* addresses, | 114 AddressList* addresses, |
115 const BoundNetLog& net_log) OVERRIDE { | 115 const BoundNetLog& net_log) override { |
116 NOTIMPLEMENTED(); | 116 NOTIMPLEMENTED(); |
117 return ERR_UNEXPECTED; | 117 return ERR_UNEXPECTED; |
118 } | 118 } |
119 | 119 |
120 virtual void CancelRequest(RequestHandle req) OVERRIDE { | 120 virtual void CancelRequest(RequestHandle req) override { |
121 EXPECT_TRUE(HasOutstandingRequest()); | 121 EXPECT_TRUE(HasOutstandingRequest()); |
122 EXPECT_EQ(outstanding_request_, req); | 122 EXPECT_EQ(outstanding_request_, req); |
123 outstanding_request_ = NULL; | 123 outstanding_request_ = NULL; |
124 } | 124 } |
125 | 125 |
126 bool HasOutstandingRequest() { | 126 bool HasOutstandingRequest() { |
127 return outstanding_request_ != NULL; | 127 return outstanding_request_ != NULL; |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 NULL, 0, | 441 NULL, 0, |
442 host_resolver.get(), | 442 host_resolver.get(), |
443 kHostName, 80, | 443 kHostName, 80, |
444 NULL); | 444 NULL); |
445 | 445 |
446 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, | 446 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, |
447 callback_.GetResult(user_sock_->Connect(callback_.callback()))); | 447 callback_.GetResult(user_sock_->Connect(callback_.callback()))); |
448 } | 448 } |
449 | 449 |
450 } // namespace net | 450 } // namespace net |
OLD | NEW |