| Index: remoting/host/remoting_me2me_host.cc | 
| diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc | 
| index f0118d6e4ce72723d426a08f48db8b6f47ffca59..3d692d79a1e25a6c983e2cee1c41a6c4735543a9 100644 | 
| --- a/remoting/host/remoting_me2me_host.cc | 
| +++ b/remoting/host/remoting_me2me_host.cc | 
| @@ -4,8 +4,6 @@ | 
| // | 
| // This file implements a standalone host process for Me2Me. | 
|  | 
| -#include "remoting/host/remoting_me2me_host.h" | 
| - | 
| #include <string> | 
|  | 
| #include "base/at_exit.h" | 
| @@ -14,7 +12,6 @@ | 
| #include "base/command_line.h" | 
| #include "base/file_path.h" | 
| #include "base/file_util.h" | 
| -#include "base/logging.h" | 
| #include "base/memory/scoped_ptr.h" | 
| #include "base/message_loop.h" | 
| #include "base/scoped_native_library.h" | 
| @@ -1039,7 +1036,9 @@ void HostProcess::OnCrash(const std::string& function_name, | 
| CHECK(false); | 
| } | 
|  | 
| -int HostProcessMain(int argc, char** argv) { | 
| +}  // namespace remoting | 
| + | 
| +int main(int argc, char** argv) { | 
| #if defined(OS_MACOSX) | 
| // Needed so we don't leak objects when threads are created. | 
| base::mac::ScopedNSAutoreleasePool pool; | 
| @@ -1047,14 +1046,15 @@ int HostProcessMain(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(); | 
| +  // Initialize Breakpad as early as possible. On Windows, this happens in | 
| +  // WinMain(), so it shouldn't also be done here. 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(MAC_BREAKPAD) | 
| +  if (remoting::IsUsageStatsAllowed()) { | 
| +    remoting::InitializeCrashReporting(); | 
| } | 
| -#endif  // defined(OFFICIAL_BUILD) && (defined(MAC_BREAKPAD) || defined(OS_WIN)) | 
| +#endif  // MAC_BREAKPAD | 
|  | 
| // This object instance is required by Chrome code (for example, | 
| // LazyInstance, MessageLoop). | 
| @@ -1065,29 +1065,7 @@ int HostProcessMain(int argc, char** argv) { | 
| return 0; | 
| } | 
|  | 
| -  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) | 
| +  remoting::InitHostLogging(); | 
|  | 
| #if defined(TOOLKIT_GTK) | 
| // Required for any calls into GTK functions, such as the Disconnect and | 
| @@ -1103,18 +1081,18 @@ int HostProcessMain(int argc, char** argv) { | 
|  | 
| // Create the main message loop and start helper threads. | 
| MessageLoop message_loop(MessageLoop::TYPE_UI); | 
| -  scoped_ptr<ChromotingHostContext> context = | 
| -      ChromotingHostContext::Create( | 
| -          new AutoThreadTaskRunner(message_loop.message_loop_proxy(), | 
| -                                   MessageLoop::QuitClosure())); | 
| +  scoped_ptr<remoting::ChromotingHostContext> context = | 
| +      remoting::ChromotingHostContext::Create( | 
| +          new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), | 
| +                                             MessageLoop::QuitClosure())); | 
| if (!context) | 
| -    return kInitializationFailed; | 
| +    return remoting::kInitializationFailed; | 
|  | 
| // Create & start the HostProcess using these threads. | 
| // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). | 
| // Remove this hack as part of the multi-process refactoring. | 
| -  int exit_code = kSuccessExitCode; | 
| -  new HostProcess(context.Pass(), &exit_code); | 
| +  int exit_code = remoting::kSuccessExitCode; | 
| +  new remoting::HostProcess(context.Pass(), &exit_code); | 
|  | 
| // Run the main (also UI) message loop until the host no longer needs it. | 
| message_loop.Run(); | 
| @@ -1122,10 +1100,44 @@ int HostProcessMain(int argc, char** argv) { | 
| return exit_code; | 
| } | 
|  | 
| -}  // namespace remoting | 
| +#if defined(OS_WIN) | 
| +HMODULE g_hModule = NULL; | 
| + | 
| +int CALLBACK WinMain(HINSTANCE instance, | 
| +                     HINSTANCE previous_instance, | 
| +                     LPSTR command_line, | 
| +                     int show_command) { | 
| +#if defined(OFFICIAL_BUILD) | 
| +  if (remoting::IsUsageStatsAllowed()) { | 
| +    remoting::InitializeCrashReporting(); | 
| +  } | 
| +#endif  // OFFICIAL_BUILD | 
|  | 
| -#if !defined(OS_WIN) | 
| -int main(int argc, char** argv) { | 
| -  return remoting::HostProcessMain(argc, argv); | 
| +  g_hModule = instance; | 
| + | 
| +  // 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(); | 
| +  } | 
| + | 
| +  // 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); | 
| } | 
| -#endif  // !defined(OS_WIN) | 
| + | 
| +#endif  // defined(OS_WIN) | 
|  |