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

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

Issue 11970044: Merged all Chromoting Host code into remoting_core.dll (Windows). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Rebased. Debug is compilable. 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/remoting_me2me_host.h ('k') | remoting/host/verify_config_window_win.h » ('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 a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include "remoting/host/remoting_me2me_host.h"
8
7 #include <string> 9 #include <string>
8 10
9 #include "base/at_exit.h" 11 #include "base/at_exit.h"
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/callback.h" 13 #include "base/callback.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/file_path.h" 15 #include "base/file_path.h"
14 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 19 #include "base/message_loop.h"
17 #include "base/scoped_native_library.h" 20 #include "base/scoped_native_library.h"
18 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
19 #include "base/string_number_conversions.h" 22 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 23 #include "base/string_util.h"
21 #include "base/stringize_macros.h" 24 #include "base/stringize_macros.h"
22 #include "base/synchronization/waitable_event.h" 25 #include "base/synchronization/waitable_event.h"
23 #include "base/threading/thread.h" 26 #include "base/threading/thread.h"
24 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 NOTREACHED(); 1032 NOTREACHED();
1030 } 1033 }
1031 } 1034 }
1032 1035
1033 void HostProcess::OnCrash(const std::string& function_name, 1036 void HostProcess::OnCrash(const std::string& function_name,
1034 const std::string& file_name, 1037 const std::string& file_name,
1035 const int& line_number) { 1038 const int& line_number) {
1036 CHECK(false); 1039 CHECK(false);
1037 } 1040 }
1038 1041
1039 } // namespace remoting 1042 int HostProcessMain(int argc, char** argv) {
1040
1041 int main(int argc, char** argv) {
1042 #if defined(OS_MACOSX) 1043 #if defined(OS_MACOSX)
1043 // Needed so we don't leak objects when threads are created. 1044 // Needed so we don't leak objects when threads are created.
1044 base::mac::ScopedNSAutoreleasePool pool; 1045 base::mac::ScopedNSAutoreleasePool pool;
1045 #endif 1046 #endif
1046 1047
1047 CommandLine::Init(argc, argv); 1048 CommandLine::Init(argc, argv);
1048 1049
1049 // Initialize Breakpad as early as possible. On Windows, this happens in 1050 // Initialize Breakpad as early as possible. On Mac the command-line needs to
1050 // WinMain(), so it shouldn't also be done here. The command-line needs to be 1051 // be initialized first, so that the preference for crash-reporting can be
1051 // initialized first, so that the preference for crash-reporting can be looked 1052 // looked up in the config file.
1052 // up in the config file. 1053 #if defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
1053 #if defined(MAC_BREAKPAD) 1054 if (IsUsageStatsAllowed()) {
1054 if (remoting::IsUsageStatsAllowed()) { 1055 InitializeCrashReporting();
1055 remoting::InitializeCrashReporting();
1056 } 1056 }
1057 #endif // MAC_BREAKPAD 1057 #endif // defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN))
1058 1058
1059 // This object instance is required by Chrome code (for example, 1059 // This object instance is required by Chrome code (for example,
1060 // LazyInstance, MessageLoop). 1060 // LazyInstance, MessageLoop).
1061 base::AtExitManager exit_manager; 1061 base::AtExitManager exit_manager;
1062 1062
1063 if (CommandLine::ForCurrentProcess()->HasSwitch(kVersionSwitchName)) { 1063 if (CommandLine::ForCurrentProcess()->HasSwitch(kVersionSwitchName)) {
1064 printf("%s\n", STRINGIZE(VERSION)); 1064 printf("%s\n", STRINGIZE(VERSION));
1065 return 0; 1065 return 0;
1066 } 1066 }
1067 1067
1068 remoting::InitHostLogging(); 1068 InitHostLogging();
1069
1070 #if defined(OS_WIN)
1071 // Register and initialize common controls.
1072 INITCOMMONCONTROLSEX info;
1073 info.dwSize = sizeof(info);
1074 info.dwICC = ICC_STANDARD_CLASSES;
1075 InitCommonControlsEx(&info);
1076
1077 // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
1078 // N.B. This API exists on Vista and above.
1079 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1080 FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
1081 base::ScopedNativeLibrary user32(path);
1082 CHECK(user32.is_valid());
1083
1084 typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
1085 SetProcessDPIAwareFn set_process_dpi_aware =
1086 static_cast<SetProcessDPIAwareFn>(
1087 user32.GetFunctionPointer("SetProcessDPIAware"));
1088 set_process_dpi_aware();
1089 }
1090 #endif // defined(OS_WIN)
1069 1091
1070 #if defined(TOOLKIT_GTK) 1092 #if defined(TOOLKIT_GTK)
1071 // Required for any calls into GTK functions, such as the Disconnect and 1093 // Required for any calls into GTK functions, such as the Disconnect and
1072 // Continue windows, though these should not be used for the Me2Me case 1094 // Continue windows, though these should not be used for the Me2Me case
1073 // (crbug.com/104377). 1095 // (crbug.com/104377).
1074 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 1096 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
1075 gfx::GtkInitFromCommandLine(*cmd_line); 1097 gfx::GtkInitFromCommandLine(*cmd_line);
1076 #endif // TOOLKIT_GTK 1098 #endif // TOOLKIT_GTK
1077 1099
1078 // Enable support for SSL server sockets, which must be done while still 1100 // Enable support for SSL server sockets, which must be done while still
1079 // single-threaded. 1101 // single-threaded.
1080 net::EnableSSLServerSockets(); 1102 net::EnableSSLServerSockets();
1081 1103
1082 // Create the main message loop and start helper threads. 1104 // Create the main message loop and start helper threads.
1083 MessageLoop message_loop(MessageLoop::TYPE_UI); 1105 MessageLoop message_loop(MessageLoop::TYPE_UI);
1084 scoped_ptr<remoting::ChromotingHostContext> context = 1106 scoped_ptr<ChromotingHostContext> context =
1085 remoting::ChromotingHostContext::Create( 1107 ChromotingHostContext::Create(
1086 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), 1108 new AutoThreadTaskRunner(message_loop.message_loop_proxy(),
1087 MessageLoop::QuitClosure())); 1109 MessageLoop::QuitClosure()));
1088 if (!context) 1110 if (!context)
1089 return remoting::kInitializationFailed; 1111 return kInitializationFailed;
1090 1112
1091 // Create & start the HostProcess using these threads. 1113 // Create & start the HostProcess using these threads.
1092 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). 1114 // TODO(wez): The HostProcess holds a reference to itself until Shutdown().
1093 // Remove this hack as part of the multi-process refactoring. 1115 // Remove this hack as part of the multi-process refactoring.
1094 int exit_code = remoting::kSuccessExitCode; 1116 int exit_code = kSuccessExitCode;
1095 new remoting::HostProcess(context.Pass(), &exit_code); 1117 new HostProcess(context.Pass(), &exit_code);
1096 1118
1097 // Run the main (also UI) message loop until the host no longer needs it. 1119 // Run the main (also UI) message loop until the host no longer needs it.
1098 message_loop.Run(); 1120 message_loop.Run();
1099 1121
1100 return exit_code; 1122 return exit_code;
1101 } 1123 }
1102 1124
1103 #if defined(OS_WIN) 1125 } // namespace remoting
1104 HMODULE g_hModule = NULL;
1105 1126
1106 int CALLBACK WinMain(HINSTANCE instance, 1127 #if !defined(OS_WIN)
1107 HINSTANCE previous_instance, 1128 int main(int argc, char** argv) {
1108 LPSTR command_line, 1129 return remoting::HostProcessMain(argc, argv);
1109 int show_command) {
1110 #if defined(OFFICIAL_BUILD)
1111 if (remoting::IsUsageStatsAllowed()) {
1112 remoting::InitializeCrashReporting();
1113 }
1114 #endif // OFFICIAL_BUILD
1115
1116 g_hModule = instance;
1117
1118 // Register and initialize common controls.
1119 INITCOMMONCONTROLSEX info;
1120 info.dwSize = sizeof(info);
1121 info.dwICC = ICC_STANDARD_CLASSES;
1122 InitCommonControlsEx(&info);
1123
1124 // Mark the process as DPI-aware, so Windows won't scale coordinates in APIs.
1125 // N.B. This API exists on Vista and above.
1126 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1127 FilePath path(base::GetNativeLibraryName(UTF8ToUTF16("user32")));
1128 base::ScopedNativeLibrary user32(path);
1129 CHECK(user32.is_valid());
1130
1131 typedef BOOL (WINAPI * SetProcessDPIAwareFn)();
1132 SetProcessDPIAwareFn set_process_dpi_aware =
1133 static_cast<SetProcessDPIAwareFn>(
1134 user32.GetFunctionPointer("SetProcessDPIAware"));
1135 set_process_dpi_aware();
1136 }
1137
1138 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
1139 // the command line from GetCommandLineW(), so we can safely pass NULL here.
1140 return main(0, NULL);
1141 } 1130 }
1142 1131 #endif // !defined(OS_WIN)
1143 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.h ('k') | remoting/host/verify_config_window_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698