| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ |
| 7 | 7 |
| 8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 virtual bool IsConnected() const; | 42 virtual bool IsConnected() const; |
| 43 virtual bool IsConnectedAndIdle() const; | 43 virtual bool IsConnectedAndIdle() const; |
| 44 | 44 |
| 45 // Socket methods: | 45 // Socket methods: |
| 46 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 46 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 47 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 47 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 48 virtual bool SetReceiveBufferSize(int32 size); | 48 virtual bool SetReceiveBufferSize(int32 size); |
| 49 virtual bool SetSendBufferSize(int32 size); | 49 virtual bool SetSendBufferSize(int32 size); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 void DoCallback(int result); | 52 void DoConnectCallback(int result); |
| 53 void OnIOComplete(int result); | 53 void DoReadCallback(int result); |
| 54 void DoWriteCallback(int result); |
| 55 void OnHandshakeIOComplete(int result); |
| 56 void OnTransportReadComplete(int result); |
| 57 void OnTransportWriteComplete(int result); |
| 54 | 58 |
| 55 int DoLoop(int last_io_result); | 59 int DoHandshakeLoop(int last_io_result); |
| 60 |
| 56 int DoPayloadRead(); | 61 int DoPayloadRead(); |
| 57 int DoPayloadWrite(); | 62 int DoPayloadWrite(); |
| 58 int DoHandshakeStart(); | 63 int DoHandshakeStart(); |
| 59 int DoVerifyCert(); | 64 int DoVerifyCert(); |
| 60 int DoVerifyCertComplete(int result); | 65 int DoVerifyCertComplete(int result); |
| 61 int DoHandshakeFinish(); | 66 int DoHandshakeFinish(); |
| 62 int DoReadComplete(int result); | |
| 63 void OnWriteComplete(int result); | |
| 64 | 67 |
| 65 static OSStatus SSLReadCallback(SSLConnectionRef connection, | 68 static OSStatus SSLReadCallback(SSLConnectionRef connection, |
| 66 void* data, | 69 void* data, |
| 67 size_t* data_length); | 70 size_t* data_length); |
| 68 static OSStatus SSLWriteCallback(SSLConnectionRef connection, | 71 static OSStatus SSLWriteCallback(SSLConnectionRef connection, |
| 69 const void* data, | 72 const void* data, |
| 70 size_t* data_length); | 73 size_t* data_length); |
| 71 | 74 |
| 72 CompletionCallbackImpl<SSLClientSocketMac> io_callback_; | 75 CompletionCallbackImpl<SSLClientSocketMac> handshake_io_callback_; |
| 73 CompletionCallbackImpl<SSLClientSocketMac> write_callback_; | 76 CompletionCallbackImpl<SSLClientSocketMac> transport_read_callback_; |
| 77 CompletionCallbackImpl<SSLClientSocketMac> transport_write_callback_; |
| 74 | 78 |
| 75 scoped_ptr<ClientSocket> transport_; | 79 scoped_ptr<ClientSocket> transport_; |
| 76 std::string hostname_; | 80 std::string hostname_; |
| 77 SSLConfig ssl_config_; | 81 SSLConfig ssl_config_; |
| 78 | 82 |
| 79 CompletionCallback* user_callback_; | 83 CompletionCallback* user_connect_callback_; |
| 84 CompletionCallback* user_read_callback_; |
| 85 CompletionCallback* user_write_callback_; |
| 80 | 86 |
| 81 // Used by both Read and Write functions. | 87 // Used by Read function. |
| 82 scoped_refptr<IOBuffer> user_buf_; | 88 scoped_refptr<IOBuffer> user_read_buf_; |
| 83 int user_buf_len_; | 89 int user_read_buf_len_; |
| 90 |
| 91 // Used by Write function. |
| 92 scoped_refptr<IOBuffer> user_write_buf_; |
| 93 int user_write_buf_len_; |
| 84 | 94 |
| 85 enum State { | 95 enum State { |
| 86 STATE_NONE, | 96 STATE_NONE, |
| 87 STATE_PAYLOAD_READ, | |
| 88 STATE_PAYLOAD_WRITE, | |
| 89 STATE_HANDSHAKE_START, | 97 STATE_HANDSHAKE_START, |
| 90 STATE_VERIFY_CERT, | 98 STATE_VERIFY_CERT, |
| 91 STATE_VERIFY_CERT_COMPLETE, | 99 STATE_VERIFY_CERT_COMPLETE, |
| 92 STATE_HANDSHAKE_FINISH, | 100 STATE_HANDSHAKE_FINISH, |
| 93 STATE_READ_COMPLETE, | |
| 94 }; | 101 }; |
| 95 State next_state_; | 102 State next_handshake_state_; |
| 96 State next_io_state_; | |
| 97 | 103 |
| 98 scoped_refptr<X509Certificate> server_cert_; | 104 scoped_refptr<X509Certificate> server_cert_; |
| 99 std::vector<scoped_refptr<X509Certificate> > intermediate_certs_; | 105 std::vector<scoped_refptr<X509Certificate> > intermediate_certs_; |
| 100 scoped_ptr<CertVerifier> verifier_; | 106 scoped_ptr<CertVerifier> verifier_; |
| 101 CertVerifyResult server_cert_verify_result_; | 107 CertVerifyResult server_cert_verify_result_; |
| 102 | 108 |
| 103 bool completed_handshake_; | 109 bool completed_handshake_; |
| 104 bool handshake_interrupted_; | 110 bool handshake_interrupted_; |
| 105 SSLContextRef ssl_context_; | 111 SSLContextRef ssl_context_; |
| 106 | 112 |
| 107 // These are buffers for holding data during I/O. The "slop" is the amount of | 113 // These are buffers for holding data during I/O. The "slop" is the amount of |
| 108 // space at the ends of the receive buffer that are allocated for holding data | 114 // space at the ends of the receive buffer that are allocated for holding data |
| 109 // but don't (yet). | 115 // but don't (yet). |
| 110 std::vector<char> send_buffer_; | 116 std::vector<char> send_buffer_; |
| 111 int pending_send_error_; | 117 int pending_send_error_; |
| 112 std::vector<char> recv_buffer_; | 118 std::vector<char> recv_buffer_; |
| 113 int recv_buffer_head_slop_; | 119 int recv_buffer_head_slop_; |
| 114 int recv_buffer_tail_slop_; | 120 int recv_buffer_tail_slop_; |
| 115 | 121 |
| 116 // This buffer holds data for Read() operations on the underlying transport | 122 // This buffer holds data for Read() operations on the underlying transport |
| 117 // (ClientSocket::Read()). | 123 // (ClientSocket::Read()). |
| 118 scoped_refptr<IOBuffer> read_io_buf_; | 124 scoped_refptr<IOBuffer> read_io_buf_; |
| 119 }; | 125 }; |
| 120 | 126 |
| 121 } // namespace net | 127 } // namespace net |
| 122 | 128 |
| 123 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ | 129 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_MAC_H_ |
| OLD | NEW |