| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 base::TimeDelta timeout, | 37 base::TimeDelta timeout, |
| 38 const base::Closure& timeout_callback); | 38 const base::Closure& timeout_callback); |
| 39 ~SecurityKeySocket(); | 39 ~SecurityKeySocket(); |
| 40 | 40 |
| 41 // Returns false if the request has not yet completed, or is too large to be | 41 // Returns false if the request has not yet completed, or is too large to be |
| 42 // processed. Otherwise, the cached request data is copied into |data_out| and | 42 // processed. Otherwise, the cached request data is copied into |data_out| and |
| 43 // the internal buffer resets and is ready for the next request. | 43 // the internal buffer resets and is ready for the next request. |
| 44 bool GetAndClearRequestData(std::string* data_out); | 44 bool GetAndClearRequestData(std::string* data_out); |
| 45 | 45 |
| 46 // Sends response data to the socket. | 46 // Sends response data to the socket. |
| 47 void SendResponse(const std::string& data); | 47 void SendResponse(const std::string& data, |
| 48 const base::Closure& response_written_callback); |
| 48 | 49 |
| 49 // Sends an SSH error code to the socket. | 50 // Sends an SSH error code to the socket. |
| 50 void SendSshError(); | 51 void SendSshError(const base::Closure& error_sent_callback); |
| 51 | 52 |
| 52 // |request_received_callback| is used to notify the caller that request data | 53 // |request_received_callback| is used to notify the caller that request data |
| 53 // has been fully read, and caller is to use GetAndClearRequestData method to | 54 // has been fully read, and caller is to use GetAndClearRequestData method to |
| 54 // get the request data. | 55 // get the request data. |
| 55 void StartReadingRequest(const base::Closure& request_received_callback); | 56 void StartReadingRequest(const base::Closure& request_received_callback); |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 // Called when bytes are written to |socket_|. | 59 // Called when bytes are written to |socket_|. |
| 59 void OnDataWritten(int result); | 60 void OnDataWritten(int result); |
| 60 | 61 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 | 85 |
| 85 // Ensures SecurityKeySocketSocket methods are called on the same thread. | 86 // Ensures SecurityKeySocketSocket methods are called on the same thread. |
| 86 base::ThreadChecker thread_checker_; | 87 base::ThreadChecker thread_checker_; |
| 87 | 88 |
| 88 // The socket. | 89 // The socket. |
| 89 std::unique_ptr<net::StreamSocket> socket_; | 90 std::unique_ptr<net::StreamSocket> socket_; |
| 90 | 91 |
| 91 // Invoked when request data has been read. | 92 // Invoked when request data has been read. |
| 92 base::Closure request_received_callback_; | 93 base::Closure request_received_callback_; |
| 93 | 94 |
| 95 // Invoked when the response has been written. |
| 96 base::Closure response_written_callback_; |
| 97 |
| 94 // Indicates whether read has completed and |request_received_callback_| is | 98 // Indicates whether read has completed and |request_received_callback_| is |
| 95 // about to be run. | 99 // about to be run. |
| 96 bool read_completed_; | 100 bool read_completed_; |
| 97 | 101 |
| 98 // Request data. | 102 // Request data. |
| 99 std::vector<char> request_data_; | 103 std::vector<char> request_data_; |
| 100 | 104 |
| 101 scoped_refptr<net::DrainableIOBuffer> write_buffer_; | 105 scoped_refptr<net::DrainableIOBuffer> write_buffer_; |
| 102 | 106 |
| 103 scoped_refptr<net::IOBufferWithSize> read_buffer_; | 107 scoped_refptr<net::IOBufferWithSize> read_buffer_; |
| 104 | 108 |
| 105 // The activity timer. | 109 // The activity timer. |
| 106 std::unique_ptr<base::Timer> timer_; | 110 std::unique_ptr<base::Timer> timer_; |
| 107 | 111 |
| 108 DISALLOW_COPY_AND_ASSIGN(SecurityKeySocket); | 112 DISALLOW_COPY_AND_ASSIGN(SecurityKeySocket); |
| 109 }; | 113 }; |
| 110 | 114 |
| 111 } // namespace remoting | 115 } // namespace remoting |
| 112 | 116 |
| 113 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ | 117 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_SOCKET_H_ |
| OLD | NEW |