OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/transport_client_socket_pool_test_util.h" | 5 #include "net/socket/transport_client_socket_pool_test_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
18 #include "net/base/load_timing_info.h" | 19 #include "net/base/load_timing_info.h" |
19 #include "net/base/load_timing_info_test_util.h" | 20 #include "net/base/load_timing_info_test_util.h" |
20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
21 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
22 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 int Read(IOBuffer* buf, | 89 int Read(IOBuffer* buf, |
89 int buf_len, | 90 int buf_len, |
90 const CompletionCallback& callback) override { | 91 const CompletionCallback& callback) override { |
91 return ERR_FAILED; | 92 return ERR_FAILED; |
92 } | 93 } |
93 int Write(IOBuffer* buf, | 94 int Write(IOBuffer* buf, |
94 int buf_len, | 95 int buf_len, |
95 const CompletionCallback& callback) override { | 96 const CompletionCallback& callback) override { |
96 return ERR_FAILED; | 97 return ERR_FAILED; |
97 } | 98 } |
98 int SetReceiveBufferSize(int32 size) override { return OK; } | 99 int SetReceiveBufferSize(int32_t size) override { return OK; } |
99 int SetSendBufferSize(int32 size) override { return OK; } | 100 int SetSendBufferSize(int32_t size) override { return OK; } |
100 | 101 |
101 private: | 102 private: |
102 bool connected_; | 103 bool connected_; |
103 const AddressList addrlist_; | 104 const AddressList addrlist_; |
104 BoundNetLog net_log_; | 105 BoundNetLog net_log_; |
105 bool use_tcp_fastopen_; | 106 bool use_tcp_fastopen_; |
106 | 107 |
107 DISALLOW_COPY_AND_ASSIGN(MockConnectClientSocket); | 108 DISALLOW_COPY_AND_ASSIGN(MockConnectClientSocket); |
108 }; | 109 }; |
109 | 110 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 int buf_len, | 157 int buf_len, |
157 const CompletionCallback& callback) override { | 158 const CompletionCallback& callback) override { |
158 return ERR_FAILED; | 159 return ERR_FAILED; |
159 } | 160 } |
160 | 161 |
161 int Write(IOBuffer* buf, | 162 int Write(IOBuffer* buf, |
162 int buf_len, | 163 int buf_len, |
163 const CompletionCallback& callback) override { | 164 const CompletionCallback& callback) override { |
164 return ERR_FAILED; | 165 return ERR_FAILED; |
165 } | 166 } |
166 int SetReceiveBufferSize(int32 size) override { return OK; } | 167 int SetReceiveBufferSize(int32_t size) override { return OK; } |
167 int SetSendBufferSize(int32 size) override { return OK; } | 168 int SetSendBufferSize(int32_t size) override { return OK; } |
168 | 169 |
169 private: | 170 private: |
170 const AddressList addrlist_; | 171 const AddressList addrlist_; |
171 BoundNetLog net_log_; | 172 BoundNetLog net_log_; |
172 bool use_tcp_fastopen_; | 173 bool use_tcp_fastopen_; |
173 | 174 |
174 DISALLOW_COPY_AND_ASSIGN(MockFailingClientSocket); | 175 DISALLOW_COPY_AND_ASSIGN(MockFailingClientSocket); |
175 }; | 176 }; |
176 | 177 |
177 class MockTriggerableClientSocket : public StreamSocket { | 178 class MockTriggerableClientSocket : public StreamSocket { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 int buf_len, | 287 int buf_len, |
287 const CompletionCallback& callback) override { | 288 const CompletionCallback& callback) override { |
288 return ERR_FAILED; | 289 return ERR_FAILED; |
289 } | 290 } |
290 | 291 |
291 int Write(IOBuffer* buf, | 292 int Write(IOBuffer* buf, |
292 int buf_len, | 293 int buf_len, |
293 const CompletionCallback& callback) override { | 294 const CompletionCallback& callback) override { |
294 return ERR_FAILED; | 295 return ERR_FAILED; |
295 } | 296 } |
296 int SetReceiveBufferSize(int32 size) override { return OK; } | 297 int SetReceiveBufferSize(int32_t size) override { return OK; } |
297 int SetSendBufferSize(int32 size) override { return OK; } | 298 int SetSendBufferSize(int32_t size) override { return OK; } |
298 | 299 |
299 private: | 300 private: |
300 void DoCallback() { | 301 void DoCallback() { |
301 is_connected_ = should_connect_; | 302 is_connected_ = should_connect_; |
302 callback_.Run(is_connected_ ? OK : ERR_CONNECTION_FAILED); | 303 callback_.Run(is_connected_ ? OK : ERR_CONNECTION_FAILED); |
303 } | 304 } |
304 | 305 |
305 bool should_connect_; | 306 bool should_connect_; |
306 bool is_connected_; | 307 bool is_connected_; |
307 const AddressList addrlist_; | 308 const AddressList addrlist_; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 run_loop_quit_closure_ = run_loop.QuitClosure(); | 464 run_loop_quit_closure_ = run_loop.QuitClosure(); |
464 run_loop.Run(); | 465 run_loop.Run(); |
465 run_loop_quit_closure_.Reset(); | 466 run_loop_quit_closure_.Reset(); |
466 } | 467 } |
467 base::Closure trigger = triggerable_sockets_.front(); | 468 base::Closure trigger = triggerable_sockets_.front(); |
468 triggerable_sockets_.pop(); | 469 triggerable_sockets_.pop(); |
469 return trigger; | 470 return trigger; |
470 } | 471 } |
471 | 472 |
472 } // namespace net | 473 } // namespace net |
OLD | NEW |