Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 3a2c94b

Browse files
committed
Bug 1518639: Add boilerplate support for a windows remote client and server. r=jimm,froydnj
Adds build config and stubs for a windows implementation of the remote client and server. Differential Revision: https://phabricator.services.mozilla.com/D19074 --HG-- extra : source : abd7789e9637c92978efcf745361b98c5abf847a extra : intermediate-source : 276ca640adc8ff16ff3ff7252e8aa5016205b1e0
1 parent d16e7ca commit 3a2c94b

File tree

10 files changed

+145
-27
lines changed

10 files changed

+145
-27
lines changed

toolkit/components/moz.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ with Files('**'):
88
BUG_COMPONENT = ('Toolkit', 'General')
99

1010
# These component dirs are built for all apps (including suite)
11-
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
11+
if CONFIG['MOZ_HAS_REMOTE']:
1212
DIRS += ['remote']
1313

1414
DIRS += [

toolkit/components/remote/moz.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
2727
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
2828
CXXFLAGS += CONFIG['TK_CFLAGS']
2929

30+
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
31+
SOURCES += [
32+
'nsWinRemoteClient.cpp',
33+
'nsWinRemoteServer.cpp',
34+
]
35+
3036
LOCAL_INCLUDES += [
3137
'../../profile',
3238
]

toolkit/components/remote/nsRemoteService.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# include "nsDBusRemoteServer.h"
1818
# include "nsDBusRemoteClient.h"
1919
# endif
20+
#elif defined(XP_WIN)
21+
# include "nsWinRemoteServer.h"
22+
# include "nsWinRemoteClient.h"
2023
#endif
2124
#include "nsRemoteService.h"
2225

@@ -102,6 +105,11 @@ RemoteResult nsRemoteService::StartClient(const char* aDesktopStartupID) {
102105
if (useX11Remote) {
103106
client = new nsXRemoteClient();
104107
}
108+
#elif defined(XP_WIN)
109+
client = new nsWinRemoteClient();
110+
#else
111+
return REMOTE_NOT_FOUND;
112+
#endif
105113

106114
nsresult rv = client ? client->Init() : NS_ERROR_FAILURE;
107115
if (NS_FAILED(rv)) return REMOTE_NOT_FOUND;
@@ -122,9 +130,6 @@ RemoteResult nsRemoteService::StartClient(const char* aDesktopStartupID) {
122130
if (NS_FAILED(rv)) return REMOTE_NOT_FOUND;
123131

124132
return REMOTE_FOUND;
125-
#else
126-
return REMOTE_NOT_FOUND;
127-
#endif
128133
}
129134

130135
void nsRemoteService::StartupServer() {
@@ -147,6 +152,10 @@ void nsRemoteService::StartupServer() {
147152
if (useX11Remote) {
148153
mRemoteServer = MakeUnique<nsGTKRemoteServer>();
149154
}
155+
#elif defined(XP_WIN)
156+
mRemoteServer = MakeUnique<nsWinRemoteServer>();
157+
#else
158+
return;
150159
#endif
151160

152161
nsresult rv = mRemoteServer->Startup(mProgram.get(), mProfile.get());
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim:expandtab:shiftwidth=4:tabstop=4:
3+
*/
4+
/* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7+
8+
#include "nsWinRemoteClient.h"
9+
10+
nsresult nsWinRemoteClient::Init() {
11+
return NS_OK;
12+
}
13+
14+
nsresult nsWinRemoteClient::SendCommandLine(const char *aProgram, const char *aProfile,
15+
int32_t argc, char **argv,
16+
const char *aDesktopStartupID,
17+
char **aResponse, bool *aSucceeded) {
18+
*aSucceeded = false;
19+
return NS_OK;
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim:expandtab:shiftwidth=4:tabstop=4:
3+
*/
4+
/* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7+
8+
#ifndef nsWinRemoteClient_h__
9+
#define nsWinRemoteClient_h__
10+
11+
#include "nscore.h"
12+
#include "nsRemoteClient.h"
13+
14+
/**
15+
* Pure-virtual common base class for remoting implementations.
16+
*/
17+
18+
class nsWinRemoteClient : public nsRemoteClient {
19+
public:
20+
virtual ~nsWinRemoteClient() = default;
21+
22+
nsresult Init() override;
23+
24+
nsresult SendCommandLine(const char *aProgram, const char *aProfile,
25+
int32_t argc, char **argv,
26+
const char *aDesktopStartupID,
27+
char **aResponse, bool *aSucceeded) override;
28+
};
29+
30+
#endif // nsWinRemoteClient_h__
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim:expandtab:shiftwidth=2:tabstop=2:
3+
*/
4+
/* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7+
8+
#include "nsWinRemoteServer.h"
9+
10+
nsresult nsWinRemoteServer::Startup(const char* aAppName,
11+
const char* aProfileName) {
12+
return NS_OK;
13+
}
14+
15+
void nsWinRemoteServer::Shutdown() {
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim:expandtab:shiftwidth=2:tabstop=2:
3+
*/
4+
/* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7+
8+
#ifndef __nsWinRemoteServer_h__
9+
#define __nsWinRemoteServer_h__
10+
11+
#include "nsRemoteServer.h"
12+
13+
class nsWinRemoteServer final : public nsRemoteServer {
14+
public:
15+
nsWinRemoteServer() = default;
16+
~nsWinRemoteServer() override = default;
17+
18+
nsresult Startup(const char* aAppName, const char* aProfileName) override;
19+
void Shutdown() override;
20+
};
21+
22+
#endif // __nsWinRemoteService_h__

toolkit/moz.configure

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,3 +1652,14 @@ with only_when(compile_environment & target_is_windows):
16521652
set_config('MOZ_D3DCOMPILER_VISTA_DLL', d3d_compiler_dll.name,
16531653
when=d3d_compiler_dll.path)
16541654
set_config('MOZ_D3DCOMPILER_VISTA_DLL_PATH', d3d_compiler_dll.path)
1655+
1656+
# Remoting protocol support
1657+
# ==============================================================
1658+
1659+
@depends(toolkit)
1660+
def has_remote(toolkit):
1661+
if 'gtk' in toolkit or toolkit == 'windows':
1662+
return True
1663+
1664+
set_config('MOZ_HAS_REMOTE', has_remote)
1665+
set_define('MOZ_HAS_REMOTE', has_remote)

toolkit/xre/moz.build

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
9191
UNIFIED_SOURCES += [
9292
'nsNativeAppSupportUnix.cpp',
9393
]
94-
95-
LOCAL_INCLUDES += [
96-
'../components/remote',
97-
]
9894
else:
9995
UNIFIED_SOURCES += [
10096
'nsNativeAppSupportDefault.cpp',
10197
]
10298

99+
if CONFIG['MOZ_HAS_REMOTE']:
100+
LOCAL_INCLUDES += [
101+
'../components/remote',
102+
]
103+
103104
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
104105
UNIFIED_SOURCES += [
105106
'nsGDKErrorHandler.cpp',

toolkit/xre/nsAppRunner.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,8 @@
187187
#endif
188188

189189
// for X remote support
190-
#if defined(MOZ_WIDGET_GTK)
191-
# include "nsXRemoteClient.h"
190+
#if defined(MOZ_HAS_REMOTE)
192191
# include "nsRemoteService.h"
193-
# include "nsProfileLock.h"
194-
# include "SpecialSystemDirectory.h"
195-
# include <sched.h>
196-
# ifdef MOZ_ENABLE_DBUS
197-
# include "nsDBusRemoteClient.h"
198-
# endif
199192
#endif
200193

201194
#if defined(DEBUG) && defined(XP_WIN32)
@@ -310,6 +303,9 @@ void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) {
310303
# endif
311304
#endif // FUZZING
312305

306+
// Undo X11/X.h's definition of None
307+
#undef None
308+
313309
namespace mozilla {
314310
int (*RunGTest)(int*, char**) = 0;
315311
} // namespace mozilla
@@ -2854,9 +2850,12 @@ class XREMain {
28542850
XREMain()
28552851
: mStartOffline(false),
28562852
mShuttingDown(false)
2853+
#ifdef MOZ_HAS_REMOTE
2854+
,
2855+
mDisableRemote(false)
2856+
#endif
28572857
#if defined(MOZ_WIDGET_GTK)
28582858
,
2859-
mDisableRemote(false),
28602859
mGdkDisplay(nullptr)
28612860
#endif
28622861
{};
@@ -2878,7 +2877,7 @@ class XREMain {
28782877
nsCOMPtr<nsIFile> mProfD;
28792878
nsCOMPtr<nsIFile> mProfLD;
28802879
nsCOMPtr<nsIProfileLock> mProfileLock;
2881-
#if defined(MOZ_WIDGET_GTK)
2880+
#if defined(MOZ_HAS_REMOTE)
28822881
RefPtr<nsRemoteService> mRemoteService;
28832882
#endif
28842883

@@ -2890,7 +2889,7 @@ class XREMain {
28902889

28912890
bool mStartOffline;
28922891
bool mShuttingDown;
2893-
#if defined(MOZ_WIDGET_GTK)
2892+
#if defined(MOZ_HAS_REMOTE)
28942893
bool mDisableRemote;
28952894
#endif
28962895

@@ -3406,14 +3405,14 @@ int XREMain::XRE_mainInit(bool* aExitFlag) {
34063405
}
34073406
if (ar == ARG_FOUND) {
34083407
SaveToEnv("MOZ_NO_REMOTE=1");
3409-
#ifdef MOZ_WIDGET_GTK
3408+
#if defined(MOZ_HAS_REMOTE)
34103409
mDisableRemote = true;
34113410
} else if (EnvHasValue("MOZ_NO_REMOTE")) {
34123411
mDisableRemote = true;
34133412
#endif
34143413
}
34153414

3416-
#ifdef MOZ_WIDGET_GTK
3415+
#if defined(MOZ_HAS_REMOTE)
34173416
ar = CheckArg("new-instance", nullptr,
34183417
CheckArgFlag::CheckOSInt | CheckArgFlag::RemoveArg);
34193418
if (ar == ARG_BAD) {
@@ -3822,6 +3821,12 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
38223821
return result;
38233822
}
38243823

3824+
#ifdef MOZ_HAS_REMOTE
3825+
if (gfxPlatform::IsHeadless()) {
3826+
mDisableRemote = true;
3827+
}
3828+
#endif
3829+
38253830
#ifdef MOZ_X11
38263831
// Init X11 in thread-safe mode. Must be called prior to the first call to
38273832
// XOpenDisplay (called inside gdk_display_open). This is a requirement for
@@ -3892,11 +3897,9 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
38923897
gdk_display_manager_open_display(gdk_display_manager_get(), nullptr);
38933898
}
38943899
# endif
3895-
} else {
3896-
mDisableRemote = true;
38973900
}
38983901
#endif
3899-
#if defined(MOZ_WIDGET_GTK)
3902+
#if defined(MOZ_HAS_REMOTE)
39003903
// handle --remote now that xpcom is fired up
39013904
if (!mDisableRemote) {
39023905
mRemoteService = new nsRemoteService(gAppData->remotingName);
@@ -4025,7 +4028,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
40254028
return 1;
40264029
}
40274030

4028-
#if defined(MOZ_WIDGET_GTK)
4031+
#if defined(MOZ_HAS_REMOTE)
40294032
if (mRemoteService) {
40304033
// We want a unique profile name to identify the remote instance.
40314034
nsCString profileName;
@@ -4553,7 +4556,7 @@ nsresult XREMain::XRE_mainRun() {
45534556
}
45544557

45554558
if (!mShuttingDown) {
4556-
#if defined(MOZ_WIDGET_GTK)
4559+
#if defined(MOZ_HAS_REMOTE)
45574560
// if we have X remote support, start listening for requests on the
45584561
// proxy window.
45594562
if (mRemoteService) {
@@ -4761,7 +4764,7 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
47614764
}
47624765

47634766
if (!mShuttingDown) {
4764-
#if defined(MOZ_WIDGET_GTK)
4767+
#if defined(MOZ_HAS_REMOTE)
47654768
// shut down the x remote proxy window
47664769
if (mRemoteService) {
47674770
mRemoteService->ShutdownServer();

0 commit comments

Comments
 (0)