| 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/remote_security_key_message_handler.h" | 5 #include "remoting/host/security_key/remote_security_key_message_handler.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "remoting/host/security_key/remote_security_key_ipc_client.h" | 14 #include "remoting/host/security_key/remote_security_key_ipc_client.h" |
| 15 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" | 15 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" |
| 16 #include "remoting/host/security_key/remote_security_key_message_reader_impl.h" | 16 #include "remoting/host/security_key/remote_security_key_message_reader_impl.h" |
| 17 #include "remoting/host/security_key/remote_security_key_message_writer_impl.h" | 17 #include "remoting/host/security_key/remote_security_key_message_writer_impl.h" |
| 18 | 18 |
| 19 namespace remoting { | 19 namespace remoting { |
| 20 | 20 |
| 21 RemoteSecurityKeyMessageHandler::RemoteSecurityKeyMessageHandler() {} | 21 RemoteSecurityKeyMessageHandler::RemoteSecurityKeyMessageHandler() {} |
| 22 | 22 |
| 23 RemoteSecurityKeyMessageHandler::~RemoteSecurityKeyMessageHandler() {} | 23 RemoteSecurityKeyMessageHandler::~RemoteSecurityKeyMessageHandler() {} |
| 24 | 24 |
| 25 void RemoteSecurityKeyMessageHandler::Start( | 25 void RemoteSecurityKeyMessageHandler::Start( |
| 26 base::File message_read_stream, | 26 base::File message_read_stream, |
| 27 base::File message_write_stream, | 27 base::File message_write_stream, |
| 28 scoped_ptr<RemoteSecurityKeyIpcClient> ipc_client, | 28 std::unique_ptr<RemoteSecurityKeyIpcClient> ipc_client, |
| 29 const base::Closure& error_callback) { | 29 const base::Closure& error_callback) { |
| 30 DCHECK(thread_checker_.CalledOnValidThread()); | 30 DCHECK(thread_checker_.CalledOnValidThread()); |
| 31 DCHECK(message_read_stream.IsValid()); | 31 DCHECK(message_read_stream.IsValid()); |
| 32 DCHECK(message_write_stream.IsValid()); | 32 DCHECK(message_write_stream.IsValid()); |
| 33 DCHECK(ipc_client); | 33 DCHECK(ipc_client); |
| 34 DCHECK(!error_callback.is_null()); | 34 DCHECK(!error_callback.is_null()); |
| 35 DCHECK(error_callback_.is_null()); | 35 DCHECK(error_callback_.is_null()); |
| 36 | 36 |
| 37 if (!reader_) { | 37 if (!reader_) { |
| 38 reader_.reset( | 38 reader_.reset( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 | 49 |
| 50 reader_->Start( | 50 reader_->Start( |
| 51 base::Bind( | 51 base::Bind( |
| 52 &RemoteSecurityKeyMessageHandler::ProcessRemoteSecurityKeyMessage, | 52 &RemoteSecurityKeyMessageHandler::ProcessRemoteSecurityKeyMessage, |
| 53 base::Unretained(this)), | 53 base::Unretained(this)), |
| 54 base::Bind(&RemoteSecurityKeyMessageHandler::OnError, | 54 base::Bind(&RemoteSecurityKeyMessageHandler::OnError, |
| 55 base::Unretained(this))); | 55 base::Unretained(this))); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void RemoteSecurityKeyMessageHandler::SetRemoteSecurityKeyMessageReaderForTest( | 58 void RemoteSecurityKeyMessageHandler::SetRemoteSecurityKeyMessageReaderForTest( |
| 59 scoped_ptr<RemoteSecurityKeyMessageReader> reader) { | 59 std::unique_ptr<RemoteSecurityKeyMessageReader> reader) { |
| 60 DCHECK(!reader_); | 60 DCHECK(!reader_); |
| 61 reader_ = std::move(reader); | 61 reader_ = std::move(reader); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void RemoteSecurityKeyMessageHandler::SetRemoteSecurityKeyMessageWriterForTest( | 64 void RemoteSecurityKeyMessageHandler::SetRemoteSecurityKeyMessageWriterForTest( |
| 65 scoped_ptr<RemoteSecurityKeyMessageWriter> writer) { | 65 std::unique_ptr<RemoteSecurityKeyMessageWriter> writer) { |
| 66 DCHECK(!writer_); | 66 DCHECK(!writer_); |
| 67 writer_ = std::move(writer); | 67 writer_ = std::move(writer); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void RemoteSecurityKeyMessageHandler::ProcessRemoteSecurityKeyMessage( | 70 void RemoteSecurityKeyMessageHandler::ProcessRemoteSecurityKeyMessage( |
| 71 scoped_ptr<SecurityKeyMessage> message) { | 71 std::unique_ptr<SecurityKeyMessage> message) { |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
| 73 | 73 |
| 74 RemoteSecurityKeyMessageType message_type = message->type(); | 74 RemoteSecurityKeyMessageType message_type = message->type(); |
| 75 if (message_type == RemoteSecurityKeyMessageType::CONNECT) { | 75 if (message_type == RemoteSecurityKeyMessageType::CONNECT) { |
| 76 HandleConnectRequest(message->payload()); | 76 HandleConnectRequest(message->payload()); |
| 77 } else if (message_type == RemoteSecurityKeyMessageType::REQUEST) { | 77 } else if (message_type == RemoteSecurityKeyMessageType::REQUEST) { |
| 78 HandleSecurityKeyRequest(message->payload()); | 78 HandleSecurityKeyRequest(message->payload()); |
| 79 } else { | 79 } else { |
| 80 LOG(ERROR) << "Unknown message type: " | 80 LOG(ERROR) << "Unknown message type: " |
| 81 << static_cast<uint8_t>(message_type); | 81 << static_cast<uint8_t>(message_type); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ipc_client_.reset(); | 173 ipc_client_.reset(); |
| 174 writer_.reset(); | 174 writer_.reset(); |
| 175 reader_.reset(); | 175 reader_.reset(); |
| 176 | 176 |
| 177 if (!error_callback_.is_null()) { | 177 if (!error_callback_.is_null()) { |
| 178 base::ResetAndReturn(&error_callback_).Run(); | 178 base::ResetAndReturn(&error_callback_).Run(); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace remoting | 182 } // namespace remoting |
| OLD | NEW |