Skip to content

Commit d263400

Browse files
committed
Backed out 2 changesets (bug 1511078) for build bustages at Unified_cpp_toolkit_xre0.obj
Backed out changeset 61a47d6d5e26 (bug 1511078) Backed out changeset 006df494925a (bug 1511078) --HG-- rename : toolkit/xre/LauncherResult.h => browser/app/winlauncher/LauncherResult.h rename : mozglue/misc/NativeNt.h => browser/app/winlauncher/NativeNt.h rename : mozglue/tests/TestNativeNt.cpp => browser/app/winlauncher/test/TestNativeNt.cpp
1 parent 4ace331 commit d263400

23 files changed

+49
-1347
lines changed

browser/app/winlauncher/DllBlocklistWin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
66

7+
#include "NativeNt.h"
78
#include "nsWindowsDllInterceptor.h"
89
#include "mozilla/ArrayUtils.h"
910
#include "mozilla/Attributes.h"
10-
#include "mozilla/NativeNt.h"
1111
#include "mozilla/Types.h"
1212
#include "mozilla/WindowsDllBlocklist.h"
1313
#include "mozilla/WinHeaderOnlyUtils.h"

browser/app/winlauncher/DllBlocklistWin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <windows.h>
1111

12-
#include "mozilla/LauncherResult.h"
12+
#include "LauncherResult.h"
1313

1414
namespace mozilla {
1515

browser/app/winlauncher/ErrorHandler.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@
66

77
#include "ErrorHandler.h"
88

9-
#include "mozilla/LauncherRegistryInfo.h"
10-
119
namespace mozilla {
1210

1311
void HandleLauncherError(const LauncherError& aError) {
1412
// This is a placeholder error handler. We'll add telemetry and a fallback
1513
// error log in future revisions.
16-
17-
LauncherRegistryInfo regInfo;
18-
regInfo.DisableDueToFailure();
19-
2014
WindowsError::UniqueString msg = aError.mError.AsString();
2115
if (!msg) {
2216
return;

browser/app/winlauncher/ErrorHandler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#define mozilla_ErrorHandler_h
99

1010
#include "mozilla/Assertions.h"
11-
#include "mozilla/LauncherResult.h"
11+
12+
#include "LauncherResult.h"
1213

1314
namespace mozilla {
1415

browser/app/winlauncher/LaunchUnelevated.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
#include "mozilla/Assertions.h"
1010
#include "mozilla/CmdLineAndEnvUtils.h"
11-
#include "mozilla/LauncherResult.h"
1211
#include "mozilla/mscom/COMApartmentRegion.h"
1312
#include "mozilla/RefPtr.h"
1413
#include "nsWindowsHelpers.h"
1514

15+
#include "LauncherResult.h"
16+
1617
// For _bstr_t and _variant_t
1718
#include <comdef.h>
1819
#include <comutil.h>

browser/app/winlauncher/LaunchUnelevated.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define mozilla_LaunchUnelevated_h
99

1010
#include "LauncherProcessWin.h"
11-
#include "mozilla/LauncherResult.h"
11+
#include "LauncherResult.h"
1212
#include "mozilla/Maybe.h"
1313
#include "nsWindowsHelpers.h"
1414

browser/app/winlauncher/LauncherProcessWin.cpp

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "mozilla/CmdLineAndEnvUtils.h"
1414
#include "mozilla/DebugOnly.h"
1515
#include "mozilla/DynamicallyLinkedFunctionPtr.h"
16-
#include "mozilla/LauncherRegistryInfo.h"
17-
#include "mozilla/LauncherResult.h"
1816
#include "mozilla/Maybe.h"
1917
#include "mozilla/SafeMode.h"
2018
#include "mozilla/Sprintf.h" // For printf_stderr
@@ -28,6 +26,7 @@
2826

2927
#include "DllBlocklistWin.h"
3028
#include "ErrorHandler.h"
29+
#include "LauncherResult.h"
3130
#include "LaunchUnelevated.h"
3231
#include "ProcThreadAttributes.h"
3332

@@ -39,7 +38,7 @@
3938
* At this point the child process has been created in a suspended state. Any
4039
* additional startup work (eg, blocklist setup) should go here.
4140
*
42-
* @return Ok if browser startup should proceed
41+
* @return true if browser startup should proceed, otherwise false.
4342
*/
4443
static mozilla::LauncherVoidResult PostCreationSetup(HANDLE aChildProcess,
4544
HANDLE aChildMainThread,
@@ -145,14 +144,16 @@ static void MaybeBreakForBrowserDebugging() {
145144
::Sleep(pauseLenMs);
146145
}
147146

148-
static bool DoLauncherProcessChecks(int& argc, wchar_t** argv) {
147+
namespace mozilla {
148+
149+
bool RunAsLauncherProcess(int& argc, wchar_t** argv) {
149150
// NB: We run all tests in this function instead of returning early in order
150151
// to ensure that all side effects take place, such as clearing environment
151152
// variables.
152153
bool result = false;
153154

154155
#if defined(MOZ_LAUNCHER_PROCESS)
155-
mozilla::LauncherResult<bool> isSame = mozilla::IsSameBinaryAsParentProcess();
156+
LauncherResult<bool> isSame = IsSameBinaryAsParentProcess();
156157
if (isSame.isOk()) {
157158
result = !isSame.unwrap();
158159
} else {
@@ -165,47 +166,17 @@ static bool DoLauncherProcessChecks(int& argc, wchar_t** argv) {
165166
result = true;
166167
}
167168

168-
result |= mozilla::CheckArg(
169-
argc, argv, L"launcher", static_cast<const wchar_t**>(nullptr),
170-
mozilla::CheckArgFlag::RemoveArg) == mozilla::ARG_FOUND;
171-
172-
return result;
173-
}
174-
175-
namespace mozilla {
176-
177-
bool RunAsLauncherProcess(int& argc, wchar_t** argv) {
178-
LauncherRegistryInfo::ProcessType desiredType =
179-
DoLauncherProcessChecks(argc, argv)
180-
? LauncherRegistryInfo::ProcessType::Launcher
181-
: LauncherRegistryInfo::ProcessType::Browser;
182-
183-
// If we're looking at browser, return fast when we're a child process.
184-
if (desiredType == LauncherRegistryInfo::ProcessType::Browser &&
185-
mozilla::CheckArg(argc, argv, L"contentproc",
186-
static_cast<const wchar_t**>(nullptr),
187-
mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND) {
188-
return false;
189-
}
190-
191-
LauncherRegistryInfo regInfo;
192-
LauncherResult<LauncherRegistryInfo::ProcessType> runAsType =
193-
regInfo.Check(desiredType);
194-
195-
if (runAsType.isErr()) {
196-
HandleLauncherError(runAsType);
197-
// If there is an error, we should always fall back to returning false
198-
// for safety's sake.
199-
return false;
200-
}
169+
result |=
170+
CheckArg(argc, argv, L"launcher", static_cast<const wchar_t**>(nullptr),
171+
CheckArgFlag::RemoveArg) == ARG_FOUND;
201172

202-
if (runAsType.unwrap() == LauncherRegistryInfo::ProcessType::Browser) {
173+
if (!result) {
203174
// In this case, we will be proceeding to run as the browser.
204175
// We should check MOZ_DEBUG_BROWSER_* env vars.
205176
MaybeBreakForBrowserDebugging();
206177
}
207178

208-
return runAsType.unwrap() == LauncherRegistryInfo::ProcessType::Launcher;
179+
return result;
209180
}
210181

211182
int LauncherMain(int argc, wchar_t* argv[]) {

toolkit/xre/LauncherResult.h renamed to browser/app/winlauncher/LauncherResult.h

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,22 @@
1212

1313
namespace mozilla {
1414

15-
#if defined(MOZILLA_INTERNAL_API)
16-
17-
template <typename T>
18-
using LauncherResult = WindowsErrorResult<T>;
19-
20-
#else
21-
2215
struct LauncherError {
2316
LauncherError(const char* aFile, int aLine, WindowsError aWin32Error)
2417
: mFile(aFile), mLine(aLine), mError(aWin32Error) {}
2518

2619
const char* mFile;
2720
int mLine;
2821
WindowsError mError;
29-
30-
bool operator==(const LauncherError& aOther) const {
31-
return mError == aOther.mError;
32-
}
33-
34-
bool operator!=(const LauncherError& aOther) const {
35-
return mError != aOther.mError;
36-
}
37-
38-
bool operator==(const WindowsError& aOther) const { return mError == aOther; }
39-
40-
bool operator!=(const WindowsError& aOther) const { return mError != aOther; }
4122
};
4223

4324
template <typename T>
4425
using LauncherResult = Result<T, LauncherError>;
4526

46-
#endif // defined(MOZILLA_INTERNAL_API)
47-
48-
using LauncherVoidResult = LauncherResult<Ok>;
27+
using LauncherVoidResult = Result<Ok, LauncherError>;
4928

5029
} // namespace mozilla
5130

52-
#if defined(MOZILLA_INTERNAL_API)
53-
54-
#define LAUNCHER_ERROR_GENERIC() \
55-
::mozilla::Err(::mozilla::WindowsError::CreateGeneric())
56-
57-
#define LAUNCHER_ERROR_FROM_WIN32(err) \
58-
::mozilla::Err(::mozilla::WindowsError::FromWin32Error(err))
59-
60-
#define LAUNCHER_ERROR_FROM_LAST() \
61-
::mozilla::Err(::mozilla::WindowsError::FromLastError())
62-
63-
#define LAUNCHER_ERROR_FROM_NTSTATUS(ntstatus) \
64-
::mozilla::Err(::mozilla::WindowsError::FromNtStatus(ntstatus))
65-
66-
#define LAUNCHER_ERROR_FROM_HRESULT(hresult) \
67-
::mozilla::Err(::mozilla::WindowsError::FromHResult(hresult))
68-
69-
#else
70-
7131
#define LAUNCHER_ERROR_GENERIC() \
7232
::mozilla::Err(::mozilla::LauncherError( \
7333
__FILE__, __LINE__, ::mozilla::WindowsError::CreateGeneric()))
@@ -78,7 +38,8 @@ using LauncherVoidResult = LauncherResult<Ok>;
7838

7939
#define LAUNCHER_ERROR_FROM_LAST() \
8040
::mozilla::Err(::mozilla::LauncherError( \
81-
__FILE__, __LINE__, ::mozilla::WindowsError::FromLastError()))
41+
__FILE__, __LINE__, \
42+
::mozilla::WindowsError::FromWin32Error(::GetLastError())))
8243

8344
#define LAUNCHER_ERROR_FROM_NTSTATUS(ntstatus) \
8445
::mozilla::Err(::mozilla::LauncherError( \
@@ -88,14 +49,12 @@ using LauncherVoidResult = LauncherResult<Ok>;
8849
::mozilla::Err(::mozilla::LauncherError( \
8950
__FILE__, __LINE__, ::mozilla::WindowsError::FromHResult(hresult)))
9051

91-
// This macro wraps the supplied WindowsError with a LauncherError
92-
#define LAUNCHER_ERROR_FROM_MOZ_WINDOWS_ERROR(err) \
93-
::mozilla::Err(::mozilla::LauncherError(__FILE__, __LINE__, err))
94-
95-
#endif // defined(MOZILLA_INTERNAL_API)
96-
9752
// This macro enables moving of a mozilla::LauncherError from a
9853
// mozilla::LauncherResult<Foo> into a mozilla::LauncherResult<Bar>
9954
#define LAUNCHER_ERROR_FROM_RESULT(result) ::mozilla::Err(result.unwrapErr())
10055

56+
// This macro wraps the supplied WindowsError with a LauncherError
57+
#define LAUNCHER_ERROR_FROM_MOZ_WINDOWS_ERROR(err) \
58+
::mozilla::Err(::mozilla::LauncherError(__FILE__, __LINE__, err))
59+
10160
#endif // mozilla_LauncherResult_h

mozglue/misc/NativeNt.h renamed to browser/app/winlauncher/NativeNt.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
#ifndef mozilla_NativeNt_h
88
#define mozilla_NativeNt_h
99

10+
#if defined(MOZILLA_INTERNAL_API)
11+
#error \
12+
"This header is for initial process initialization. You don't want to be including this here."
13+
#endif // defined(MOZILLA_INTERNAL_API)
14+
1015
#include <stdint.h>
1116
#include <windows.h>
1217
#include <winnt.h>
1318
#include <winternl.h>
1419

1520
#include "mozilla/ArrayUtils.h"
1621
#include "mozilla/Attributes.h"
17-
#include "mozilla/LauncherResult.h"
1822

19-
// The declarations within this #if block are intended to be used for initial
20-
// process initialization ONLY. You probably don't want to be using these in
21-
// normal Gecko code!
22-
#if !defined(MOZILLA_INTERNAL_API)
23+
#include "LauncherResult.h"
2324

2425
extern "C" {
2526

@@ -79,13 +80,9 @@ VOID NTAPI RtlReleaseSRWLockExclusive(PSRWLOCK aLock);
7980

8081
} // extern "C"
8182

82-
#endif // !defined(MOZILLA_INTERNAL_API)
83-
8483
namespace mozilla {
8584
namespace nt {
8685

87-
#if !defined(MOZILLA_INTERNAL_API)
88-
8986
struct MemorySectionNameBuf : public _MEMORY_SECTION_NAME {
9087
MemorySectionNameBuf() {
9188
mSectionFileName.Length = 0;
@@ -205,8 +202,6 @@ inline void GetLeafName(PUNICODE_STRING aDestString,
205202
aDestString->MaximumLength = aDestString->Length;
206203
}
207204

208-
#endif // !defined(MOZILLA_INTERNAL_API)
209-
210205
inline char EnsureLowerCaseASCII(char aChar) {
211206
if (aChar >= 'A' && aChar <= 'Z') {
212207
aChar -= 'A' - 'a';

browser/app/winlauncher/SameBinary.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#ifndef mozilla_SameBinary_h
88
#define mozilla_SameBinary_h
99

10-
#include "mozilla/LauncherResult.h"
11-
#include "mozilla/NativeNt.h"
10+
#include "LauncherResult.h"
11+
#include "NativeNt.h"
1212
#include "nsWindowsHelpers.h"
1313

1414
namespace mozilla {

0 commit comments

Comments
 (0)