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

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

Issue 76403004: An implementation of chrome.socket.secure(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing another cross-platform build issue (try 2) Created 7 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_
7
8 #include <string>
9
10 #include "chrome/browser/extensions/api/socket/socket.h"
11
12 namespace net {
13 class Socket;
14 }
15
16 namespace extensions {
17
18 // TLS Sockets from the chrome.socket API. A regular TCPSocket is converted
19 // to a TLSSocket via chrome.socket.secure().
20 class TLSSocket : public Socket {
21 public:
22 TLSSocket(net::StreamSocket* tls_socket,
23 net::TCPClientSocket* underlying_tcp_socket,
24 const std::string& owner_extension_id);
25
26 virtual ~TLSSocket();
27
28 // Most of these methods either fail or forward the method call on to the
29 // inner net::StreamSocket. The remaining few do actual TLS work.
Ryan Sleevi 2013/11/25 17:30:13 This definitely violates the SOLID design of is-a
Lally Singh 2013/12/05 17:07:12 No disagreement here, but this is an artifact of s
30
31 // Fails.
32 virtual void Connect(const std::string& address,
33 int port,
34 const CompletionCallback& callback) OVERRIDE;
35 // Forwards.
36 virtual void Disconnect() OVERRIDE;
37
38 // Fails.
39 virtual int Bind(const std::string& address, int port) OVERRIDE;
40
41 // The |callback| will be called with the number of bytes read into the
42 // buffer, or a negative number if an error occurred. Does TLS work.
43 virtual void Read(int count,
44 const ReadCompletionCallback& callback) OVERRIDE;
45
46 // Fails.
47 virtual void RecvFrom(int count,
48 const RecvFromCompletionCallback& callback) OVERRIDE;
49 // Fails.
50 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
51 int byte_count,
52 const std::string& address,
53 int port,
54 const CompletionCallback& callback) OVERRIDE;
55
56 // Forwards.
57 virtual bool SetKeepAlive(bool enable, int delay) OVERRIDE;
58
59 // Forwards.
60 virtual bool SetNoDelay(bool no_delay) OVERRIDE;
61
62 // Fails.
63 virtual int Listen(const std::string& address, int port, int backlog,
64 std::string* error_msg) OVERRIDE;
65 // Fails.
66 virtual void Accept(const AcceptCompletionCallback &callback) OVERRIDE;
67
68 // Forwards.
69 virtual bool IsConnected() OVERRIDE;
70
71 // Forwards.
72 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE;
73 // Forwards.
74 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE;
75
76 // Forwards.
77 virtual SocketType GetSocketType() const OVERRIDE;
78
79 private:
80 virtual int WriteImpl(net::IOBuffer* io_buffer, int io_buffer_size,
81 const net::CompletionCallback& callback) OVERRIDE;
82 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
83 int result);
84
85 scoped_ptr<net::StreamSocket> tls_socket_;
86 scoped_ptr<net::TCPClientSocket> underlying_socket_;
87
88 ReadCompletionCallback read_callback_;
89 };
90
91 } // namespace extensions
92
93 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TLS_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698