| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 void SendResponse(const std::string& data); | 47 void SendResponse(const std::string& data); |
| 48 | 48 |
| 49 // Sends an SSH error code to the socket. | 49 // Sends an SSH error code to the socket. |
| 50 void SendSshError(); | 50 void SendSshError(); |
| 51 | 51 |
| 52 // |request_received_callback| is used to notify the caller that request data | 52 // |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 | 53 // has been fully read, and caller is to use GetAndClearRequestData method to |
| 54 // get the request data. | 54 // get the request data. |
| 55 void StartReadingRequest(const base::Closure& request_received_callback); | 55 void StartReadingRequest(const base::Closure& request_received_callback); |
| 56 | 56 |
| 57 bool socket_read_error() const { return socket_read_error_; } |
| 58 |
| 57 private: | 59 private: |
| 58 // Called when bytes are written to |socket_|. | 60 // Called when bytes are written to |socket_|. |
| 59 void OnDataWritten(int result); | 61 void OnDataWritten(int result); |
| 60 | 62 |
| 61 // Continues writing to |socket_| if needed. | 63 // Continues writing to |socket_| if needed. |
| 62 void DoWrite(); | 64 void DoWrite(); |
| 63 | 65 |
| 64 // Called when bytes are read from |socket_|. | 66 // Called when bytes are read from |socket_|. |
| 65 void OnDataRead(int bytes_read); | 67 void OnDataRead(int bytes_read); |
| 66 | 68 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 84 | 86 |
| 85 // Ensures SecurityKeySocketSocket methods are called on the same thread. | 87 // Ensures SecurityKeySocketSocket methods are called on the same thread. |
| 86 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
| 87 | 89 |
| 88 // The socket. | 90 // The socket. |
| 89 std::unique_ptr<net::StreamSocket> socket_; | 91 std::unique_ptr<net::StreamSocket> socket_; |
| 90 | 92 |
| 91 // Invoked when request data has been read. | 93 // Invoked when request data has been read. |
| 92 base::Closure request_received_callback_; | 94 base::Closure request_received_callback_; |
| 93 | 95 |
| 94 // Indicates whether read has completed and |request_received_callback_| is | 96 // Indicates whether the socket is being used to wait for a request. |
| 95 // about to be run. | 97 bool waiting_for_request_ = false; |
| 96 bool read_completed_; | 98 |
| 99 // Indicates whether an error was encountered while reading from the socket. |
| 100 bool socket_read_error_ = false; |
| 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 |