| 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 #include "remoting/host/security_key/security_key_socket.h" | 5 #include "remoting/host/security_key/security_key_socket.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 SecurityKeySocket::SecurityKeySocket(std::unique_ptr<net::StreamSocket> socket, | 29 SecurityKeySocket::SecurityKeySocket(std::unique_ptr<net::StreamSocket> socket, |
| 30 base::TimeDelta timeout, | 30 base::TimeDelta timeout, |
| 31 const base::Closure& timeout_callback) | 31 const base::Closure& timeout_callback) |
| 32 : socket_(std::move(socket)), | 32 : socket_(std::move(socket)), |
| 33 read_buffer_(new net::IOBufferWithSize(kRequestReadBufferLength)) { | 33 read_buffer_(new net::IOBufferWithSize(kRequestReadBufferLength)) { |
| 34 timer_.reset(new base::Timer(false, false)); | 34 timer_.reset(new base::Timer(false, false)); |
| 35 timer_->Start(FROM_HERE, timeout, timeout_callback); | 35 timer_->Start(FROM_HERE, timeout, timeout_callback); |
| 36 } | 36 } |
| 37 | 37 |
| 38 SecurityKeySocket::~SecurityKeySocket() {} | 38 SecurityKeySocket::~SecurityKeySocket() { |
| 39 DCHECK(thread_checker_.CalledOnValidThread()); |
| 40 } |
| 39 | 41 |
| 40 bool SecurityKeySocket::GetAndClearRequestData(std::string* data_out) { | 42 bool SecurityKeySocket::GetAndClearRequestData(std::string* data_out) { |
| 41 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 42 DCHECK(!waiting_for_request_); | 44 DCHECK(!waiting_for_request_); |
| 43 | 45 |
| 44 if (!IsRequestComplete() || IsRequestTooLarge()) { | 46 if (!IsRequestComplete() || IsRequestTooLarge()) { |
| 45 return false; | 47 return false; |
| 46 } | 48 } |
| 47 // The request size is not part of the data; don't send it. | 49 // The request size is not part of the data; don't send it. |
| 48 data_out->assign(request_data_.begin() + kRequestSizeBytes, | 50 data_out->assign(request_data_.begin() + kRequestSizeBytes, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return response_len; | 196 return response_len; |
| 195 } | 197 } |
| 196 | 198 |
| 197 void SecurityKeySocket::ResetTimer() { | 199 void SecurityKeySocket::ResetTimer() { |
| 198 if (timer_->IsRunning()) { | 200 if (timer_->IsRunning()) { |
| 199 timer_->Reset(); | 201 timer_->Reset(); |
| 200 } | 202 } |
| 201 } | 203 } |
| 202 | 204 |
| 203 } // namespace remoting | 205 } // namespace remoting |
| OLD | NEW |