| 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_auth_handler.h" | 5 #include "remoting/host/security_key/security_key_auth_handler.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include <cstdint> | 9 #include <cstdint> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 g_security_key_socket_name.Get() = security_key_socket_name; | 143 g_security_key_socket_name.Get() = security_key_socket_name; |
| 144 } | 144 } |
| 145 | 145 |
| 146 SecurityKeyAuthHandlerPosix::SecurityKeyAuthHandlerPosix( | 146 SecurityKeyAuthHandlerPosix::SecurityKeyAuthHandlerPosix( |
| 147 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 147 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) |
| 148 : file_task_runner_(file_task_runner), | 148 : file_task_runner_(file_task_runner), |
| 149 request_timeout_( | 149 request_timeout_( |
| 150 base::TimeDelta::FromSeconds(kDefaultRequestTimeoutSeconds)), | 150 base::TimeDelta::FromSeconds(kDefaultRequestTimeoutSeconds)), |
| 151 weak_factory_(this) {} | 151 weak_factory_(this) {} |
| 152 | 152 |
| 153 SecurityKeyAuthHandlerPosix::~SecurityKeyAuthHandlerPosix() {} | 153 SecurityKeyAuthHandlerPosix::~SecurityKeyAuthHandlerPosix() { |
| 154 if (file_task_runner_) { |
| 155 // Attempt to clean up the socket before being destroyed. |
| 156 file_task_runner_->PostTask( |
| 157 FROM_HERE, base::Bind(base::IgnoreResult(&base::DeleteFile), |
| 158 g_security_key_socket_name.Get(), |
| 159 /*recursive=*/false)); |
| 160 } |
| 161 } |
| 154 | 162 |
| 155 void SecurityKeyAuthHandlerPosix::CreateSecurityKeyConnection() { | 163 void SecurityKeyAuthHandlerPosix::CreateSecurityKeyConnection() { |
| 156 DCHECK(thread_checker_.CalledOnValidThread()); | 164 DCHECK(thread_checker_.CalledOnValidThread()); |
| 157 DCHECK(!g_security_key_socket_name.Get().empty()); | 165 DCHECK(!g_security_key_socket_name.Get().empty()); |
| 158 | 166 |
| 159 // We need to run the DeleteFile method on |file_task_runner_| as it is a | 167 // We need to run the DeleteFile method on |file_task_runner_| as it is a |
| 160 // blocking function call which cannot be run on the main thread. Once | 168 // blocking function call which cannot be run on the main thread. Once |
| 161 // that task has completed, the main thread will be called back and we will | 169 // that task has completed, the main thread will be called back and we will |
| 162 // resume setting up our security key auth socket there. | 170 // resume setting up our security key auth socket there. |
| 163 file_task_runner_->PostTaskAndReply( | 171 file_task_runner_->PostTaskAndReply( |
| 164 FROM_HERE, base::Bind(base::IgnoreResult(&base::DeleteFile), | 172 FROM_HERE, base::Bind(base::IgnoreResult(&base::DeleteFile), |
| 165 g_security_key_socket_name.Get(), false), | 173 g_security_key_socket_name.Get(), |
| 174 /*recursive=*/false), |
| 166 base::Bind(&SecurityKeyAuthHandlerPosix::CreateSocket, | 175 base::Bind(&SecurityKeyAuthHandlerPosix::CreateSocket, |
| 167 weak_factory_.GetWeakPtr())); | 176 weak_factory_.GetWeakPtr())); |
| 168 } | 177 } |
| 169 | 178 |
| 170 void SecurityKeyAuthHandlerPosix::CreateSocket() { | 179 void SecurityKeyAuthHandlerPosix::CreateSocket() { |
| 171 DCHECK(thread_checker_.CalledOnValidThread()); | 180 DCHECK(thread_checker_.CalledOnValidThread()); |
| 172 HOST_LOG << "Listening for security key requests on " | 181 HOST_LOG << "Listening for security key requests on " |
| 173 << g_security_key_socket_name.Get().value(); | 182 << g_security_key_socket_name.Get().value(); |
| 174 | 183 |
| 175 auth_socket_.reset( | 184 auth_socket_.reset( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 void SecurityKeyAuthHandlerPosix::RequestTimedOut( | 306 void SecurityKeyAuthHandlerPosix::RequestTimedOut( |
| 298 int security_key_connection_id) { | 307 int security_key_connection_id) { |
| 299 HOST_LOG << "SecurityKey request timed out"; | 308 HOST_LOG << "SecurityKey request timed out"; |
| 300 ActiveSockets::const_iterator iter = | 309 ActiveSockets::const_iterator iter = |
| 301 active_sockets_.find(security_key_connection_id); | 310 active_sockets_.find(security_key_connection_id); |
| 302 if (iter != active_sockets_.end()) | 311 if (iter != active_sockets_.end()) |
| 303 SendErrorAndCloseActiveSocket(iter); | 312 SendErrorAndCloseActiveSocket(iter); |
| 304 } | 313 } |
| 305 | 314 |
| 306 } // namespace remoting | 315 } // namespace remoting |
| OLD | NEW |