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

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

Issue 1826613003: Updating the remote_security_key to use the new message processing classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handler
Patch Set: Merging in latest handler changes. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
8 #include <utility>
9
7 #include "base/at_exit.h" 10 #include "base/at_exit.h"
8 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
9 #include "remoting/host/host_exit_codes.h" 14 #include "remoting/host/host_exit_codes.h"
10 #include "remoting/host/logging.h" 15 #include "remoting/host/logging.h"
16 #include "remoting/host/security_key/remote_security_key_ipc_client.h"
17 #include "remoting/host/security_key/remote_security_key_message_handler.h"
11 18
12 namespace remoting { 19 namespace remoting {
13 20
14 int StartRemoteSecurityKey() { 21 int StartRemoteSecurityKey() {
22 #if defined(OS_WIN)
23 // GetStdHandle() returns pseudo-handles for stdin and stdout even if
24 // the hosting executable specifies "Windows" subsystem. However the returned
25 // handles are invalid in that case unless standard input and output are
26 // redirected to a pipe or file.
27 base::File read_file(GetStdHandle(STD_INPUT_HANDLE));
28 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE));
29
30 // After the message handler starts, the remote security key message reader
31 // will keep doing blocking read operations on the input named pipe.
32 // If any other thread tries to perform any operation on STDIN, it will also
33 // block because the input named pipe is synchronous (non-overlapped).
34 // It is pretty common for a DLL to query the device info (GetFileType) of
35 // the STD* handles at startup. So any LoadLibrary request can potentially
36 // be blocked. To prevent that from happening we close STDIN and STDOUT
37 // handles as soon as we retrieve the corresponding file handles.
38 SetStdHandle(STD_INPUT_HANDLE, nullptr);
39 SetStdHandle(STD_OUTPUT_HANDLE, nullptr);
40 #elif defined(OS_POSIX)
41 // The files are automatically closed.
42 base::File read_file(STDIN_FILENO);
43 base::File write_file(STDOUT_FILENO);
44 #else
45 #error Not implemented.
46 #endif
47
48 base::RunLoop run_loop;
49
50 scoped_ptr<RemoteSecurityKeyIpcClient> ipc_client(
dcheng 2016/04/06 23:12:22 Please don't forget to IWYU, this collided with ht
51 new RemoteSecurityKeyIpcClient());
52
53 RemoteSecurityKeyMessageHandler message_handler;
54 message_handler.Start(std::move(read_file), std::move(write_file),
55 std::move(ipc_client), run_loop.QuitClosure());
56
57 run_loop.Run();
58
15 return kSuccessExitCode; 59 return kSuccessExitCode;
16 } 60 }
17 61
18 int RemoteSecurityKeyMain(int argc, char** argv) { 62 int RemoteSecurityKeyMain(int argc, char** argv) {
19 // This object instance is required by Chrome classes (such as MessageLoop). 63 // This object instance is required by Chrome classes (such as MessageLoop).
20 base::AtExitManager exit_manager; 64 base::AtExitManager exit_manager;
65 base::MessageLoopForUI message_loop;
21 66
22 base::CommandLine::Init(argc, argv); 67 base::CommandLine::Init(argc, argv);
23 remoting::InitHostLogging(); 68 remoting::InitHostLogging();
24 69
25 return StartRemoteSecurityKey(); 70 return StartRemoteSecurityKey();
26 } 71 }
27 72
28 } // namespace remoting 73 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698