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

Side by Side Diff: remoting/host/remoting_me2me_host.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstdint> 9 #include <cstdint>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/debug/alias.h" 17 #include "base/debug/alias.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/run_loop.h" 23 #include "base/run_loop.h"
24 #include "base/single_thread_task_runner.h" 24 #include "base/single_thread_task_runner.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
27 #include "base/strings/stringize_macros.h" 27 #include "base/strings/stringize_macros.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/task_scheduler/task_scheduler.h"
29 #include "build/build_config.h" 30 #include "build/build_config.h"
30 #include "components/policy/policy_constants.h" 31 #include "components/policy/policy_constants.h"
31 #include "ipc/ipc_channel.h" 32 #include "ipc/ipc_channel.h"
32 #include "ipc/ipc_channel_proxy.h" 33 #include "ipc/ipc_channel_proxy.h"
33 #include "ipc/ipc_listener.h" 34 #include "ipc/ipc_listener.h"
34 #include "jingle/glue/thread_wrapper.h" 35 #include "jingle/glue/thread_wrapper.h"
35 #include "mojo/edk/embedder/embedder.h" 36 #include "mojo/edk/embedder/embedder.h"
36 #include "mojo/edk/embedder/platform_channel_pair.h" 37 #include "mojo/edk/embedder/platform_channel_pair.h"
37 #include "mojo/edk/embedder/scoped_ipc_support.h" 38 #include "mojo/edk/embedder/scoped_ipc_support.h"
38 #include "net/base/network_change_notifier.h" 39 #include "net/base/network_change_notifier.h"
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 // Required for any calls into GTK functions, such as the Disconnect and 1635 // Required for any calls into GTK functions, such as the Disconnect and
1635 // Continue windows, though these should not be used for the Me2Me case 1636 // Continue windows, though these should not be used for the Me2Me case
1636 // (crbug.com/104377). 1637 // (crbug.com/104377).
1637 gtk_init(nullptr, nullptr); 1638 gtk_init(nullptr, nullptr);
1638 1639
1639 // Need to prime the host OS version value for linux to prevent IO on the 1640 // Need to prime the host OS version value for linux to prevent IO on the
1640 // network thread. base::GetLinuxDistro() caches the result. 1641 // network thread. base::GetLinuxDistro() caches the result.
1641 base::GetLinuxDistro(); 1642 base::GetLinuxDistro();
1642 #endif 1643 #endif
1643 1644
1645 // TODO(sergeyu): Consider adding separate pools for different task classes.
1646 const int kMaxBackgroundThreads = 5;
1647 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads);
1648
1644 // Create the main message loop and start helper threads. 1649 // Create the main message loop and start helper threads.
1645 base::MessageLoopForUI message_loop; 1650 base::MessageLoopForUI message_loop;
1646 std::unique_ptr<ChromotingHostContext> context = 1651 std::unique_ptr<ChromotingHostContext> context =
1647 ChromotingHostContext::Create( 1652 ChromotingHostContext::Create(
1648 new AutoThreadTaskRunner(message_loop.task_runner(), 1653 new AutoThreadTaskRunner(message_loop.task_runner(),
1649 base::MessageLoop::QuitWhenIdleClosure())); 1654 base::MessageLoop::QuitWhenIdleClosure()));
1650 if (!context) 1655 if (!context)
1651 return kInitializationFailed; 1656 return kInitializationFailed;
1652 1657
1653 // NetworkChangeNotifier must be initialized after MessageLoop. 1658 // NetworkChangeNotifier must be initialized after MessageLoop.
1654 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( 1659 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
1655 net::NetworkChangeNotifier::Create()); 1660 net::NetworkChangeNotifier::Create());
1656 1661
1657 // Create & start the HostProcess using these threads. 1662 // Create & start the HostProcess using these threads.
1658 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). 1663 // TODO(wez): The HostProcess holds a reference to itself until Shutdown().
1659 // Remove this hack as part of the multi-process refactoring. 1664 // Remove this hack as part of the multi-process refactoring.
1660 int exit_code = kSuccessExitCode; 1665 int exit_code = kSuccessExitCode;
1661 ShutdownWatchdog shutdown_watchdog( 1666 ShutdownWatchdog shutdown_watchdog(
1662 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1667 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1663 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); 1668 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1664 1669
1665 // Run the main (also UI) message loop until the host no longer needs it. 1670 // Run the main (also UI) message loop until the host no longer needs it.
1666 base::RunLoop().Run(); 1671 base::RunLoop().Run();
1667 1672
1668 return exit_code; 1673 return exit_code;
1669 } 1674 }
1670 1675
1671 } // namespace remoting 1676 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_native_messaging_host_main.cc ('k') | remoting/host/setup/me2me_native_messaging_host_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698