Chromium Code Reviews| Index: remoting/host/security_key/security_key_socket.cc |
| diff --git a/remoting/host/security_key/security_key_socket.cc b/remoting/host/security_key/security_key_socket.cc |
| index 88239ad4008d4bdd0d812dab8c0cd9eb4a70d6b6..70543db7751e2cd82f1e6e1e65ef37cd9cedcf67 100644 |
| --- a/remoting/host/security_key/security_key_socket.cc |
| +++ b/remoting/host/security_key/security_key_socket.cc |
| @@ -30,7 +30,6 @@ SecurityKeySocket::SecurityKeySocket(std::unique_ptr<net::StreamSocket> socket, |
| base::TimeDelta timeout, |
| const base::Closure& timeout_callback) |
| : socket_(std::move(socket)), |
| - read_completed_(false), |
| read_buffer_(new net::IOBufferWithSize(kRequestReadBufferLength)) { |
| timer_.reset(new base::Timer(false, false)); |
| timer_->Start(FROM_HERE, timeout, timeout_callback); |
| @@ -40,11 +39,8 @@ SecurityKeySocket::~SecurityKeySocket() {} |
| bool SecurityKeySocket::GetAndClearRequestData(std::string* data_out) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - DCHECK(read_completed_); |
| + DCHECK(!waiting_for_request_); |
| - if (!read_completed_) { |
| - return false; |
| - } |
| if (!IsRequestComplete() || IsRequestTooLarge()) { |
| return false; |
| } |
| @@ -81,7 +77,9 @@ void SecurityKeySocket::StartReadingRequest( |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK(request_received_callback_.is_null()); |
| + waiting_for_request_ = true; |
| request_received_callback_ = request_received_callback; |
| + |
| DoRead(); |
|
Sergey Ulanov
2016/12/19 23:19:18
Do we need to check if there a complete request in
joedow
2016/12/20 00:28:00
Right now we drain everything from the buffer (lin
|
| } |
| @@ -122,8 +120,9 @@ void SecurityKeySocket::OnDataRead(int result) { |
| if (result <= 0) { |
| if (result < 0) { |
| LOG(ERROR) << "Error reading request: " << result; |
| + socket_read_error_ = true; |
| } |
| - read_completed_ = true; |
| + waiting_for_request_ = false; |
| base::ResetAndReturn(&request_received_callback_).Run(); |
| return; |
| } |
| @@ -132,7 +131,7 @@ void SecurityKeySocket::OnDataRead(int result) { |
| request_data_.insert(request_data_.end(), read_buffer_->data(), |
| read_buffer_->data() + result); |
| if (IsRequestComplete()) { |
| - read_completed_ = true; |
| + waiting_for_request_ = false; |
| base::ResetAndReturn(&request_received_callback_).Run(); |
| return; |
| } |