OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/it2me/it2me_native_messaging_host_main.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host_main.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/icu_util.h" | 9 #include "base/i18n/icu_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 base::i18n::InitializeICU(); | 64 base::i18n::InitializeICU(); |
65 | 65 |
66 remoting::LoadResources(""); | 66 remoting::LoadResources(""); |
67 | 67 |
68 // Cannot use TOOLKIT_GTK because it is not defined when aura is enabled. | 68 // Cannot use TOOLKIT_GTK because it is not defined when aura is enabled. |
69 #if defined(OS_LINUX) | 69 #if defined(OS_LINUX) |
70 // Required in order for us to run multiple X11 threads. | 70 // Required in order for us to run multiple X11 threads. |
71 XInitThreads(); | 71 XInitThreads(); |
72 | 72 |
73 // Required for any calls into GTK functions, such as the Disconnect and | 73 // Required for any calls into GTK functions, such as the Disconnect and |
74 // Continue windows. Calling with NULL arguments because we don't have | 74 // Continue windows. Calling with nullptr arguments because we don't have |
75 // any command line arguments for gtk to consume. | 75 // any command line arguments for gtk to consume. |
76 gtk_init(NULL, NULL); | 76 gtk_init(nullptr, nullptr); |
77 #endif // OS_LINUX | 77 #endif // OS_LINUX |
78 | 78 |
79 // Enable support for SSL server sockets, which must be done while still | 79 // Enable support for SSL server sockets, which must be done while still |
80 // single-threaded. | 80 // single-threaded. |
81 net::EnableSSLServerSockets(); | 81 net::EnableSSLServerSockets(); |
82 | 82 |
83 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
84 // GetStdHandle() returns pseudo-handles for stdin and stdout even if | 84 // GetStdHandle() returns pseudo-handles for stdin and stdout even if |
85 // the hosting executable specifies "Windows" subsystem. However the returned | 85 // the hosting executable specifies "Windows" subsystem. However the returned |
86 // handles are invalid in that case unless standard input and output are | 86 // handles are invalid in that case unless standard input and output are |
87 // redirected to a pipe or file. | 87 // redirected to a pipe or file. |
88 base::File read_file(GetStdHandle(STD_INPUT_HANDLE)); | 88 base::File read_file(GetStdHandle(STD_INPUT_HANDLE)); |
89 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE)); | 89 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE)); |
90 | 90 |
91 // After the native messaging channel starts the native messaging reader | 91 // After the native messaging channel starts the native messaging reader |
92 // will keep doing blocking read operations on the input named pipe. | 92 // will keep doing blocking read operations on the input named pipe. |
93 // If any other thread tries to perform any operation on STDIN, it will also | 93 // If any other thread tries to perform any operation on STDIN, it will also |
94 // block because the input named pipe is synchronous (non-overlapped). | 94 // block because the input named pipe is synchronous (non-overlapped). |
95 // It is pretty common for a DLL to query the device info (GetFileType) of | 95 // It is pretty common for a DLL to query the device info (GetFileType) of |
96 // the STD* handles at startup. So any LoadLibrary request can potentially | 96 // the STD* handles at startup. So any LoadLibrary request can potentially |
97 // be blocked. To prevent that from happening we close STDIN and STDOUT | 97 // be blocked. To prevent that from happening we close STDIN and STDOUT |
98 // handles as soon as we retrieve the corresponding file handles. | 98 // handles as soon as we retrieve the corresponding file handles. |
99 SetStdHandle(STD_INPUT_HANDLE, NULL); | 99 SetStdHandle(STD_INPUT_HANDLE, nullptr); |
100 SetStdHandle(STD_OUTPUT_HANDLE, NULL); | 100 SetStdHandle(STD_OUTPUT_HANDLE, nullptr); |
101 #elif defined(OS_POSIX) | 101 #elif defined(OS_POSIX) |
102 // The files are automatically closed. | 102 // The files are automatically closed. |
103 base::File read_file(STDIN_FILENO); | 103 base::File read_file(STDIN_FILENO); |
104 base::File write_file(STDOUT_FILENO); | 104 base::File write_file(STDOUT_FILENO); |
105 #else | 105 #else |
106 #error Not implemented. | 106 #error Not implemented. |
107 #endif | 107 #endif |
108 | 108 |
109 base::MessageLoopForUI message_loop; | 109 base::MessageLoopForUI message_loop; |
110 base::RunLoop run_loop; | 110 base::RunLoop run_loop; |
(...skipping 29 matching lines...) Expand all Loading... |
140 // This object instance is required by Chrome code (such as MessageLoop). | 140 // This object instance is required by Chrome code (such as MessageLoop). |
141 base::AtExitManager exit_manager; | 141 base::AtExitManager exit_manager; |
142 | 142 |
143 base::CommandLine::Init(argc, argv); | 143 base::CommandLine::Init(argc, argv); |
144 remoting::InitHostLogging(); | 144 remoting::InitHostLogging(); |
145 | 145 |
146 return StartIt2MeNativeMessagingHost(); | 146 return StartIt2MeNativeMessagingHost(); |
147 } | 147 } |
148 | 148 |
149 } // namespace remoting | 149 } // namespace remoting |
OLD | NEW |