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

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

Issue 2162083003: Renaming Gnubby and RemoteSecurityKey files/classes/members (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a GYP build error Created 4 years, 5 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/remote_security_key_main.h" 5 #include "remoting/host/security_key/remote_security_key_main.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "remoting/host/host_exit_codes.h" 15 #include "remoting/host/host_exit_codes.h"
16 #include "remoting/host/logging.h" 16 #include "remoting/host/logging.h"
17 #include "remoting/host/security_key/remote_security_key_ipc_client.h" 17 #include "remoting/host/security_key/security_key_ipc_client.h"
18 #include "remoting/host/security_key/remote_security_key_message_handler.h" 18 #include "remoting/host/security_key/security_key_message_handler.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include <aclapi.h> 21 #include <aclapi.h>
22 #include <windows.h> 22 #include <windows.h>
23 23
24 #include "base/win/scoped_handle.h" 24 #include "base/win/scoped_handle.h"
25 #endif // defined(OS_WIN) 25 #endif // defined(OS_WIN)
26 26
27 #if defined(OS_WIN) 27 #if defined(OS_WIN)
28 namespace { 28 namespace {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return kInitializationFailed; 112 return kInitializationFailed;
113 } 113 }
114 114
115 // GetStdHandle() returns pseudo-handles for stdin and stdout even if 115 // GetStdHandle() returns pseudo-handles for stdin and stdout even if
116 // the hosting executable specifies "Windows" subsystem. However the returned 116 // the hosting executable specifies "Windows" subsystem. However the returned
117 // handles are invalid in that case unless standard input and output are 117 // handles are invalid in that case unless standard input and output are
118 // redirected to a pipe or file. 118 // redirected to a pipe or file.
119 base::File read_file(GetStdHandle(STD_INPUT_HANDLE)); 119 base::File read_file(GetStdHandle(STD_INPUT_HANDLE));
120 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE)); 120 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE));
121 121
122 // After the message handler starts, the remote security key message reader 122 // After the message handler starts, the security key message reader
123 // will keep doing blocking read operations on the input named pipe. 123 // will keep doing blocking read operations on the input named pipe.
124 // If any other thread tries to perform any operation on STDIN, it will also 124 // If any other thread tries to perform any operation on STDIN, it will also
125 // block because the input named pipe is synchronous (non-overlapped). 125 // block because the input named pipe is synchronous (non-overlapped).
126 // It is pretty common for a DLL to query the device info (GetFileType) of 126 // It is pretty common for a DLL to query the device info (GetFileType) of
127 // the STD* handles at startup. So any LoadLibrary request can potentially 127 // the STD* handles at startup. So any LoadLibrary request can potentially
128 // be blocked. To prevent that from happening we close STDIN and STDOUT 128 // be blocked. To prevent that from happening we close STDIN and STDOUT
129 // handles as soon as we retrieve the corresponding file handles. 129 // handles as soon as we retrieve the corresponding file handles.
130 SetStdHandle(STD_INPUT_HANDLE, nullptr); 130 SetStdHandle(STD_INPUT_HANDLE, nullptr);
131 SetStdHandle(STD_OUTPUT_HANDLE, nullptr); 131 SetStdHandle(STD_OUTPUT_HANDLE, nullptr);
132 #elif defined(OS_POSIX) 132 #elif defined(OS_POSIX)
133 // The files are automatically closed. 133 // The files are automatically closed.
134 base::File read_file(STDIN_FILENO); 134 base::File read_file(STDIN_FILENO);
135 base::File write_file(STDOUT_FILENO); 135 base::File write_file(STDOUT_FILENO);
136 #else 136 #else
137 #error Not implemented. 137 #error Not implemented.
138 #endif 138 #endif
139 139
140 base::RunLoop run_loop; 140 base::RunLoop run_loop;
141 141
142 std::unique_ptr<RemoteSecurityKeyIpcClient> ipc_client( 142 std::unique_ptr<SecurityKeyIpcClient> ipc_client(new SecurityKeyIpcClient());
143 new RemoteSecurityKeyIpcClient());
144 143
145 RemoteSecurityKeyMessageHandler message_handler; 144 SecurityKeyMessageHandler message_handler;
146 message_handler.Start(std::move(read_file), std::move(write_file), 145 message_handler.Start(std::move(read_file), std::move(write_file),
147 std::move(ipc_client), run_loop.QuitClosure()); 146 std::move(ipc_client), run_loop.QuitClosure());
148 147
149 run_loop.Run(); 148 run_loop.Run();
150 149
151 return kSuccessExitCode; 150 return kSuccessExitCode;
152 } 151 }
153 152
154 int RemoteSecurityKeyMain(int argc, char** argv) { 153 int RemoteSecurityKeyMain(int argc, char** argv) {
155 // This object instance is required by Chrome classes (such as MessageLoop). 154 // This object instance is required by Chrome classes (such as MessageLoop).
156 base::AtExitManager exit_manager; 155 base::AtExitManager exit_manager;
157 base::MessageLoopForIO message_loop; 156 base::MessageLoopForIO message_loop;
158 157
159 base::CommandLine::Init(argc, argv); 158 base::CommandLine::Init(argc, argv);
160 remoting::InitHostLogging(); 159 remoting::InitHostLogging();
161 160
162 return StartRemoteSecurityKey(); 161 return StartRemoteSecurityKey();
163 } 162 }
164 163
165 } // namespace remoting 164 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698