Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: extensions/browser/api/socket/tls_socket.h

Issue 494573002: A change for the setPause() api in chrome.sockets.tcp: Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cosmetics and commentary. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 EXTENSIONS_BROWSER_API_SOCKET_TLS_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ 6 #define EXTENSIONS_BROWSER_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"
11 #include "extensions/browser/api/socket/socket_api.h" 11 #include "extensions/browser/api/socket/socket_api.h"
12 #include "extensions/browser/api/socket/tcp_socket.h" 12 #include "extensions/browser/api/socket/tcp_socket.h"
13 #include "net/ssl/ssl_config_service.h" 13 #include "net/ssl/ssl_config_service.h"
14 14
15 namespace net { 15 namespace net {
16 class Socket; 16 class Socket;
17 class CertVerifier; 17 class CertVerifier;
18 class TransportSecurityState; 18 class TransportSecurityState;
19 } 19 }
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 class TLSSocket;
24
25 // TLS Sockets from the chrome.socket and chrome.sockets.tcp APIs. A regular 23 // TLS Sockets from the chrome.socket and chrome.sockets.tcp APIs. A regular
26 // TCPSocket is converted to a TLSSocket via chrome.socket.secure() or 24 // TCPSocket is converted to a TLSSocket via chrome.socket.secure() or
27 // chrome.sockets.tcp.secure(). The inheritance here is for interface API 25 // chrome.sockets.tcp.secure(). The inheritance here is for interface API
28 // compatibility, not for the implementation that comes with it. TLSSocket 26 // compatibility, not for the implementation that comes with it. TLSSocket
29 // does not use its superclass's socket state, so all methods are overridden 27 // does not use its superclass's socket state, so all methods are overridden
30 // here to prevent any access of ResumableTCPSocket's socket state. Except 28 // here to prevent any access of ResumableTCPSocket's socket state. Except
31 // for the implementation of a write queue in Socket::Write() (a super-super 29 // for the implementation of a write queue in Socket::Write() (a super-super
32 // class of ResumableTCPSocket). That implementation only queues and 30 // class of ResumableTCPSocket). That implementation only queues and
33 // serializes invocations to WriteImpl(), implemented here, and does not 31 // serializes invocations to WriteImpl(), implemented here, and does not
34 // touch any socket state. 32 // touch any socket state.
35 class TLSSocket : public ResumableTCPSocket { 33 class TLSSocket : public ResumableTCPSocket {
36 public: 34 public:
37 typedef base::Callback<void(scoped_ptr<TLSSocket>, int)> SecureCallback; 35 typedef base::Callback<void(scoped_ptr<TLSSocket>, int)> SecureCallback;
38 36
39 TLSSocket(scoped_ptr<net::StreamSocket> tls_socket, 37 TLSSocket(scoped_ptr<BufferingStreamSocket> tls_socket,
40 const std::string& owner_extension_id); 38 const std::string& owner_extension_id);
41 39
42 ~TLSSocket() override; 40 ~TLSSocket() override;
43 41
44 // Most of these methods either fail or forward the method call on to the 42 // 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. 43 // inner net::StreamSocket. The remaining few do actual TLS work.
46 44
47 // Fails. 45 // Fails.
48 void Connect(const net::AddressList& address, 46 void Connect(const net::AddressList& address,
49 const CompletionCallback& callback) override; 47 const CompletionCallback& callback) override;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const SecureCallback& callback); 99 const SecureCallback& callback);
102 100
103 private: 101 private:
104 int WriteImpl(net::IOBuffer* io_buffer, 102 int WriteImpl(net::IOBuffer* io_buffer,
105 int io_buffer_size, 103 int io_buffer_size,
106 const net::CompletionCallback& callback) override; 104 const net::CompletionCallback& callback) override;
107 105
108 void OnReadComplete(const scoped_refptr<net::IOBuffer>& io_buffer, 106 void OnReadComplete(const scoped_refptr<net::IOBuffer>& io_buffer,
109 int result); 107 int result);
110 108
111 scoped_ptr<net::StreamSocket> tls_socket_; 109 scoped_ptr<BufferingStreamSocket> tls_socket_;
112 ReadCompletionCallback read_callback_; 110 ReadCompletionCallback read_callback_;
113 }; 111 };
114 112
115 } // namespace extensions 113 } // namespace extensions
116 114
117 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_ 115 #endif // EXTENSIONS_BROWSER_API_SOCKET_TLS_SOCKET_H_
118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698