| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ |
| 6 #define REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ | 6 #define JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/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" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" |
| 13 #include "net/socket/client_socket.h" | 13 #include "net/socket/client_socket.h" |
| 14 #include "net/socket/ssl_client_socket.h" | 14 #include "net/socket/ssl_client_socket.h" |
| 15 #include "talk/base/asyncsocket.h" | 15 #include "talk/base/asyncsocket.h" |
| 16 #include "talk/base/ssladapter.h" | 16 #include "talk/base/ssladapter.h" |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace notifier { |
| 19 | 19 |
| 20 class SSLSocketAdapter; | 20 class SSLSocketAdapter; |
| 21 | 21 |
| 22 // TODO(sergeyu): Write unittests for this code! | 22 // TODO(sergeyu): Write unittests for this code! |
| 23 | 23 |
| 24 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that | 24 // This class provides a wrapper to libjingle's talk_base::AsyncSocket that |
| 25 // implements Chromium's net::ClientSocket interface. It's used by | 25 // implements Chromium's net::ClientSocket interface. It's used by |
| 26 // SSLSocketAdapter to enable Chromium's SSL implementation to work over | 26 // SSLSocketAdapter to enable Chromium's SSL implementation to work over |
| 27 // libjingle's socket class. | 27 // libjingle's socket class. |
| 28 class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> { | 28 class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 talk_base::AsyncSocket *socket_; | 75 talk_base::AsyncSocket *socket_; |
| 76 talk_base::SocketAddress addr_; | 76 talk_base::SocketAddress addr_; |
| 77 | 77 |
| 78 bool was_used_to_convey_data_; | 78 bool was_used_to_convey_data_; |
| 79 | 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(TransportSocket); | 80 DISALLOW_COPY_AND_ASSIGN(TransportSocket); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's | 83 // This provides a talk_base::AsyncSocketAdapter interface around Chromium's |
| 84 // net::SSLClientSocket class. This allows remoting to use Chromium's SSL | 84 // net::SSLClientSocket class. This allows notifier to use Chromium's SSL |
| 85 // implementation instead of OpenSSL. | 85 // implementation instead of OpenSSL. |
| 86 class SSLSocketAdapter : public talk_base::SSLAdapter { | 86 class SSLSocketAdapter : public talk_base::SSLAdapter { |
| 87 public: | 87 public: |
| 88 explicit SSLSocketAdapter(talk_base::AsyncSocket* socket); | 88 explicit SSLSocketAdapter(talk_base::AsyncSocket* socket); |
| 89 ~SSLSocketAdapter(); | 89 ~SSLSocketAdapter(); |
| 90 | 90 |
| 91 // StartSSL returns 0 if successful, or non-zero on failure. | 91 // StartSSL returns 0 if successful, or non-zero on failure. |
| 92 // If StartSSL is called while the socket is closed or connecting, the SSL | 92 // If StartSSL is called while the socket is closed or connecting, the SSL |
| 93 // negotiation will begin as soon as the socket connects. | 93 // negotiation will begin as soon as the socket connects. |
| 94 // | 94 // |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 net::CompletionCallbackImpl<SSLSocketAdapter> write_callback_; | 133 net::CompletionCallbackImpl<SSLSocketAdapter> write_callback_; |
| 134 SSLState ssl_state_; | 134 SSLState ssl_state_; |
| 135 IOState read_state_; | 135 IOState read_state_; |
| 136 IOState write_state_; | 136 IOState write_state_; |
| 137 scoped_refptr<net::IOBuffer> transport_buf_; | 137 scoped_refptr<net::IOBuffer> transport_buf_; |
| 138 int data_transferred_; | 138 int data_transferred_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); | 140 DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 } // namespace remoting | 143 } // namespace notifier |
| 144 | 144 |
| 145 #endif // REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ | 145 #endif // JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ |
| OLD | NEW |