OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/socket_test_util.h" | 5 #include "net/base/socket_test_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/socket.h" | 11 #include "net/base/socket.h" |
12 #include "net/base/ssl_client_socket.h" | 12 #include "net/base/ssl_client_socket.h" |
13 #include "net/base/ssl_info.h" | 13 #include "net/base/ssl_info.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 class MockClientSocket : public net::SSLClientSocket { | 18 class MockClientSocket : public net::SSLClientSocket { |
19 public: | 19 public: |
20 MockClientSocket(); | 20 MockClientSocket(); |
21 | 21 |
22 // ClientSocket methods: | 22 // ClientSocket methods: |
23 virtual int Connect(net::CompletionCallback* callback) = 0; | 23 virtual int Connect(net::CompletionCallback* callback) = 0; |
24 | 24 |
25 // SSLClientSocket methods: | 25 // SSLClientSocket methods: |
26 virtual void GetSSLInfo(net::SSLInfo* ssl_info); | 26 virtual void GetSSLInfo(net::SSLInfo* ssl_info); |
| 27 virtual void GetSSLCertRequestInfo( |
| 28 net::SSLCertRequestInfo* cert_request_info); |
27 virtual void Disconnect(); | 29 virtual void Disconnect(); |
28 virtual bool IsConnected() const; | 30 virtual bool IsConnected() const; |
29 virtual bool IsConnectedAndIdle() const; | 31 virtual bool IsConnectedAndIdle() const; |
30 | 32 |
31 // Socket methods: | 33 // Socket methods: |
32 virtual int Read(net::IOBuffer* buf, int buf_len, | 34 virtual int Read(net::IOBuffer* buf, int buf_len, |
33 net::CompletionCallback* callback) = 0; | 35 net::CompletionCallback* callback) = 0; |
34 virtual int Write(net::IOBuffer* buf, int buf_len, | 36 virtual int Write(net::IOBuffer* buf, int buf_len, |
35 net::CompletionCallback* callback) = 0; | 37 net::CompletionCallback* callback) = 0; |
36 | 38 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 MockClientSocket::MockClientSocket() | 100 MockClientSocket::MockClientSocket() |
99 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 101 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
100 callback_(NULL), | 102 callback_(NULL), |
101 connected_(false) { | 103 connected_(false) { |
102 } | 104 } |
103 | 105 |
104 void MockClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) { | 106 void MockClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) { |
105 NOTREACHED(); | 107 NOTREACHED(); |
106 } | 108 } |
107 | 109 |
| 110 void MockClientSocket::GetSSLCertRequestInfo( |
| 111 net::SSLCertRequestInfo* cert_request_info) { |
| 112 NOTREACHED(); |
| 113 } |
| 114 |
108 void MockClientSocket::Disconnect() { | 115 void MockClientSocket::Disconnect() { |
109 connected_ = false; | 116 connected_ = false; |
110 callback_ = NULL; | 117 callback_ = NULL; |
111 } | 118 } |
112 | 119 |
113 bool MockClientSocket::IsConnected() const { | 120 bool MockClientSocket::IsConnected() const { |
114 return connected_; | 121 return connected_; |
115 } | 122 } |
116 | 123 |
117 bool MockClientSocket::IsConnectedAndIdle() const { | 124 bool MockClientSocket::IsConnectedAndIdle() const { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 327 |
321 SSLClientSocket* MockClientSocketFactory::CreateSSLClientSocket( | 328 SSLClientSocket* MockClientSocketFactory::CreateSSLClientSocket( |
322 ClientSocket* transport_socket, | 329 ClientSocket* transport_socket, |
323 const std::string& hostname, | 330 const std::string& hostname, |
324 const SSLConfig& ssl_config) { | 331 const SSLConfig& ssl_config) { |
325 return new MockSSLClientSocket(transport_socket, hostname, ssl_config, | 332 return new MockSSLClientSocket(transport_socket, hostname, ssl_config, |
326 mock_ssl_sockets_.GetNext()); | 333 mock_ssl_sockets_.GetNext()); |
327 } | 334 } |
328 | 335 |
329 } // namespace net | 336 } // namespace net |
OLD | NEW |