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

Unified Diff: chrome/browser/extensions/api/socket/ssl_socket.h

Issue 10580028: Experimental support for SSL in platform apps sockets. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 8 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/socket/ssl_socket.h
diff --git a/chrome/browser/extensions/api/socket/tcp_socket.h b/chrome/browser/extensions/api/socket/ssl_socket.h
similarity index 58%
copy from chrome/browser/extensions/api/socket/tcp_socket.h
copy to chrome/browser/extensions/api/socket/ssl_socket.h
index a536dbe5b8547c1647df6334289c42986c093010..540d488f82285f20cc2862a3d690df768b74dc91 100644
--- a/chrome/browser/extensions/api/socket/tcp_socket.h
+++ b/chrome/browser/extensions/api/socket/ssl_socket.h
@@ -2,34 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
-#define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
+#ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SSL_SOCKET_H_
+#define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SSL_SOCKET_H_
#pragma once
#include <string>
+#include "chrome/browser/extensions/api/api_resource_event_notifier.h"
#include "chrome/browser/extensions/api/socket/socket.h"
-// This looks like it should be forward-declarable, but it does some tricky
-// moves that make it easier to just include it.
+#include "net/socket/ssl_client_socket.h"
#include "net/socket/tcp_client_socket.h"
-namespace net {
-class Socket;
-}
-
namespace extensions {
-class APIResourceEventNotifier;
-
-class TCPSocket : public Socket {
+class SSLSocket : public Socket {
public:
- explicit TCPSocket(APIResourceEventNotifier* event_notifier);
- virtual ~TCPSocket();
+ explicit SSLSocket(extensions::APIResourceEventNotifier* event_notifier);
+ virtual ~SSLSocket();
virtual void Connect(const std::string& address,
int port,
const CompletionCallback& callback) OVERRIDE;
+ virtual void PerformSSLHandshake(
+ const std::string& ssl_hostname,
+ int ssl_port,
+ const CompletionCallback& callback) OVERRIDE;
virtual void Disconnect() OVERRIDE;
virtual int Bind(const std::string& address, int port) OVERRIDE;
virtual void Read(int count,
@@ -44,7 +42,7 @@ class TCPSocket : public Socket {
virtual bool SetKeepAlive(bool enable, int delay) OVERRIDE;
virtual bool SetNoDelay(bool no_delay) OVERRIDE;
- static TCPSocket* CreateSocketForTesting(
+ static SSLSocket* CreateSocketForTesting(
net::TCPClientSocket* tcp_client_socket,
APIResourceEventNotifier* event_notifier);
@@ -53,21 +51,43 @@ class TCPSocket : public Socket {
int io_buffer_size,
const net::CompletionCallback& callback) OVERRIDE;
+ virtual void OnWriteComplete(int result) OVERRIDE;
+
private:
+ enum SSLState {
+ SSLSTATE_NONE,
+ SSLSTATE_WAIT,
+ SSLSTATE_CONNECTED,
+ SSLSTATE_ERROR
+ };
+
void OnConnectComplete(int result);
+ void OnHandshakeComplete(int result);
void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
int result);
- TCPSocket(net::TCPClientSocket* tcp_client_socket,
+ void AttemptSSLHandshake();
+
+ SSLSocket(net::TCPClientSocket* tcp_client_socket,
APIResourceEventNotifier* event_notifier);
+ // See remoting/jingle_glue/ssl_socket_adapter.h:
+ // |cert_verifier_| must be defined before |ssl_socket_| so that it's
+ // destroyed after |ssl_socket_|.
+ scoped_ptr<net::CertVerifier> cert_verifier_;
Ryan Sleevi 2012/07/09 20:55:45 drive-by: The CertVerifier should be passed in as
+ scoped_ptr<net::SSLClientSocket> ssl_socket_;
scoped_ptr<net::TCPClientSocket> socket_;
+ SSLState ssl_state_;
+ int ssl_port_;
+ std::string ssl_hostname_;
+
CompletionCallback connect_callback_;
+ CompletionCallback handshake_callback_;
ReadCompletionCallback read_callback_;
};
} // namespace extensions
-#endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
+#endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SSL_SOCKET_H_

Powered by Google App Engine
This is Rietveld 408576698