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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_main.cc

Issue 2669893002: Initialize TaskScheduler in remoting processes. (Closed)
Patch Set: . Created 3 years, 10 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 | « remoting/client/jni/chromoting_jni_runtime.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/icu_util.h" 11 #include "base/i18n/icu_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/task_scheduler/task_scheduler.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "remoting/base/auto_thread_task_runner.h" 16 #include "remoting/base/auto_thread_task_runner.h"
16 #include "remoting/base/breakpad.h" 17 #include "remoting/base/breakpad.h"
17 #include "remoting/host/chromoting_host_context.h" 18 #include "remoting/host/chromoting_host_context.h"
18 #include "remoting/host/host_exit_codes.h" 19 #include "remoting/host/host_exit_codes.h"
19 #include "remoting/host/it2me/it2me_native_messaging_host.h" 20 #include "remoting/host/it2me/it2me_native_messaging_host.h"
20 #include "remoting/host/logging.h" 21 #include "remoting/host/logging.h"
21 #include "remoting/host/native_messaging/native_messaging_pipe.h" 22 #include "remoting/host/native_messaging/native_messaging_pipe.h"
22 #include "remoting/host/native_messaging/pipe_messaging_channel.h" 23 #include "remoting/host/native_messaging/pipe_messaging_channel.h"
23 #include "remoting/host/resources.h" 24 #include "remoting/host/resources.h"
(...skipping 14 matching lines...) Expand all
38 #include <commctrl.h> 39 #include <commctrl.h>
39 40
40 #include "remoting/host/switches.h" 41 #include "remoting/host/switches.h"
41 #include "remoting/host/win/elevation_helpers.h" 42 #include "remoting/host/win/elevation_helpers.h"
42 #endif // defined(OS_WIN) 43 #endif // defined(OS_WIN)
43 44
44 namespace remoting { 45 namespace remoting {
45 46
46 // Creates a It2MeNativeMessagingHost instance, attaches it to stdin/stdout and 47 // Creates a It2MeNativeMessagingHost instance, attaches it to stdin/stdout and
47 // runs the message loop until It2MeNativeMessagingHost signals shutdown. 48 // runs the message loop until It2MeNativeMessagingHost signals shutdown.
48 int StartIt2MeNativeMessagingHost() { 49 int It2MeNativeMessagingHostMain(int argc, char** argv) {
50 // This object instance is required by Chrome code (such as MessageLoop).
51 base::AtExitManager exit_manager;
52
53 base::CommandLine::Init(argc, argv);
54 remoting::InitHostLogging();
55
49 #if defined(OS_MACOSX) 56 #if defined(OS_MACOSX)
50 // Needed so we don't leak objects when threads are created. 57 // Needed so we don't leak objects when threads are created.
51 base::mac::ScopedNSAutoreleasePool pool; 58 base::mac::ScopedNSAutoreleasePool pool;
52 #endif // defined(OS_MACOSX) 59 #endif // defined(OS_MACOSX)
53 60
54 #if defined(REMOTING_ENABLE_BREAKPAD) 61 #if defined(REMOTING_ENABLE_BREAKPAD)
55 // Initialize Breakpad as early as possible. On Mac the command-line needs to 62 // Initialize Breakpad as early as possible. On Mac the command-line needs to
56 // be initialized first, so that the preference for crash-reporting can be 63 // be initialized first, so that the preference for crash-reporting can be
57 // looked up in the config file. 64 // looked up in the config file.
58 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884 65 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884
59 // if (IsUsageStatsAllowed()) { 66 // if (IsUsageStatsAllowed()) {
60 // InitializeCrashReporting(); 67 // InitializeCrashReporting();
61 // } 68 // }
62 #endif // defined(REMOTING_ENABLE_BREAKPAD) 69 #endif // defined(REMOTING_ENABLE_BREAKPAD)
63 70
64 #if defined(OS_WIN) 71 #if defined(OS_WIN)
65 // Register and initialize common controls. 72 // Register and initialize common controls.
66 INITCOMMONCONTROLSEX info; 73 INITCOMMONCONTROLSEX info;
67 info.dwSize = sizeof(info); 74 info.dwSize = sizeof(info);
68 info.dwICC = ICC_STANDARD_CLASSES; 75 info.dwICC = ICC_STANDARD_CLASSES;
69 InitCommonControlsEx(&info); 76 InitCommonControlsEx(&info);
70 #endif // defined(OS_WIN) 77 #endif // defined(OS_WIN)
71 78
72 // Required to find the ICU data file, used by some file_util routines. 79 // Required to find the ICU data file, used by some file_util routines.
73 base::i18n::InitializeICU(); 80 base::i18n::InitializeICU();
74 81
82 // TODO(sergeyu): Consider adding separate pools for different task classes.
83 const int kMaxBackgroundThreads = 5;
84 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads);
85
75 remoting::LoadResources(""); 86 remoting::LoadResources("");
76 87
77 #if defined(OS_LINUX) 88 #if defined(OS_LINUX)
78 // Required in order for us to run multiple X11 threads. 89 // Required in order for us to run multiple X11 threads.
79 XInitThreads(); 90 XInitThreads();
80 91
81 // Required for any calls into GTK functions, such as the Disconnect and 92 // Required for any calls into GTK functions, such as the Disconnect and
82 // Continue windows. Calling with nullptr arguments because we don't have 93 // Continue windows. Calling with nullptr arguments because we don't have
83 // any command line arguments for gtk to consume. 94 // any command line arguments for gtk to consume.
84 gtk_init(nullptr, nullptr); 95 gtk_init(nullptr, nullptr);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 host->Start(native_messaging_pipe.get()); 196 host->Start(native_messaging_pipe.get());
186 197
187 native_messaging_pipe->Start(std::move(host), std::move(channel)); 198 native_messaging_pipe->Start(std::move(host), std::move(channel));
188 199
189 // Run the loop until channel is alive. 200 // Run the loop until channel is alive.
190 run_loop.Run(); 201 run_loop.Run();
191 202
192 return kSuccessExitCode; 203 return kSuccessExitCode;
193 } 204 }
194 205
195 int It2MeNativeMessagingHostMain(int argc, char** argv) {
196 // This object instance is required by Chrome code (such as MessageLoop).
197 base::AtExitManager exit_manager;
198
199 base::CommandLine::Init(argc, argv);
200 remoting::InitHostLogging();
201
202 return StartIt2MeNativeMessagingHost();
203 }
204
205 } // namespace remoting 206 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_runtime.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698