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

Side by Side Diff: remoting/host/setup/me2me_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/host/remoting_me2me_host.cc ('k') | 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 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 <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/i18n/icu_util.h" 15 #include "base/i18n/icu_util.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/task_scheduler/task_scheduler.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "net/url_request/url_fetcher.h" 22 #include "net/url_request/url_fetcher.h"
22 #include "remoting/base/auto_thread_task_runner.h" 23 #include "remoting/base/auto_thread_task_runner.h"
23 #include "remoting/base/breakpad.h" 24 #include "remoting/base/breakpad.h"
24 #include "remoting/base/url_request_context_getter.h" 25 #include "remoting/base/url_request_context_getter.h"
25 #include "remoting/host/chromoting_host_context.h" 26 #include "remoting/host/chromoting_host_context.h"
26 #include "remoting/host/host_exit_codes.h" 27 #include "remoting/host/host_exit_codes.h"
27 #include "remoting/host/logging.h" 28 #include "remoting/host/logging.h"
28 #include "remoting/host/native_messaging/native_messaging_pipe.h" 29 #include "remoting/host/native_messaging/native_messaging_pipe.h"
(...skipping 15 matching lines...) Expand all
44 #endif // defined(OS_WIN) 45 #endif // defined(OS_WIN)
45 46
46 #if defined(OS_LINUX) 47 #if defined(OS_LINUX)
47 #include <glib-object.h> 48 #include <glib-object.h>
48 #endif // defined(OS_LINUX) 49 #endif // defined(OS_LINUX)
49 50
50 using remoting::protocol::PairingRegistry; 51 using remoting::protocol::PairingRegistry;
51 52
52 namespace remoting { 53 namespace remoting {
53 54
54 int StartMe2MeNativeMessagingHost() { 55 int Me2MeNativeMessagingHostMain(int argc, char** argv) {
56 // This object instance is required by Chrome code (such as MessageLoop).
57 base::AtExitManager exit_manager;
58
59 base::CommandLine::Init(argc, argv);
60 remoting::InitHostLogging();
61
55 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
56 // Needed so we don't leak objects when threads are created. 63 // Needed so we don't leak objects when threads are created.
57 base::mac::ScopedNSAutoreleasePool pool; 64 base::mac::ScopedNSAutoreleasePool pool;
58 #endif // defined(OS_MACOSX) 65 #endif // defined(OS_MACOSX)
59 66
60 #if defined(OS_LINUX) 67 #if defined(OS_LINUX)
61 // g_type_init will be deprecated in 2.36. 2.35 is the development 68 // g_type_init will be deprecated in 2.36. 2.35 is the development
62 // version for 2.36, hence do not call g_type_init starting 2.35. 69 // version for 2.36, hence do not call g_type_init starting 2.35.
63 // http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-t ype-init 70 // http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-t ype-init
64 #if !GLIB_CHECK_VERSION(2, 35, 0) 71 #if !GLIB_CHECK_VERSION(2, 35, 0)
65 g_type_init(); 72 g_type_init();
66 #endif 73 #endif
67 #endif // defined(OS_LINUX) 74 #endif // defined(OS_LINUX)
68 75
69 // Required to find the ICU data file, used by some file_util routines. 76 // Required to find the ICU data file, used by some file_util routines.
70 base::i18n::InitializeICU(); 77 base::i18n::InitializeICU();
71 78
72 #if defined(REMOTING_ENABLE_BREAKPAD) 79 #if defined(REMOTING_ENABLE_BREAKPAD)
73 // Initialize Breakpad as early as possible. On Mac the command-line needs to 80 // Initialize Breakpad as early as possible. On Mac the command-line needs to
74 // be initialized first, so that the preference for crash-reporting can be 81 // be initialized first, so that the preference for crash-reporting can be
75 // looked up in the config file. 82 // looked up in the config file.
76 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884 83 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884
77 // if (IsUsageStatsAllowed()) { 84 // if (IsUsageStatsAllowed()) {
78 // InitializeCrashReporting(); 85 // InitializeCrashReporting();
79 // } 86 // }
80 #endif // defined(REMOTING_ENABLE_BREAKPAD) 87 #endif // defined(REMOTING_ENABLE_BREAKPAD)
81 88
89 // TODO(sergeyu): Consider adding separate pools for different task classes.
90 const int kMaxBackgroundThreads = 5;
91 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads);
92
82 // Mac OS X requires that the main thread be a UI message loop in order to 93 // 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 94 // receive distributed notifications from the System Preferences pane. An
84 // IO thread is needed for the pairing registry and URL context getter. 95 // IO thread is needed for the pairing registry and URL context getter.
85 base::Thread io_thread("io_thread"); 96 base::Thread io_thread("io_thread");
86 io_thread.StartWithOptions( 97 io_thread.StartWithOptions(
87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 98 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
88 99
89 base::Thread file_thread("file_thread"); 100 base::Thread file_thread("file_thread");
90 file_thread.StartWithOptions( 101 file_thread.StartWithOptions(
91 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 102 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 265
255 host->Start(native_messaging_pipe.get()); 266 host->Start(native_messaging_pipe.get());
256 267
257 native_messaging_pipe->Start(std::move(host), std::move(channel)); 268 native_messaging_pipe->Start(std::move(host), std::move(channel));
258 269
259 // Run the loop until channel is alive. 270 // Run the loop until channel is alive.
260 run_loop.Run(); 271 run_loop.Run();
261 return kSuccessExitCode; 272 return kSuccessExitCode;
262 } 273 }
263 274
264 int Me2MeNativeMessagingHostMain(int argc, char** argv) {
265 // This object instance is required by Chrome code (such as MessageLoop).
266 base::AtExitManager exit_manager;
267
268 base::CommandLine::Init(argc, argv);
269 remoting::InitHostLogging();
270
271 return StartMe2MeNativeMessagingHost();
272 }
273
274 } // namespace remoting 275 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698