Skip to content

Commit

Permalink
Merged all Chromoting Host code into remoting_core.dll (Windows).
Browse files Browse the repository at this point in the history
Consolidated all installable Chromoting Host core into remoting_core.dll and converted all executables into thin wrappers around entry points exposed by remoting_core.dll. This reduces size of the installer by approximately 600KB.

This is the 2nd attempt to land this CL. It was previously reverted at r179322.

BUG=170200

Review URL: https://codereview.chromium.org/12088049

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179373 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
alexeypa@chromium.org committed Jan 29, 2013
1 parent 8c6ca86 commit 96ca5d7
Show file tree
Hide file tree
Showing 37 changed files with 678 additions and 643 deletions.
1 change: 1 addition & 0 deletions remoting/branding_Chrome
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DAEMON_FILE_NAME=Chrome Remote Desktop Host Service
DAEMON_DESCRIPTION=Chrome Remote Desktop Host Service
CONTROLLER_DESCRIPTION=Chrome Remote Desktop Host Controller
DESKTOP_DESCRIPTION=Chrome Remote Desktop Integration Process
CORE_DESCRIPTION=Chrome Remote Desktop Core
MAC_BUNDLE_ID=com.google.Chrome
MAC_CREATOR=rimZ
MAC_HOST_BUNDLE_ID=com.google.chrome_remote_desktop.remoting_me2me_host
Expand Down
1 change: 1 addition & 0 deletions remoting/branding_Chromium
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DAEMON_FILE_NAME=Chromoting Host Service
DAEMON_DESCRIPTION=Chromoting Host Service
CONTROLLER_DESCRIPTION=Chromoting Host Controller
DESKTOP_DESCRIPTION=Chromoting Integration Process
CORE_DESCRIPTION=Chromoting Core
MAC_BUNDLE_ID=org.chromium.Chromium
MAC_CREATOR=Cr24
MAC_HOST_BUNDLE_ID=org.chromium.chromoting.remoting_me2me_host
Expand Down
13 changes: 5 additions & 8 deletions remoting/host/continue_window_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@

#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/process_util.h"
#include "base/utf_string_conversions.h"
#include "remoting/host/host_ui_resource.h"
#include "remoting/host/ui_strings.h"
#include "remoting/host/win/core_resource.h"

// TODO(garykac): Lots of duplicated code in this file and
// disconnect_window_win.cc. These global floating windows are temporary so
// they should be deleted soon. If we need to expand this then we should
// create a class with the shared code.

// HMODULE from DllMain/WinMain. This is needed to find our dialog resource.
// This is defined in:
// Plugin: host_plugin.cc
// SimpleHost: simple_host_process.cc
extern HMODULE g_hModule;

namespace remoting {

class ContinueWindowWin : public ContinueWindow {
Expand Down Expand Up @@ -106,8 +101,10 @@ BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg,
void ContinueWindowWin::Show(const ContinueSessionCallback& callback) {
callback_ = callback;

HMODULE instance = base::GetModuleFromAddress(&DialogProc);

CHECK(!hwnd_);
hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL,
hwnd_ = CreateDialogParam(instance, MAKEINTRESOURCE(IDD_CONTINUE), NULL,
(DLGPROC)DialogProc, (LPARAM)this);
if (!hwnd_) {
LOG(ERROR) << "Unable to create Disconnect dialog for remoting.";
Expand Down
96 changes: 50 additions & 46 deletions remoting/host/desktop_process_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,33 +56,66 @@ void Usage(const 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;
#endif

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 =
command_line->GetSwitchValueASCII(kDaemonIpcSwitchName);

if (channel_name.empty()) {
Usage(command_line->GetProgram());
return remoting::kUsageExitCode;
return kUsageExitCode;
}

MessageLoop message_loop(MessageLoop::TYPE_UI);
Expand All @@ -89,56 +124,25 @@ 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);
if (!desktop_process.Start())
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) {
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)
17 changes: 17 additions & 0 deletions remoting/host/desktop_process_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_DESKTOP_PROCESS_MAIN_H_
#define REMOTING_HOST_DESKTOP_PROCESS_MAIN_H_

#include "remoting/host/host_export.h"

namespace remoting {

// The desktop process's entry point.
HOST_EXPORT int DesktopProcessMain(int argc, char** argv);

} // namespace remoting

#endif // REMOTING_HOST_DESKTOP_PROCESS_MAIN_H_
2 changes: 1 addition & 1 deletion remoting/host/disconnect_window_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
#include "base/win/scoped_select_object.h"
#include "remoting/host/host_ui_resource.h"
#include "remoting/host/ui_strings.h"
#include "remoting/host/win/core_resource.h"

// TODO(garykac): Lots of duplicated code in this file and
// continue_window_win.cc. If we need to expand this then we should
Expand Down
24 changes: 24 additions & 0 deletions remoting/host/host_export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_HOST_EXPORT_H_
#define REMOTING_HOST_HOST_EXPORT_H_

#if defined(WIN32)

#if defined(HOST_IMPLEMENTATION)
#define HOST_EXPORT __declspec(dllexport)
#else
#define HOST_EXPORT __declspec(dllimport)
#endif // defined(HOST_IMPLEMENTATION)

#else // !defined(WIN32)
#if defined(HOST_IMPLEMENTATION)
#define HOST_EXPORT __attribute__((visibility("default")))
#else
#define HOST_EXPORT
#endif // defined(HOST_IMPLEMENTATION)
#endif // !defined(WIN32)

#endif // REMOTING_HOST_HOST_EXPORT_H_
39 changes: 25 additions & 14 deletions remoting/host/installer/win/chromoting.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<?define OmahaAppid = "{b210701e-ffc4-49e3-932b-370728c72662}" ?>
<?define UpgradeCode = "2b21f767-e157-4fa6-963c-55834c1433a6" ?>

<?define CoreBinary = "remoting_core.dll" ?>

<?define ControllerAppid = "{4ff35d5e-d226-4550-9248-03e7779e67de}" ?>
<?define ControllerBinary = "remoting_controller.exe" ?>
<?define ControllerClass = "ElevatedController Class" ?>
Expand Down Expand Up @@ -136,6 +138,23 @@
Vital="yes"/>
</Component>

<Component Id="remoting_core" Guid="*">
<File Id="$(var.CoreBinary)"
DiskId="1"
KeyPath="yes"
Name="$(var.CoreBinary)"
Vital="yes"/>

<util:EventSource xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
Name="$(var.EventSourceName)"
Log="Application"
CategoryCount="1"
CategoryMessageFile="[#$(var.CoreBinary)]"
EventMessageFile="[#$(var.CoreBinary)]"
SupportsErrors="yes"
SupportsInformationals="yes"/>
</Component>

<?if $(var.RemotingMultiProcess) != 0 ?>
<Component Id="remoting_desktop" Guid="*">
<File Id="remoting_desktop.exe"
Expand Down Expand Up @@ -177,15 +196,6 @@
DiskId="1"
Name="remoting_host.exe"
Vital="yes"/>
<util:EventSource xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
Name="$(var.EventSourceName)"
Log="Application"
CategoryCount="1"
CategoryMessageFile="[#remoting_host.exe]"
EventMessageFile="[#remoting_host.exe]"
SupportsErrors="yes"
SupportsInformationals="yes"/>

<fire:FirewallException xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension"
Id="me2me_firewall_exception"
IgnoreFailure="yes"
Expand Down Expand Up @@ -273,7 +283,7 @@

<RegistryValue Type="string"
Name="LocalizedString"
Value="@[#$(var.ControllerBinary)],-100"/>
Value="@[binaries]$(var.CoreBinary),-103"/>

<RegistryKey Key="LocalServer32" Action="create">
<RegistryValue Type="string"
Expand Down Expand Up @@ -301,7 +311,7 @@
Value="1"/>
<RegistryValue Type="string"
Name="IconReference"
Value="@[#$(var.ControllerBinary)],-101"/>
Value="@[binaries]$(var.CoreBinary),-104"/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
Expand Down Expand Up @@ -340,7 +350,7 @@
<RegistryKey Key="0" Action="create">
<RegistryKey Key="win32" Action="create">
<RegistryValue Type="string"
Value="[#$(var.ControllerBinary)]"/>
Value="@[binaries]$(var.CoreBinary)"/>
</RegistryKey>
</RegistryKey>

Expand Down Expand Up @@ -437,10 +447,10 @@

<CustomAction Id="set_service_display_name"
Property="chromoting_service_display_name"
Value="@[binaries]remoting_daemon.exe,-101" />
Value="@[binaries]$(var.CoreBinary),-101" />
<CustomAction Id="set_service_description"
Property="chromoting_service_description"
Value="@[binaries]remoting_daemon.exe,-102" />
Value="@[binaries]$(var.CoreBinary),-102" />

<!-- XP does not support MUI strings in the service name and description, so
we fall back to plain strings on XP. -->
Expand All @@ -460,6 +470,7 @@
<ComponentRef Id="omaha_registration"/>
<?endif?>
<ComponentRef Id="remoting_controller"/>
<ComponentRef Id="remoting_core"/>
<ComponentRef Id="remoting_daemon"/>
<?if $(var.RemotingMultiProcess) != 0 ?>
<ComponentRef Id="remoting_desktop"/>
Expand Down
1 change: 1 addition & 0 deletions remoting/host/installer/win/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"sign": [
"remoting_controller.exe",
"remoting_core.dll",
"remoting_daemon.exe",
"remoting_desktop.exe",
"remoting_host.exe"
Expand Down
3 changes: 0 additions & 3 deletions remoting/host/plugin/host_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,9 @@ NPError SetWindow(NPP instance, NPWindow* pNPWindow) {
} // namespace

#if defined(OS_WIN)
HMODULE g_hModule = NULL;

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
switch (dwReason) {
case DLL_PROCESS_ATTACH:
g_hModule = hModule;
DisableThreadLibraryCalls(hModule);
break;
case DLL_PROCESS_DETACH:
Expand Down
Loading

0 comments on commit 96ca5d7

Please sign in to comment.