OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gnubby_auth_handler_posix.h" | 5 #include "remoting/host/gnubby_auth_handler_posix.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 DCHECK(CalledOnValidThread()); | 224 DCHECK(CalledOnValidThread()); |
225 | 225 |
226 ActiveSockets::iterator iter = active_sockets_.find(connection_id); | 226 ActiveSockets::iterator iter = active_sockets_.find(connection_id); |
227 DCHECK(iter != active_sockets_.end()); | 227 DCHECK(iter != active_sockets_.end()); |
228 std::string request_data; | 228 std::string request_data; |
229 if (!iter->second->GetAndClearRequestData(&request_data)) { | 229 if (!iter->second->GetAndClearRequestData(&request_data)) { |
230 SendErrorAndCloseActiveSocket(iter); | 230 SendErrorAndCloseActiveSocket(iter); |
231 return; | 231 return; |
232 } | 232 } |
233 ProcessGnubbyRequest(connection_id, request_data); | 233 ProcessGnubbyRequest(connection_id, request_data); |
234 Close(iter); | 234 iter->second->StartReadingRequest( |
235 } | 235 base::Bind(&GnubbyAuthHandlerPosix::OnReadComplete, |
236 | 236 base::Unretained(this), connection_id)); |
237 void GnubbyAuthHandlerPosix::Close(const ActiveSockets::iterator& iter) { | |
238 DCHECK(CalledOnValidThread()); | |
239 | |
240 delete iter->second; | |
241 active_sockets_.erase(iter); | |
242 } | 237 } |
243 | 238 |
244 void GnubbyAuthHandlerPosix::CreateAuthorizationSocket() { | 239 void GnubbyAuthHandlerPosix::CreateAuthorizationSocket() { |
245 DCHECK(CalledOnValidThread()); | 240 DCHECK(CalledOnValidThread()); |
246 | 241 |
247 if (!g_gnubby_socket_name.Get().empty()) { | 242 if (!g_gnubby_socket_name.Get().empty()) { |
248 // If the file already exists, a socket in use error is returned. | 243 // If the file already exists, a socket in use error is returned. |
249 base::DeleteFile(g_gnubby_socket_name.Get(), false); | 244 base::DeleteFile(g_gnubby_socket_name.Get(), false); |
250 | 245 |
251 HOST_LOG << "Listening for gnubby requests on " | 246 HOST_LOG << "Listening for gnubby requests on " |
(...skipping 25 matching lines...) Expand all Loading... |
277 int connection_id; | 272 int connection_id; |
278 if (message->GetInteger(kConnectionId, &connection_id)) { | 273 if (message->GetInteger(kConnectionId, &connection_id)) { |
279 return active_sockets_.find(connection_id); | 274 return active_sockets_.find(connection_id); |
280 } | 275 } |
281 return active_sockets_.end(); | 276 return active_sockets_.end(); |
282 } | 277 } |
283 | 278 |
284 void GnubbyAuthHandlerPosix::SendErrorAndCloseActiveSocket( | 279 void GnubbyAuthHandlerPosix::SendErrorAndCloseActiveSocket( |
285 const ActiveSockets::iterator& iter) { | 280 const ActiveSockets::iterator& iter) { |
286 iter->second->SendSshError(); | 281 iter->second->SendSshError(); |
287 Close(iter); | 282 delete iter->second; |
| 283 active_sockets_.erase(iter); |
288 } | 284 } |
289 | 285 |
290 void GnubbyAuthHandlerPosix::RequestTimedOut(int connection_id) { | 286 void GnubbyAuthHandlerPosix::RequestTimedOut(int connection_id) { |
291 HOST_LOG << "Gnubby request timed out"; | 287 HOST_LOG << "Gnubby request timed out"; |
292 ActiveSockets::iterator iter = active_sockets_.find(connection_id); | 288 ActiveSockets::iterator iter = active_sockets_.find(connection_id); |
293 if (iter != active_sockets_.end()) | 289 if (iter != active_sockets_.end()) |
294 SendErrorAndCloseActiveSocket(iter); | 290 SendErrorAndCloseActiveSocket(iter); |
295 } | 291 } |
296 | 292 |
297 } // namespace remoting | 293 } // namespace remoting |
OLD | NEW |