OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "extensions/browser/api/socket/socket.h" | 10 #include "extensions/browser/api/socket/socket.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 const std::string& owner_extension_id); | 40 const std::string& owner_extension_id); |
41 | 41 |
42 virtual ~TLSSocket(); | 42 virtual ~TLSSocket(); |
43 | 43 |
44 // Most of these methods either fail or forward the method call on to the | 44 // Most of these methods either fail or forward the method call on to the |
45 // inner net::StreamSocket. The remaining few do actual TLS work. | 45 // inner net::StreamSocket. The remaining few do actual TLS work. |
46 | 46 |
47 // Fails. | 47 // Fails. |
48 virtual void Connect(const std::string& address, | 48 virtual void Connect(const std::string& address, |
49 int port, | 49 int port, |
50 const CompletionCallback& callback) OVERRIDE; | 50 const CompletionCallback& callback) override; |
51 // Forwards. | 51 // Forwards. |
52 virtual void Disconnect() OVERRIDE; | 52 virtual void Disconnect() override; |
53 | 53 |
54 // Attempts to read |count| bytes of decrypted data from the TLS socket, | 54 // Attempts to read |count| bytes of decrypted data from the TLS socket, |
55 // invoking |callback| with the actual number of bytes read, or a network | 55 // invoking |callback| with the actual number of bytes read, or a network |
56 // error code if an error occurred. | 56 // error code if an error occurred. |
57 virtual void Read(int count, const ReadCompletionCallback& callback) OVERRIDE; | 57 virtual void Read(int count, const ReadCompletionCallback& callback) override; |
58 | 58 |
59 // Fails. This should have been called on the TCP socket before secure() was | 59 // Fails. This should have been called on the TCP socket before secure() was |
60 // invoked. | 60 // invoked. |
61 virtual bool SetKeepAlive(bool enable, int delay) OVERRIDE; | 61 virtual bool SetKeepAlive(bool enable, int delay) override; |
62 | 62 |
63 // Fails. This should have been called on the TCP socket before secure() was | 63 // Fails. This should have been called on the TCP socket before secure() was |
64 // invoked. | 64 // invoked. |
65 virtual bool SetNoDelay(bool no_delay) OVERRIDE; | 65 virtual bool SetNoDelay(bool no_delay) override; |
66 | 66 |
67 // Fails. TLSSocket is only a client. | 67 // Fails. TLSSocket is only a client. |
68 virtual int Listen(const std::string& address, | 68 virtual int Listen(const std::string& address, |
69 int port, | 69 int port, |
70 int backlog, | 70 int backlog, |
71 std::string* error_msg) OVERRIDE; | 71 std::string* error_msg) override; |
72 | 72 |
73 // Fails. TLSSocket is only a client. | 73 // Fails. TLSSocket is only a client. |
74 virtual void Accept(const AcceptCompletionCallback& callback) OVERRIDE; | 74 virtual void Accept(const AcceptCompletionCallback& callback) override; |
75 | 75 |
76 // Forwards. | 76 // Forwards. |
77 virtual bool IsConnected() OVERRIDE; | 77 virtual bool IsConnected() override; |
78 | 78 |
79 // Forwards. | 79 // Forwards. |
80 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE; | 80 virtual bool GetPeerAddress(net::IPEndPoint* address) override; |
81 // Forwards. | 81 // Forwards. |
82 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE; | 82 virtual bool GetLocalAddress(net::IPEndPoint* address) override; |
83 | 83 |
84 // Returns TYPE_TLS. | 84 // Returns TYPE_TLS. |
85 virtual SocketType GetSocketType() const OVERRIDE; | 85 virtual SocketType GetSocketType() const override; |
86 | 86 |
87 // Convert |socket| to a TLS socket. |socket| must be an open TCP client | 87 // Convert |socket| to a TLS socket. |socket| must be an open TCP client |
88 // socket. |socket| must not have a pending read. UpgradeSocketToTLS() must | 88 // socket. |socket| must not have a pending read. UpgradeSocketToTLS() must |
89 // be invoked in the IO thread. |callback| will always be invoked. |options| | 89 // be invoked in the IO thread. |callback| will always be invoked. |options| |
90 // may be NULL. | 90 // may be NULL. |
91 // Note: |callback| may be synchronously invoked before | 91 // Note: |callback| may be synchronously invoked before |
92 // UpgradeSocketToTLS() returns. Currently using the older chrome.socket | 92 // UpgradeSocketToTLS() returns. Currently using the older chrome.socket |
93 // version of SecureOptions, to avoid having the older API implementation | 93 // version of SecureOptions, to avoid having the older API implementation |
94 // depend on the newer one. | 94 // depend on the newer one. |
95 static void UpgradeSocketToTLS( | 95 static void UpgradeSocketToTLS( |
96 Socket* socket, | 96 Socket* socket, |
97 scoped_refptr<net::SSLConfigService> config_service, | 97 scoped_refptr<net::SSLConfigService> config_service, |
98 net::CertVerifier* cert_verifier, | 98 net::CertVerifier* cert_verifier, |
99 net::TransportSecurityState* transport_security_state, | 99 net::TransportSecurityState* transport_security_state, |
100 const std::string& extension_id, | 100 const std::string& extension_id, |
101 core_api::socket::SecureOptions* options, | 101 core_api::socket::SecureOptions* options, |
102 const SecureCallback& callback); | 102 const SecureCallback& callback); |
103 | 103 |
104 private: | 104 private: |
105 virtual int WriteImpl(net::IOBuffer* io_buffer, | 105 virtual int WriteImpl(net::IOBuffer* io_buffer, |
106 int io_buffer_size, | 106 int io_buffer_size, |
107 const net::CompletionCallback& callback) OVERRIDE; | 107 const net::CompletionCallback& callback) override; |
108 | 108 |
109 void OnReadComplete(const scoped_refptr<net::IOBuffer>& io_buffer, | 109 void OnReadComplete(const scoped_refptr<net::IOBuffer>& io_buffer, |
110 int result); | 110 int result); |
111 | 111 |
112 scoped_ptr<net::StreamSocket> tls_socket_; | 112 scoped_ptr<net::StreamSocket> tls_socket_; |
113 ReadCompletionCallback read_callback_; | 113 ReadCompletionCallback read_callback_; |
114 }; | 114 }; |
115 | 115 |
116 } // namespace extensions | 116 } // namespace extensions |
117 | 117 |
118 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ | 118 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ |
119 | 119 |
OLD | NEW |