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/setup/me2me_native_messaging_host_main.h" | 5 #include "remoting/host/setup/me2me_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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 #endif // defined(REMOTING_ENABLE_BREAKPAD) | 80 #endif // defined(REMOTING_ENABLE_BREAKPAD) |
81 | 81 |
82 // Mac OS X requires that the main thread be a UI message loop in order to | 82 // Mac OS X requires that the main thread be a UI message loop in order to |
83 // receive distributed notifications from the System Preferences pane. An | 83 // receive distributed notifications from the System Preferences pane. An |
84 // IO thread is needed for the pairing registry and URL context getter. | 84 // IO thread is needed for the pairing registry and URL context getter. |
85 base::Thread io_thread("io_thread"); | 85 base::Thread io_thread("io_thread"); |
86 io_thread.StartWithOptions( | 86 io_thread.StartWithOptions( |
87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
88 | 88 |
| 89 base::Thread file_thread("file_thread"); |
| 90 file_thread.StartWithOptions( |
| 91 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 92 |
89 base::MessageLoopForUI message_loop; | 93 base::MessageLoopForUI message_loop; |
90 base::RunLoop run_loop; | 94 base::RunLoop run_loop; |
91 | 95 |
92 scoped_refptr<DaemonController> daemon_controller = | 96 scoped_refptr<DaemonController> daemon_controller = |
93 DaemonController::Create(); | 97 DaemonController::Create(); |
94 | 98 |
95 // Pass handle of the native view to the controller so that the UAC prompts | 99 // Pass handle of the native view to the controller so that the UAC prompts |
96 // are focused properly. | 100 // are focused properly. |
97 const base::CommandLine* command_line = | 101 const base::CommandLine* command_line = |
98 base::CommandLine::ForCurrentProcess(); | 102 base::CommandLine::ForCurrentProcess(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 SetStdHandle(STD_OUTPUT_HANDLE, NULL); | 171 SetStdHandle(STD_OUTPUT_HANDLE, NULL); |
168 } | 172 } |
169 #elif defined(OS_POSIX) | 173 #elif defined(OS_POSIX) |
170 // The files will be automatically closed. | 174 // The files will be automatically closed. |
171 read_file = base::File(STDIN_FILENO); | 175 read_file = base::File(STDIN_FILENO); |
172 write_file = base::File(STDOUT_FILENO); | 176 write_file = base::File(STDOUT_FILENO); |
173 #else | 177 #else |
174 #error Not implemented. | 178 #error Not implemented. |
175 #endif | 179 #endif |
176 | 180 |
177 // OAuth client (for credential requests). | 181 // OAuth client (for credential requests). IO thread is used for blocking |
178 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter( | 182 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter( |
179 new URLRequestContextGetter(io_thread.message_loop_proxy())); | 183 new URLRequestContextGetter(io_thread.task_runner(), |
| 184 file_thread.task_runner())); |
180 scoped_ptr<OAuthClient> oauth_client( | 185 scoped_ptr<OAuthClient> oauth_client( |
181 new OAuthClient(url_request_context_getter)); | 186 new OAuthClient(url_request_context_getter)); |
182 | 187 |
183 net::URLFetcher::SetIgnoreCertificateRequests(true); | 188 net::URLFetcher::SetIgnoreCertificateRequests(true); |
184 | 189 |
185 // Create the pairing registry. | 190 // Create the pairing registry. |
186 scoped_refptr<PairingRegistry> pairing_registry; | 191 scoped_refptr<PairingRegistry> pairing_registry; |
187 | 192 |
188 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
189 base::win::RegKey root; | 194 base::win::RegKey root; |
(...skipping 28 matching lines...) Expand all Loading... |
218 } | 223 } |
219 } | 224 } |
220 | 225 |
221 // Initialize the pairing registry delegate and set the root keys. | 226 // Initialize the pairing registry delegate and set the root keys. |
222 scoped_ptr<PairingRegistryDelegateWin> delegate( | 227 scoped_ptr<PairingRegistryDelegateWin> delegate( |
223 new PairingRegistryDelegateWin()); | 228 new PairingRegistryDelegateWin()); |
224 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take())) | 229 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take())) |
225 return kInitializationFailed; | 230 return kInitializationFailed; |
226 | 231 |
227 pairing_registry = new PairingRegistry( | 232 pairing_registry = new PairingRegistry( |
228 io_thread.message_loop_proxy(), | 233 io_thread.task_runner(), |
229 delegate.PassAs<PairingRegistry::Delegate>()); | 234 delegate.PassAs<PairingRegistry::Delegate>()); |
230 #else // defined(OS_WIN) | 235 #else // defined(OS_WIN) |
231 pairing_registry = | 236 pairing_registry = |
232 CreatePairingRegistry(io_thread.message_loop_proxy()); | 237 CreatePairingRegistry(io_thread.task_runner()); |
233 #endif // !defined(OS_WIN) | 238 #endif // !defined(OS_WIN) |
234 | 239 |
235 // Set up the native messaging channel. | 240 // Set up the native messaging channel. |
236 scoped_ptr<NativeMessagingChannel> channel( | 241 scoped_ptr<NativeMessagingChannel> channel( |
237 new NativeMessagingChannel(read_file.Pass(), write_file.Pass())); | 242 new NativeMessagingChannel(read_file.Pass(), write_file.Pass())); |
238 | 243 |
239 // Create the native messaging host. | 244 // Create the native messaging host. |
240 scoped_ptr<Me2MeNativeMessagingHost> host( | 245 scoped_ptr<Me2MeNativeMessagingHost> host( |
241 new Me2MeNativeMessagingHost( | 246 new Me2MeNativeMessagingHost( |
242 needs_elevation, | 247 needs_elevation, |
(...skipping 13 matching lines...) Expand all Loading... |
256 // This object instance is required by Chrome code (such as MessageLoop). | 261 // This object instance is required by Chrome code (such as MessageLoop). |
257 base::AtExitManager exit_manager; | 262 base::AtExitManager exit_manager; |
258 | 263 |
259 base::CommandLine::Init(argc, argv); | 264 base::CommandLine::Init(argc, argv); |
260 remoting::InitHostLogging(); | 265 remoting::InitHostLogging(); |
261 | 266 |
262 return StartMe2MeNativeMessagingHost(); | 267 return StartMe2MeNativeMessagingHost(); |
263 } | 268 } |
264 | 269 |
265 } // namespace remoting | 270 } // namespace remoting |
OLD | NEW |