OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ |
6 #define REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ | 6 #define REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // TODO(sergeyu): Write unittests for this code! | 26 // TODO(sergeyu): Write unittests for this code! |
27 | 27 |
28 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that | 28 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that |
29 // implements Chromium's net::StreamSocket interface. It's used by | 29 // implements Chromium's net::StreamSocket interface. It's used by |
30 // SSLSocketAdapter to enable Chromium's SSL implementation to work over | 30 // SSLSocketAdapter to enable Chromium's SSL implementation to work over |
31 // libjingle's socket class. | 31 // libjingle's socket class. |
32 class TransportSocket : public net::StreamSocket, public sigslot::has_slots<> { | 32 class TransportSocket : public net::StreamSocket, public sigslot::has_slots<> { |
33 public: | 33 public: |
34 TransportSocket(talk_base::AsyncSocket* socket, | 34 TransportSocket(talk_base::AsyncSocket* socket, |
35 SSLSocketAdapter *ssl_adapter); | 35 SSLSocketAdapter *ssl_adapter); |
36 ~TransportSocket(); | 36 virtual ~TransportSocket(); |
37 | 37 |
38 void set_addr(const talk_base::SocketAddress& addr) { | 38 void set_addr(const talk_base::SocketAddress& addr) { |
39 addr_ = addr; | 39 addr_ = addr; |
40 } | 40 } |
41 | 41 |
42 // net::StreamSocket implementation | 42 // net::StreamSocket implementation |
43 | 43 |
44 virtual int Connect(net::CompletionCallback* callback); | 44 virtual int Connect(net::CompletionCallback* callback); |
45 virtual void Disconnect(); | 45 virtual void Disconnect(); |
46 virtual bool IsConnected() const; | 46 virtual bool IsConnected() const; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(TransportSocket); | 86 DISALLOW_COPY_AND_ASSIGN(TransportSocket); |
87 }; | 87 }; |
88 | 88 |
89 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's | 89 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's |
90 // net::SSLClientSocket class. This allows remoting to use Chromium's SSL | 90 // net::SSLClientSocket class. This allows remoting to use Chromium's SSL |
91 // implementation instead of OpenSSL. | 91 // implementation instead of OpenSSL. |
92 class SSLSocketAdapter : public talk_base::SSLAdapter { | 92 class SSLSocketAdapter : public talk_base::SSLAdapter { |
93 public: | 93 public: |
94 explicit SSLSocketAdapter(talk_base::AsyncSocket* socket); | 94 explicit SSLSocketAdapter(talk_base::AsyncSocket* socket); |
95 ~SSLSocketAdapter(); | 95 virtual ~SSLSocketAdapter(); |
96 | 96 |
97 // StartSSL returns 0 if successful, or non-zero on failure. | 97 // StartSSL returns 0 if successful, or non-zero on failure. |
98 // If StartSSL is called while the socket is closed or connecting, the SSL | 98 // If StartSSL is called while the socket is closed or connecting, the SSL |
99 // negotiation will begin as soon as the socket connects. | 99 // negotiation will begin as soon as the socket connects. |
100 // | 100 // |
101 // restartable is not implemented, and must be set to false. | 101 // restartable is not implemented, and must be set to false. |
102 virtual int StartSSL(const char* hostname, bool restartable); | 102 virtual int StartSSL(const char* hostname, bool restartable); |
103 | 103 |
104 // Create the default SSL adapter for this platform. | 104 // Create the default SSL adapter for this platform. |
105 static SSLSocketAdapter* Create(AsyncSocket* socket); | 105 static SSLSocketAdapter* Create(AsyncSocket* socket); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 IOState write_state_; | 143 IOState write_state_; |
144 scoped_refptr<net::IOBuffer> transport_buf_; | 144 scoped_refptr<net::IOBuffer> transport_buf_; |
145 int data_transferred_; | 145 int data_transferred_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); | 147 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace remoting | 150 } // namespace remoting |
151 | 151 |
152 #endif // REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ | 152 #endif // REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ |
OLD | NEW |