| 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_NSS_H_ | 5 #ifndef NET_BASE_SSL_CLIENT_SOCKET_NSS_H_ |
| 6 #define NET_BASE_SSL_CLIENT_SOCKET_NSS_H_ | 6 #define NET_BASE_SSL_CLIENT_SOCKET_NSS_H_ |
| 7 | 7 |
| 8 #include <nspr.h> | 8 #include <nspr.h> |
| 9 #include <nss.h> | 9 #include <nss.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // SSLClientSocket methods: | 34 // SSLClientSocket methods: |
| 35 virtual void GetSSLInfo(SSLInfo* ssl_info); | 35 virtual void GetSSLInfo(SSLInfo* ssl_info); |
| 36 | 36 |
| 37 // ClientSocket methods: | 37 // ClientSocket methods: |
| 38 virtual int Connect(CompletionCallback* callback); | 38 virtual int Connect(CompletionCallback* callback); |
| 39 virtual void Disconnect(); | 39 virtual void Disconnect(); |
| 40 virtual bool IsConnected() const; | 40 virtual bool IsConnected() const; |
| 41 virtual bool IsConnectedAndIdle() const; | 41 virtual bool IsConnectedAndIdle() const; |
| 42 | 42 |
| 43 // Socket methods: | 43 // Socket methods: |
| 44 virtual int Read(char* buf, int buf_len, CompletionCallback* callback); | 44 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 45 virtual int Write(const char* buf, int buf_len, CompletionCallback* callback); | 45 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 void InvalidateSessionIfBadCertificate(); | 48 void InvalidateSessionIfBadCertificate(); |
| 49 X509Certificate* UpdateServerCert(); | 49 X509Certificate* UpdateServerCert(); |
| 50 void DoCallback(int result); | 50 void DoCallback(int result); |
| 51 void OnIOComplete(int result); | 51 void OnIOComplete(int result); |
| 52 | 52 |
| 53 int DoLoop(int last_io_result); | 53 int DoLoop(int last_io_result); |
| 54 int DoHandshakeRead(); | 54 int DoHandshakeRead(); |
| 55 int DoPayloadRead(); | 55 int DoPayloadRead(); |
| 56 int DoPayloadWrite(); | 56 int DoPayloadWrite(); |
| 57 int Init(); | 57 int Init(); |
| 58 int BufferSend(void); | 58 int BufferSend(void); |
| 59 int BufferRecv(void); | 59 int BufferRecv(void); |
| 60 void BufferSendComplete(int result); | 60 void BufferSendComplete(int result); |
| 61 void BufferRecvComplete(int result); | 61 void BufferRecvComplete(int result); |
| 62 | 62 |
| 63 // NSS calls this when checking certificates. We pass 'this' as the first | 63 // NSS calls this when checking certificates. We pass 'this' as the first |
| 64 // argument. | 64 // argument. |
| 65 static SECStatus OwnAuthCertHandler(void* arg, PRFileDesc* socket, | 65 static SECStatus OwnAuthCertHandler(void* arg, PRFileDesc* socket, |
| 66 PRBool checksig, PRBool is_server); | 66 PRBool checksig, PRBool is_server); |
| 67 | 67 |
| 68 // NSS calls this on error. We pass 'this' as the first argument. | 68 // NSS calls this on error. We pass 'this' as the first argument. |
| 69 static SECStatus OwnBadCertHandler(void* arg, PRFileDesc* socket); | 69 static SECStatus OwnBadCertHandler(void* arg, PRFileDesc* socket); |
| 70 | 70 |
| 71 CompletionCallbackImpl<SSLClientSocketNSS> buffer_send_callback_; | 71 CompletionCallbackImpl<SSLClientSocketNSS> buffer_send_callback_; |
| 72 CompletionCallbackImpl<SSLClientSocketNSS> buffer_recv_callback_; | 72 CompletionCallbackImpl<SSLClientSocketNSS> buffer_recv_callback_; |
| 73 bool transport_send_busy_; | 73 bool transport_send_busy_; |
| 74 bool transport_recv_busy_; | 74 bool transport_recv_busy_; |
| 75 scoped_refptr<IOBuffer> recv_buffer_; |
| 75 | 76 |
| 76 CompletionCallbackImpl<SSLClientSocketNSS> io_callback_; | 77 CompletionCallbackImpl<SSLClientSocketNSS> io_callback_; |
| 77 scoped_ptr<ClientSocket> transport_; | 78 scoped_ptr<ClientSocket> transport_; |
| 78 std::string hostname_; | 79 std::string hostname_; |
| 79 SSLConfig ssl_config_; | 80 SSLConfig ssl_config_; |
| 80 | 81 |
| 81 CompletionCallback* user_callback_; | 82 CompletionCallback* user_callback_; |
| 82 | 83 |
| 83 // Used by both Read and Write functions. | 84 // Used by both Read and Write functions. |
| 84 char* user_buf_; | 85 scoped_refptr<IOBuffer> user_buf_; |
| 85 int user_buf_len_; | 86 int user_buf_len_; |
| 86 | 87 |
| 87 // Set when handshake finishes. Value is net error code, see net_errors.h | 88 // Set when handshake finishes. Value is net error code, see net_errors.h |
| 88 int server_cert_error_; | 89 int server_cert_error_; |
| 89 | 90 |
| 90 // Set during handshake. | 91 // Set during handshake. |
| 91 scoped_refptr<X509Certificate> server_cert_; | 92 scoped_refptr<X509Certificate> server_cert_; |
| 92 | 93 |
| 93 bool completed_handshake_; | 94 bool completed_handshake_; |
| 94 | 95 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 | 107 |
| 107 // Buffers for the network end of the SSL state machine | 108 // Buffers for the network end of the SSL state machine |
| 108 memio_Private* nss_bufs_; | 109 memio_Private* nss_bufs_; |
| 109 | 110 |
| 110 static bool nss_options_initialized_; | 111 static bool nss_options_initialized_; |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 } // namespace net | 114 } // namespace net |
| 114 | 115 |
| 115 #endif // NET_BASE_SSL_CLIENT_SOCKET_NSS_H_ | 116 #endif // NET_BASE_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |