Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: remoting/host/security_key/gnubby_auth_handler_linux.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gnubby_auth_handler.h" 5 #include "remoting/host/security_key/gnubby_auth_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <memory>
11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
12 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/socket/stream_socket.h" 22 #include "net/socket/stream_socket.h"
22 #include "net/socket/unix_domain_server_socket_posix.h" 23 #include "net/socket/unix_domain_server_socket_posix.h"
23 #include "remoting/base/logging.h" 24 #include "remoting/base/logging.h"
24 #include "remoting/host/security_key/gnubby_socket.h" 25 #include "remoting/host/security_key/gnubby_socket.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Send an error and closes an active socket. 85 // Send an error and closes an active socket.
85 void SendErrorAndCloseActiveSocket(const ActiveSockets::const_iterator& iter); 86 void SendErrorAndCloseActiveSocket(const ActiveSockets::const_iterator& iter);
86 87
87 // A request timed out. 88 // A request timed out.
88 void RequestTimedOut(int gnubby_connection_id); 89 void RequestTimedOut(int gnubby_connection_id);
89 90
90 // Ensures GnubbyAuthHandlerLinux methods are called on the same thread. 91 // Ensures GnubbyAuthHandlerLinux methods are called on the same thread.
91 base::ThreadChecker thread_checker_; 92 base::ThreadChecker thread_checker_;
92 93
93 // Socket used to listen for authorization requests. 94 // Socket used to listen for authorization requests.
94 scoped_ptr<net::UnixDomainServerSocket> auth_socket_; 95 std::unique_ptr<net::UnixDomainServerSocket> auth_socket_;
95 96
96 // A temporary holder for an accepted connection. 97 // A temporary holder for an accepted connection.
97 scoped_ptr<net::StreamSocket> accept_socket_; 98 std::unique_ptr<net::StreamSocket> accept_socket_;
98 99
99 // Used to pass gnubby extension messages to the client. 100 // Used to pass gnubby extension messages to the client.
100 SendMessageCallback send_message_callback_; 101 SendMessageCallback send_message_callback_;
101 102
102 // The last assigned gnubby connection id. 103 // The last assigned gnubby connection id.
103 int last_connection_id_; 104 int last_connection_id_;
104 105
105 // Sockets by connection id used to process gnubbyd requests. 106 // Sockets by connection id used to process gnubbyd requests.
106 ActiveSockets active_sockets_; 107 ActiveSockets active_sockets_;
107 108
108 // Timeout used for a request. 109 // Timeout used for a request.
109 base::TimeDelta request_timeout_; 110 base::TimeDelta request_timeout_;
110 111
111 DISALLOW_COPY_AND_ASSIGN(GnubbyAuthHandlerLinux); 112 DISALLOW_COPY_AND_ASSIGN(GnubbyAuthHandlerLinux);
112 }; 113 };
113 114
114 scoped_ptr<GnubbyAuthHandler> GnubbyAuthHandler::Create( 115 std::unique_ptr<GnubbyAuthHandler> GnubbyAuthHandler::Create(
115 const SendMessageCallback& callback) { 116 const SendMessageCallback& callback) {
116 scoped_ptr<GnubbyAuthHandler> auth_handler(new GnubbyAuthHandlerLinux()); 117 std::unique_ptr<GnubbyAuthHandler> auth_handler(new GnubbyAuthHandlerLinux());
117 auth_handler->SetSendMessageCallback(callback); 118 auth_handler->SetSendMessageCallback(callback);
118 return auth_handler; 119 return auth_handler;
119 } 120 }
120 121
121 void GnubbyAuthHandler::SetGnubbySocketName( 122 void GnubbyAuthHandler::SetGnubbySocketName(
122 const base::FilePath& gnubby_socket_name) { 123 const base::FilePath& gnubby_socket_name) {
123 g_gnubby_socket_name.Get() = gnubby_socket_name; 124 g_gnubby_socket_name.Get() = gnubby_socket_name;
124 } 125 }
125 126
126 GnubbyAuthHandlerLinux::GnubbyAuthHandlerLinux() 127 GnubbyAuthHandlerLinux::GnubbyAuthHandlerLinux()
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 273
273 void GnubbyAuthHandlerLinux::RequestTimedOut(int gnubby_connection_id) { 274 void GnubbyAuthHandlerLinux::RequestTimedOut(int gnubby_connection_id) {
274 HOST_LOG << "Gnubby request timed out"; 275 HOST_LOG << "Gnubby request timed out";
275 ActiveSockets::const_iterator iter = 276 ActiveSockets::const_iterator iter =
276 active_sockets_.find(gnubby_connection_id); 277 active_sockets_.find(gnubby_connection_id);
277 if (iter != active_sockets_.end()) 278 if (iter != active_sockets_.end())
278 SendErrorAndCloseActiveSocket(iter); 279 SendErrorAndCloseActiveSocket(iter);
279 } 280 }
280 281
281 } // namespace remoting 282 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/security_key/gnubby_auth_handler.h ('k') | remoting/host/security_key/gnubby_auth_handler_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698