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

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
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>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #endif // defined(OS_WIN) 44 #endif // defined(OS_WIN)
45 45
46 #if defined(OS_LINUX) 46 #if defined(OS_LINUX)
47 #include <glib-object.h> 47 #include <glib-object.h>
48 #endif // defined(OS_LINUX) 48 #endif // defined(OS_LINUX)
49 49
50 using remoting::protocol::PairingRegistry; 50 using remoting::protocol::PairingRegistry;
51 51
52 namespace remoting { 52 namespace remoting {
53 53
54 int StartMe2MeNativeMessagingHost() { 54 int Me2MeNativeMessagingHostMain(int argc, char** argv) {
55 // This object instance is required by Chrome code (such as MessageLoop).
56 base::AtExitManager exit_manager;
57
58 base::CommandLine::Init(argc, argv);
59 remoting::InitHostLogging();
60
55 #if defined(OS_MACOSX) 61 #if defined(OS_MACOSX)
56 // Needed so we don't leak objects when threads are created. 62 // Needed so we don't leak objects when threads are created.
57 base::mac::ScopedNSAutoreleasePool pool; 63 base::mac::ScopedNSAutoreleasePool pool;
58 #endif // defined(OS_MACOSX) 64 #endif // defined(OS_MACOSX)
59 65
60 #if defined(OS_LINUX) 66 #if defined(OS_LINUX)
61 // g_type_init will be deprecated in 2.36. 2.35 is the development 67 // 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. 68 // 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 69 // http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-t ype-init
64 #if !GLIB_CHECK_VERSION(2, 35, 0) 70 #if !GLIB_CHECK_VERSION(2, 35, 0)
65 g_type_init(); 71 g_type_init();
66 #endif 72 #endif
67 #endif // defined(OS_LINUX) 73 #endif // defined(OS_LINUX)
68 74
69 // Required to find the ICU data file, used by some file_util routines. 75 // Required to find the ICU data file, used by some file_util routines.
70 base::i18n::InitializeICU(); 76 base::i18n::InitializeICU();
71 77
72 #if defined(REMOTING_ENABLE_BREAKPAD) 78 #if defined(REMOTING_ENABLE_BREAKPAD)
73 // Initialize Breakpad as early as possible. On Mac the command-line needs to 79 // 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 80 // be initialized first, so that the preference for crash-reporting can be
75 // looked up in the config file. 81 // looked up in the config file.
76 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884 82 // TODO(nicholss): Commenting out Breakpad. See crbug.com/637884
77 // if (IsUsageStatsAllowed()) { 83 // if (IsUsageStatsAllowed()) {
78 // InitializeCrashReporting(); 84 // InitializeCrashReporting();
79 // } 85 // }
80 #endif // defined(REMOTING_ENABLE_BREAKPAD) 86 #endif // defined(REMOTING_ENABLE_BREAKPAD)
81 87
88 const int kMaxBackgroundThreads = 5;
89 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads);
90
82 // Mac OS X requires that the main thread be a UI message loop in order to 91 // 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 92 // receive distributed notifications from the System Preferences pane. An
84 // IO thread is needed for the pairing registry and URL context getter. 93 // IO thread is needed for the pairing registry and URL context getter.
85 base::Thread io_thread("io_thread"); 94 base::Thread io_thread("io_thread");
86 io_thread.StartWithOptions( 95 io_thread.StartWithOptions(
87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 96 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
88 97
89 base::Thread file_thread("file_thread"); 98 base::Thread file_thread("file_thread");
90 file_thread.StartWithOptions( 99 file_thread.StartWithOptions(
91 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 100 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 263
255 host->Start(native_messaging_pipe.get()); 264 host->Start(native_messaging_pipe.get());
256 265
257 native_messaging_pipe->Start(std::move(host), std::move(channel)); 266 native_messaging_pipe->Start(std::move(host), std::move(channel));
258 267
259 // Run the loop until channel is alive. 268 // Run the loop until channel is alive.
260 run_loop.Run(); 269 run_loop.Run();
261 return kSuccessExitCode; 270 return kSuccessExitCode;
262 } 271 }
263 272
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 273 } // namespace remoting
OLDNEW
« remoting/client/jni/chromoting_jni_runtime.cc ('K') | « remoting/host/remoting_me2me_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698