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

Side by Side Diff: remoting/host/desktop_process_main.cc

Issue 12179013: Revert 180433 because build\some.gyp was added to the CL by mistake. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/desktop_process_main.h ('k') | remoting/host/disconnect_window_win.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 (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 the Windows service controlling Me2Me host processes 5 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions. 6 // running within user sessions.
7 7
8 #include "remoting/host/desktop_process_main.h"
9
10 #include "base/at_exit.h" 8 #include "base/at_exit.h"
11 #include "base/bind.h" 9 #include "base/bind.h"
12 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 11 #include "base/command_line.h"
14 #include "base/file_path.h" 12 #include "base/file_path.h"
15 #include "base/message_loop.h" 13 #include "base/message_loop.h"
16 #include "base/run_loop.h" 14 #include "base/run_loop.h"
17 #include "base/scoped_native_library.h" 15 #include "base/scoped_native_library.h"
18 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
(...skipping 29 matching lines...) Expand all
49 "Options:\n" 47 "Options:\n"
50 " --help, --? - Print this message.\n"; 48 " --help, --? - Print this message.\n";
51 49
52 void Usage(const base::FilePath& program_name) { 50 void Usage(const base::FilePath& program_name) {
53 std::string display_name = UTF16ToUTF8(program_name.LossyDisplayName()); 51 std::string display_name = UTF16ToUTF8(program_name.LossyDisplayName());
54 LOG(INFO) << StringPrintf(kUsageMessage, display_name.c_str()); 52 LOG(INFO) << StringPrintf(kUsageMessage, display_name.c_str());
55 } 53 }
56 54
57 } // namespace 55 } // namespace
58 56
59 namespace remoting { 57 int main(int argc, char** argv) {
60
61 int DesktopProcessMain(int argc, char** argv) {
62 #if defined(OS_MACOSX) 58 #if defined(OS_MACOSX)
63 // Needed so we don't leak objects when threads are created. 59 // Needed so we don't leak objects when threads are created.
64 base::mac::ScopedNSAutoreleasePool pool; 60 base::mac::ScopedNSAutoreleasePool pool;
65 #endif 61 #endif
66 62
67 CommandLine::Init(argc, argv); 63 CommandLine::Init(argc, argv);
68 64
69 // Initialize Breakpad as early as possible. On Mac the command-line needs to
70 // be initialized first, so that the preference for crash-reporting can be
71 // looked up in the config file.
72 #if defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
73 if (IsUsageStatsAllowed()) {
74 InitializeCrashReporting();
75 }
76 #endif // defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
77
78 // This object instance is required by Chrome code (for example, 65 // This object instance is required by Chrome code (for example,
79 // LazyInstance, MessageLoop). 66 // LazyInstance, MessageLoop).
80 base::AtExitManager exit_manager; 67 base::AtExitManager exit_manager;
81 68
82 InitHostLogging(); 69 remoting::InitHostLogging();
83
84 #if defined(OS_WIN)
85 // Register and initialize common controls.
86 INITCOMMONCONTROLSEX info;
87 info.dwSize = sizeof(info);
88 info.dwICC = ICC_STANDARD_CLASSES;
89 InitCommonControlsEx(&info);
90
91 // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
92 // N.B. This API exists on Vista and above.
93 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
94 FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
95 base::ScopedNativeLibrary user32(path);
96 CHECK(user32.is_valid());
97
98 typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
99 SetProcessDPIAwareFn set_process_dpi_aware =
100 static_cast<SetProcessDPIAwareFn>(
101 user32.GetFunctionPointer("SetProcessDPIAware"));
102 set_process_dpi_aware();
103 }
104 #endif // defined(OS_WIN)
105 70
106 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 71 const CommandLine* command_line = CommandLine::ForCurrentProcess();
107 if (command_line->HasSwitch(kHelpSwitchName) || 72 if (command_line->HasSwitch(kHelpSwitchName) ||
108 command_line->HasSwitch(kQuestionSwitchName)) { 73 command_line->HasSwitch(kQuestionSwitchName)) {
109 Usage(command_line->GetProgram()); 74 Usage(command_line->GetProgram());
110 return kSuccessExitCode; 75 return remoting::kSuccessExitCode;
111 } 76 }
112 77
113 std::string channel_name = 78 std::string channel_name =
114 command_line->GetSwitchValueASCII(kDaemonIpcSwitchName); 79 command_line->GetSwitchValueASCII(kDaemonIpcSwitchName);
115 80
116 if (channel_name.empty()) { 81 if (channel_name.empty()) {
117 Usage(command_line->GetProgram()); 82 Usage(command_line->GetProgram());
118 return kUsageExitCode; 83 return remoting::kUsageExitCode;
119 } 84 }
120 85
121 MessageLoop message_loop(MessageLoop::TYPE_UI); 86 MessageLoop message_loop(MessageLoop::TYPE_UI);
122 base::RunLoop run_loop; 87 base::RunLoop run_loop;
123 base::Closure quit_ui_task_runner = base::Bind( 88 base::Closure quit_ui_task_runner = base::Bind(
124 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), 89 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask),
125 message_loop.message_loop_proxy(), 90 message_loop.message_loop_proxy(),
126 FROM_HERE, run_loop.QuitClosure()); 91 FROM_HERE, run_loop.QuitClosure());
127 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = 92 scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner =
128 new AutoThreadTaskRunner(message_loop.message_loop_proxy(), 93 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
129 quit_ui_task_runner); 94 quit_ui_task_runner);
130 95
131 DesktopProcess desktop_process(ui_task_runner, channel_name); 96 remoting::DesktopProcess desktop_process(ui_task_runner, channel_name);
132 if (!desktop_process.Start()) 97 if (!desktop_process.Start())
133 return kInitializationFailed; 98 return remoting::kInitializationFailed;
134 99
135 // Run the UI message loop. 100 // Run the UI message loop.
136 ui_task_runner = NULL; 101 ui_task_runner = NULL;
137 run_loop.Run(); 102 run_loop.Run();
138 103
139 return kSuccessExitCode; 104 return remoting::kSuccessExitCode;
140 } 105 }
141 106
142 } // namespace remoting 107 #if defined(OS_WIN)
143 108
144 #if !defined(OS_WIN) 109 int CALLBACK WinMain(HINSTANCE instance,
145 int main(int argc, char** argv) { 110 HINSTANCE previous_instance,
146 return remoting::DesktopProcessMain(argc, argv); 111 LPSTR raw_command_line,
112 int show_command) {
113 #ifdef OFFICIAL_BUILD
114 if (remoting::IsUsageStatsAllowed()) {
115 remoting::InitializeCrashReporting();
116 }
117 #endif // OFFICIAL_BUILD
118
119 // Register and initialize common controls.
120 INITCOMMONCONTROLSEX info;
121 info.dwSize = sizeof(info);
122 info.dwICC = ICC_STANDARD_CLASSES;
123 InitCommonControlsEx(&info);
124
125 // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
126 // N.B. This API exists on Vista and above.
127 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
128 base::FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
129 base::ScopedNativeLibrary user32(path);
130 CHECK(user32.is_valid());
131
132 typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
133 SetProcessDPIAwareFn set_process_dpi_aware =
134 static_cast<SetProcessDPIAwareFn>(
135 user32.GetFunctionPointer("SetProcessDPIAware"));
136 set_process_dpi_aware();
137 }
138
139 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
140 // the command line from GetCommandLineW(), so we can safely pass NULL here.
141 return main(0, NULL);
147 } 142 }
148 #endif // !defined(OS_WIN) 143
144 #endif // defined(OS_WIN)
OLDNEW
« 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