OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BASE_SSL_CLIENT_SOCKET_MAC_H_ | 5 #ifndef NET_BASE_SSL_CLIENT_SOCKET_MAC_H_ |
6 #define NET_BASE_SSL_CLIENT_SOCKET_MAC_H_ | 6 #define NET_BASE_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 21 matching lines...) Expand all Loading... |
32 // SSLClientSocket methods: | 32 // SSLClientSocket methods: |
33 virtual void GetSSLInfo(SSLInfo* ssl_info); | 33 virtual void GetSSLInfo(SSLInfo* ssl_info); |
34 | 34 |
35 // ClientSocket methods: | 35 // ClientSocket methods: |
36 virtual int Connect(CompletionCallback* callback); | 36 virtual int Connect(CompletionCallback* callback); |
37 virtual void Disconnect(); | 37 virtual void Disconnect(); |
38 virtual bool IsConnected() const; | 38 virtual bool IsConnected() const; |
39 virtual bool IsConnectedAndIdle() const; | 39 virtual bool IsConnectedAndIdle() const; |
40 | 40 |
41 // Socket methods: | 41 // Socket methods: |
42 virtual int Read(char* buf, int buf_len, CompletionCallback* callback); | 42 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
43 virtual int Write(const char* buf, int buf_len, CompletionCallback* callback); | 43 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
44 | 44 |
45 private: | 45 private: |
46 void DoCallback(int result); | 46 void DoCallback(int result); |
47 void OnIOComplete(int result); | 47 void OnIOComplete(int result); |
48 | 48 |
49 int DoLoop(int last_io_result); | 49 int DoLoop(int last_io_result); |
50 int DoPayloadRead(); | 50 int DoPayloadRead(); |
51 int DoPayloadWrite(); | 51 int DoPayloadWrite(); |
52 int DoHandshake(); | 52 int DoHandshake(); |
53 int DoReadComplete(int result); | 53 int DoReadComplete(int result); |
54 void OnWriteComplete(int result); | 54 void OnWriteComplete(int result); |
55 | 55 |
56 static OSStatus SSLReadCallback(SSLConnectionRef connection, | 56 static OSStatus SSLReadCallback(SSLConnectionRef connection, |
57 void* data, | 57 void* data, |
58 size_t* data_length); | 58 size_t* data_length); |
59 static OSStatus SSLWriteCallback(SSLConnectionRef connection, | 59 static OSStatus SSLWriteCallback(SSLConnectionRef connection, |
60 const void* data, | 60 const void* data, |
61 size_t* data_length); | 61 size_t* data_length); |
62 | 62 |
63 CompletionCallbackImpl<SSLClientSocketMac> io_callback_; | 63 CompletionCallbackImpl<SSLClientSocketMac> io_callback_; |
64 CompletionCallbackImpl<SSLClientSocketMac> write_callback_; | 64 CompletionCallbackImpl<SSLClientSocketMac> write_callback_; |
65 | 65 |
66 scoped_ptr<ClientSocket> transport_; | 66 scoped_ptr<ClientSocket> transport_; |
67 std::string hostname_; | 67 std::string hostname_; |
68 SSLConfig ssl_config_; | 68 SSLConfig ssl_config_; |
69 | 69 |
70 CompletionCallback* user_callback_; | 70 CompletionCallback* user_callback_; |
71 | 71 |
72 // Used by both Read and Write functions. | 72 // Used by both Read and Write functions. |
73 char* user_buf_; | 73 scoped_refptr<IOBuffer> user_buf_; |
74 int user_buf_len_; | 74 int user_buf_len_; |
75 | 75 |
76 enum State { | 76 enum State { |
77 STATE_NONE, | 77 STATE_NONE, |
78 STATE_PAYLOAD_READ, | 78 STATE_PAYLOAD_READ, |
79 STATE_PAYLOAD_WRITE, | 79 STATE_PAYLOAD_WRITE, |
80 STATE_HANDSHAKE, | 80 STATE_HANDSHAKE, |
81 STATE_READ_COMPLETE, | 81 STATE_READ_COMPLETE, |
82 }; | 82 }; |
83 State next_state_; | 83 State next_state_; |
84 State next_io_state_; | 84 State next_io_state_; |
85 | 85 |
86 int server_cert_status_; | 86 int server_cert_status_; |
87 | 87 |
88 bool completed_handshake_; | 88 bool completed_handshake_; |
89 SSLContextRef ssl_context_; | 89 SSLContextRef ssl_context_; |
90 | 90 |
91 // These are buffers for holding data during I/O. The "slop" is the amount of | 91 // These are buffers for holding data during I/O. The "slop" is the amount of |
92 // space at the ends of the receive buffer that are allocated for holding data | 92 // space at the ends of the receive buffer that are allocated for holding data |
93 // but don't (yet). | 93 // but don't (yet). |
94 std::vector<char> send_buffer_; | 94 std::vector<char> send_buffer_; |
95 int pending_send_error_; | 95 int pending_send_error_; |
96 std::vector<char> recv_buffer_; | 96 std::vector<char> recv_buffer_; |
97 int recv_buffer_head_slop_; | 97 int recv_buffer_head_slop_; |
98 int recv_buffer_tail_slop_; | 98 int recv_buffer_tail_slop_; |
| 99 |
| 100 // This buffer holds data for Read() operations on the underlying transport |
| 101 // (ClientSocket::Read()). |
| 102 scoped_refptr<IOBuffer> read_io_buf_; |
99 }; | 103 }; |
100 | 104 |
101 } // namespace net | 105 } // namespace net |
102 | 106 |
103 #endif // NET_BASE_SSL_CLIENT_SOCKET_MAC_H_ | 107 #endif // NET_BASE_SSL_CLIENT_SOCKET_MAC_H_ |
OLD | NEW |