OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This StreamSocket implementation is to be used with servers that | 5 // This StreamSocket implementation is to be used with servers that |
6 // accept connections on port 443 but don't really use SSL. For | 6 // accept connections on port 443 but don't really use SSL. For |
7 // example, the Google Talk servers do this to bypass proxies. (The | 7 // example, the Google Talk servers do this to bypass proxies. (The |
8 // connection is upgraded to TLS as part of the XMPP negotiation, so | 8 // connection is upgraded to TLS as part of the XMPP negotiation, so |
9 // security is preserved.) A "fake" SSL handshake is done immediately | 9 // security is preserved.) A "fake" SSL handshake is done immediately |
10 // after connection to fool proxies into thinking that this is a real | 10 // after connection to fool proxies into thinking that this is a real |
(...skipping 29 matching lines...) Expand all Loading... |
40 explicit FakeSSLClientSocket(net::StreamSocket* transport_socket); | 40 explicit FakeSSLClientSocket(net::StreamSocket* transport_socket); |
41 | 41 |
42 virtual ~FakeSSLClientSocket(); | 42 virtual ~FakeSSLClientSocket(); |
43 | 43 |
44 // Exposed for testing. | 44 // Exposed for testing. |
45 static base::StringPiece GetSslClientHello(); | 45 static base::StringPiece GetSslClientHello(); |
46 static base::StringPiece GetSslServerHello(); | 46 static base::StringPiece GetSslServerHello(); |
47 | 47 |
48 // net::StreamSocket implementation. | 48 // net::StreamSocket implementation. |
49 virtual int Read(net::IOBuffer* buf, int buf_len, | 49 virtual int Read(net::IOBuffer* buf, int buf_len, |
50 net::OldCompletionCallback* callback) OVERRIDE; | |
51 virtual int Read(net::IOBuffer* buf, int buf_len, | |
52 const net::CompletionCallback& callback) OVERRIDE; | 50 const net::CompletionCallback& callback) OVERRIDE; |
53 virtual int Write(net::IOBuffer* buf, int buf_len, | 51 virtual int Write(net::IOBuffer* buf, int buf_len, |
54 net::OldCompletionCallback* callback) OVERRIDE; | 52 const net::CompletionCallback& callback) OVERRIDE; |
55 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 53 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
56 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 54 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
57 virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; | |
58 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | 55 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; |
59 virtual void Disconnect() OVERRIDE; | 56 virtual void Disconnect() OVERRIDE; |
60 virtual bool IsConnected() const OVERRIDE; | 57 virtual bool IsConnected() const OVERRIDE; |
61 virtual bool IsConnectedAndIdle() const OVERRIDE; | 58 virtual bool IsConnectedAndIdle() const OVERRIDE; |
62 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; | 59 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; |
63 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; | 60 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; |
64 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 61 virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
65 virtual void SetSubresourceSpeculation() OVERRIDE; | 62 virtual void SetSubresourceSpeculation() OVERRIDE; |
66 virtual void SetOmniboxSpeculation() OVERRIDE; | 63 virtual void SetOmniboxSpeculation() OVERRIDE; |
67 virtual bool WasEverUsed() const OVERRIDE; | 64 virtual bool WasEverUsed() const OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
86 void ProcessConnectDone(); | 83 void ProcessConnectDone(); |
87 | 84 |
88 int DoSendClientHello(); | 85 int DoSendClientHello(); |
89 void OnSendClientHelloDone(int status); | 86 void OnSendClientHelloDone(int status); |
90 void ProcessSendClientHelloDone(size_t written); | 87 void ProcessSendClientHelloDone(size_t written); |
91 | 88 |
92 int DoVerifyServerHello(); | 89 int DoVerifyServerHello(); |
93 void OnVerifyServerHelloDone(int status); | 90 void OnVerifyServerHelloDone(int status); |
94 net::Error ProcessVerifyServerHelloDone(size_t read); | 91 net::Error ProcessVerifyServerHelloDone(size_t read); |
95 | 92 |
96 // Callbacks passed to |transport_socket_|. | |
97 net::OldCompletionCallbackImpl<FakeSSLClientSocket> connect_callback_; | |
98 net::OldCompletionCallbackImpl<FakeSSLClientSocket> | |
99 send_client_hello_callback_; | |
100 net::OldCompletionCallbackImpl<FakeSSLClientSocket> | |
101 verify_server_hello_callback_; | |
102 | |
103 scoped_ptr<net::StreamSocket> transport_socket_; | 93 scoped_ptr<net::StreamSocket> transport_socket_; |
104 | 94 |
105 // During the handshake process, holds a value from HandshakeState. | 95 // During the handshake process, holds a value from HandshakeState. |
106 // STATE_NONE otherwise. | 96 // STATE_NONE otherwise. |
107 HandshakeState next_handshake_state_; | 97 HandshakeState next_handshake_state_; |
108 | 98 |
109 // True iff we're connected and we've finished the handshake. | 99 // True iff we're connected and we've finished the handshake. |
110 bool handshake_completed_; | 100 bool handshake_completed_; |
111 | 101 |
112 // The callback passed to Connect(). | 102 // The callback passed to Connect(). |
113 net::OldCompletionCallback* old_user_connect_callback_; | |
114 net::CompletionCallback user_connect_callback_; | 103 net::CompletionCallback user_connect_callback_; |
115 | 104 |
116 scoped_refptr<net::DrainableIOBuffer> write_buf_; | 105 scoped_refptr<net::DrainableIOBuffer> write_buf_; |
117 scoped_refptr<net::DrainableIOBuffer> read_buf_; | 106 scoped_refptr<net::DrainableIOBuffer> read_buf_; |
118 }; | 107 }; |
119 | 108 |
120 } // namespace notifier | 109 } // namespace notifier |
121 | 110 |
122 #endif // JINGLE_NOTIFIER_BASE_FAKE_SSL_CLIENT_SOCKET_H_ | 111 #endif // JINGLE_NOTIFIER_BASE_FAKE_SSL_CLIENT_SOCKET_H_ |
OLD | NEW |