| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NSS_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 7 | 7 |
| 8 #include <certt.h> | 8 #include <certt.h> |
| 9 #include <keyt.h> | 9 #include <keyt.h> |
| 10 #include <nspr.h> | 10 #include <nspr.h> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Because calls to NSS may block, such as due to needing to access slow | 58 // Because calls to NSS may block, such as due to needing to access slow |
| 59 // hardware or needing to synchronously unlock protected tokens, calls to | 59 // hardware or needing to synchronously unlock protected tokens, calls to |
| 60 // NSS may optionally be run on a dedicated thread. If synchronous/blocking | 60 // NSS may optionally be run on a dedicated thread. If synchronous/blocking |
| 61 // behaviour is desired, for performance or compatibility, the current task | 61 // behaviour is desired, for performance or compatibility, the current task |
| 62 // runner should be supplied instead. | 62 // runner should be supplied instead. |
| 63 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner, | 63 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner, |
| 64 scoped_ptr<ClientSocketHandle> transport_socket, | 64 scoped_ptr<ClientSocketHandle> transport_socket, |
| 65 const HostPortPair& host_and_port, | 65 const HostPortPair& host_and_port, |
| 66 const SSLConfig& ssl_config, | 66 const SSLConfig& ssl_config, |
| 67 const SSLClientSocketContext& context); | 67 const SSLClientSocketContext& context); |
| 68 virtual ~SSLClientSocketNSS(); | 68 ~SSLClientSocketNSS() override; |
| 69 | 69 |
| 70 // SSLClientSocket implementation. | 70 // SSLClientSocket implementation. |
| 71 virtual std::string GetSessionCacheKey() const override; | 71 std::string GetSessionCacheKey() const override; |
| 72 virtual bool InSessionCache() const override; | 72 bool InSessionCache() const override; |
| 73 virtual void SetHandshakeCompletionCallback( | 73 void SetHandshakeCompletionCallback(const base::Closure& callback) override; |
| 74 const base::Closure& callback) override; | 74 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
| 75 virtual void GetSSLCertRequestInfo( | 75 NextProtoStatus GetNextProto(std::string* proto) override; |
| 76 SSLCertRequestInfo* cert_request_info) override; | |
| 77 virtual NextProtoStatus GetNextProto(std::string* proto) override; | |
| 78 | 76 |
| 79 // SSLSocket implementation. | 77 // SSLSocket implementation. |
| 80 virtual int ExportKeyingMaterial(const base::StringPiece& label, | 78 int ExportKeyingMaterial(const base::StringPiece& label, |
| 81 bool has_context, | 79 bool has_context, |
| 82 const base::StringPiece& context, | 80 const base::StringPiece& context, |
| 83 unsigned char* out, | 81 unsigned char* out, |
| 84 unsigned int outlen) override; | 82 unsigned int outlen) override; |
| 85 virtual int GetTLSUniqueChannelBinding(std::string* out) override; | 83 int GetTLSUniqueChannelBinding(std::string* out) override; |
| 86 | 84 |
| 87 // StreamSocket implementation. | 85 // StreamSocket implementation. |
| 88 virtual int Connect(const CompletionCallback& callback) override; | 86 int Connect(const CompletionCallback& callback) override; |
| 89 virtual void Disconnect() override; | 87 void Disconnect() override; |
| 90 virtual bool IsConnected() const override; | 88 bool IsConnected() const override; |
| 91 virtual bool IsConnectedAndIdle() const override; | 89 bool IsConnectedAndIdle() const override; |
| 92 virtual int GetPeerAddress(IPEndPoint* address) const override; | 90 int GetPeerAddress(IPEndPoint* address) const override; |
| 93 virtual int GetLocalAddress(IPEndPoint* address) const override; | 91 int GetLocalAddress(IPEndPoint* address) const override; |
| 94 virtual const BoundNetLog& NetLog() const override; | 92 const BoundNetLog& NetLog() const override; |
| 95 virtual void SetSubresourceSpeculation() override; | 93 void SetSubresourceSpeculation() override; |
| 96 virtual void SetOmniboxSpeculation() override; | 94 void SetOmniboxSpeculation() override; |
| 97 virtual bool WasEverUsed() const override; | 95 bool WasEverUsed() const override; |
| 98 virtual bool UsingTCPFastOpen() const override; | 96 bool UsingTCPFastOpen() const override; |
| 99 virtual bool GetSSLInfo(SSLInfo* ssl_info) override; | 97 bool GetSSLInfo(SSLInfo* ssl_info) override; |
| 100 | 98 |
| 101 // Socket implementation. | 99 // Socket implementation. |
| 102 virtual int Read(IOBuffer* buf, | 100 int Read(IOBuffer* buf, |
| 103 int buf_len, | 101 int buf_len, |
| 104 const CompletionCallback& callback) override; | 102 const CompletionCallback& callback) override; |
| 105 virtual int Write(IOBuffer* buf, | 103 int Write(IOBuffer* buf, |
| 106 int buf_len, | 104 int buf_len, |
| 107 const CompletionCallback& callback) override; | 105 const CompletionCallback& callback) override; |
| 108 virtual int SetReceiveBufferSize(int32 size) override; | 106 int SetReceiveBufferSize(int32 size) override; |
| 109 virtual int SetSendBufferSize(int32 size) override; | 107 int SetSendBufferSize(int32 size) override; |
| 110 virtual ChannelIDService* GetChannelIDService() const override; | 108 ChannelIDService* GetChannelIDService() const override; |
| 111 | 109 |
| 112 protected: | 110 protected: |
| 113 // SSLClientSocket implementation. | 111 // SSLClientSocket implementation. |
| 114 virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() | 112 scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() |
| 115 const override; | 113 const override; |
| 116 | 114 |
| 117 private: | 115 private: |
| 118 // Helper class to handle marshalling any NSS interaction to and from the | 116 // Helper class to handle marshalling any NSS interaction to and from the |
| 119 // NSS and network task runners. Not every call needs to happen on the Core | 117 // NSS and network task runners. Not every call needs to happen on the Core |
| 120 class Core; | 118 class Core; |
| 121 | 119 |
| 122 enum State { | 120 enum State { |
| 123 STATE_NONE, | 121 STATE_NONE, |
| 124 STATE_HANDSHAKE, | 122 STATE_HANDSHAKE, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Added the following code Debugging in release mode. | 212 // Added the following code Debugging in release mode. |
| 215 mutable base::Lock lock_; | 213 mutable base::Lock lock_; |
| 216 // This is mutable so that CalledOnValidThread can set it. | 214 // This is mutable so that CalledOnValidThread can set it. |
| 217 // It's guarded by |lock_|. | 215 // It's guarded by |lock_|. |
| 218 mutable base::PlatformThreadId valid_thread_id_; | 216 mutable base::PlatformThreadId valid_thread_id_; |
| 219 }; | 217 }; |
| 220 | 218 |
| 221 } // namespace net | 219 } // namespace net |
| 222 | 220 |
| 223 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 221 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |