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

Unified Diff: remoting/host/desktop_process_main.cc

Issue 12189013: Relanding r180433, now without build/some.gyp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/desktop_process_main.h ('k') | remoting/host/disconnect_window_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/desktop_process_main.cc
diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc
index 85877f7019fcc2952ec93cdfeea12d1a10e3bddf..141d747fb4f74f5865bb1501851be99455107fd6 100644
--- a/remoting/host/desktop_process_main.cc
+++ b/remoting/host/desktop_process_main.cc
@@ -5,6 +5,8 @@
// This file implements the Windows service controlling Me2Me host processes
// running within user sessions.
+#include "remoting/host/desktop_process_main.h"
+
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -57,7 +59,9 @@ void Usage(const base::FilePath& program_name) {
} // namespace
-int main(int argc, char** argv) {
+namespace remoting {
+
+int DesktopProcessMain(int argc, char** argv) {
#if defined(OS_MACOSX)
// Needed so we don't leak objects when threads are created.
base::mac::ScopedNSAutoreleasePool pool;
@@ -65,17 +69,48 @@ int main(int argc, char** argv) {
CommandLine::Init(argc, argv);
+ // Initialize Breakpad as early as possible. On Mac the command-line needs to
+ // be initialized first, so that the preference for crash-reporting can be
+ // looked up in the config file.
+#if defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
+ if (IsUsageStatsAllowed()) {
+ InitializeCrashReporting();
+ }
+#endif // defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
+
// This object instance is required by Chrome code (for example,
// LazyInstance, MessageLoop).
base::AtExitManager exit_manager;
- remoting::InitHostLogging();
+ InitHostLogging();
+
+#if defined(OS_WIN)
+ // Register and initialize common controls.
+ INITCOMMONCONTROLSEX info;
+ info.dwSize = sizeof(info);
+ info.dwICC = ICC_STANDARD_CLASSES;
+ InitCommonControlsEx(&info);
+
+ // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
+ // N.B. This API exists on Vista and above.
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
+ FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
+ base::ScopedNativeLibrary user32(path);
+ CHECK(user32.is_valid());
+
+ typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
+ SetProcessDPIAwareFn set_process_dpi_aware =
+ static_cast<SetProcessDPIAwareFn>(
+ user32.GetFunctionPointer("SetProcessDPIAware"));
+ set_process_dpi_aware();
+ }
+#endif // defined(OS_WIN)
const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kHelpSwitchName) ||
command_line->HasSwitch(kQuestionSwitchName)) {
Usage(command_line->GetProgram());
- return remoting::kSuccessExitCode;
+ return kSuccessExitCode;
}
std::string channel_name =
@@ -83,7 +118,7 @@ int main(int argc, char** argv) {
if (channel_name.empty()) {
Usage(command_line->GetProgram());
- return remoting::kUsageExitCode;
+ return kUsageExitCode;
}
MessageLoop message_loop(MessageLoop::TYPE_UI);
@@ -92,69 +127,38 @@ int main(int argc, char** argv) {
base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask),
message_loop.message_loop_proxy(),
FROM_HERE, run_loop.QuitClosure());
- scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner =
- new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
- quit_ui_task_runner);
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
+ new AutoThreadTaskRunner(message_loop.message_loop_proxy(),
+ quit_ui_task_runner);
- remoting::DesktopProcess desktop_process(ui_task_runner, channel_name);
+ DesktopProcess desktop_process(ui_task_runner, channel_name);
// Create a platform-dependent environment factory.
- scoped_ptr<remoting::DesktopEnvironmentFactory> desktop_environment_factory;
+ scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory;
#if defined(OS_WIN)
desktop_environment_factory.reset(
- new remoting::SessionDesktopEnvironmentFactory(
- base::Bind(&remoting::DesktopProcess::InjectSas,
+ new SessionDesktopEnvironmentFactory(
+ base::Bind(&DesktopProcess::InjectSas,
desktop_process.AsWeakPtr())));
#else // !defined(OS_WIN)
desktop_environment_factory.reset(
- new remoting::BasicDesktopEnvironmentFactory(true));
+ new BasicDesktopEnvironmentFactory(true));
#endif // !defined(OS_WIN)
if (!desktop_process.Start(desktop_environment_factory.Pass()))
- return remoting::kInitializationFailed;
+ return kInitializationFailed;
// Run the UI message loop.
ui_task_runner = NULL;
run_loop.Run();
- return remoting::kSuccessExitCode;
+ return kSuccessExitCode;
}
-#if defined(OS_WIN)
-
-int CALLBACK WinMain(HINSTANCE instance,
- HINSTANCE previous_instance,
- LPSTR raw_command_line,
- int show_command) {
-#ifdef OFFICIAL_BUILD
- if (remoting::IsUsageStatsAllowed()) {
- remoting::InitializeCrashReporting();
- }
-#endif // OFFICIAL_BUILD
-
- // Register and initialize common controls.
- INITCOMMONCONTROLSEX info;
- info.dwSize = sizeof(info);
- info.dwICC = ICC_STANDARD_CLASSES;
- InitCommonControlsEx(&info);
-
- // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
- // N.B. This API exists on Vista and above.
- if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
- base::FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
- base::ScopedNativeLibrary user32(path);
- CHECK(user32.is_valid());
+} // namespace remoting
- typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
- SetProcessDPIAwareFn set_process_dpi_aware =
- static_cast<SetProcessDPIAwareFn>(
- user32.GetFunctionPointer("SetProcessDPIAware"));
- set_process_dpi_aware();
- }
-
- // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
- // the command line from GetCommandLineW(), so we can safely pass NULL here.
- return main(0, NULL);
+#if !defined(OS_WIN)
+int main(int argc, char** argv) {
+ return remoting::DesktopProcessMain(argc, argv);
}
-
-#endif // defined(OS_WIN)
+#endif // !defined(OS_WIN)
« no previous file with comments | « remoting/host/desktop_process_main.h ('k') | remoting/host/disconnect_window_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698