Bug 1630444: Part1 - Put LauncherError behind MOZ_USE_LAUNCHER_ERROR. r=aklotz

This patch defines a new macro `MOZ_USE_LAUNCHER_ERROR` and keeps
the use of `LauncherError` behind `MOZ_USE_LAUNCHER_ERROR` instead of
`MOZILLA_INTERNAL_API` so that we can selectively use `LauncherError`
in locations where `MOZILLA_INTERNAL_API` is defined.

Differential Revision: https://phabricator.services.mozilla.com/D83638
This commit is contained in:
Toshihito Kikuchi 2020-08-26 19:01:44 +00:00
parent 0e3344666e
commit 739b831899
9 changed files with 48 additions and 33 deletions

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "nsWindowsDllInterceptor.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Attributes.h"

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "LaunchUnelevated.h"
#include "mozilla/Assertions.h"

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "LauncherProcessWin.h"
#include <string.h>

View File

@ -16,6 +16,7 @@
# error "This header should only be included by freestanding code"
#endif // defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1
#define MOZ_USE_LAUNCHER_ERROR
#include "mozilla/NativeNt.h"
namespace mozilla {

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "freestanding/SafeThreadLocal.h"
#include "mozilla/NativeNt.h"

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include <stdio.h>
#include <stdlib.h>

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "mozilla/LauncherRegistryInfo.h"
#include "mozilla/NativeNt.h"
#include "mozilla/ScopeExit.h"

View File

@ -211,17 +211,7 @@ struct LauncherError {
bool operator!=(const WindowsError& aOther) const { return mError != aOther; }
};
#if defined(MOZILLA_INTERNAL_API)
template <typename T>
using LauncherResult = WindowsErrorResult<T>;
template <typename T>
using LauncherResultWithLineInfo = Result<T, LauncherError>;
using WindowsErrorType = WindowsError;
#else
#if defined(MOZ_USE_LAUNCHER_ERROR)
template <typename T>
using LauncherResult = Result<T, LauncherError>;
@ -231,32 +221,23 @@ using LauncherResultWithLineInfo = LauncherResult<T>;
using WindowsErrorType = LauncherError;
#endif // defined(MOZILLA_INTERNAL_API)
#else
template <typename T>
using LauncherResult = WindowsErrorResult<T>;
template <typename T>
using LauncherResultWithLineInfo = Result<T, LauncherError>;
using WindowsErrorType = WindowsError;
#endif // defined(MOZ_USE_LAUNCHER_ERROR)
using LauncherVoidResult = LauncherResult<Ok>;
using LauncherVoidResultWithLineInfo = LauncherResultWithLineInfo<Ok>;
#if defined(MOZILLA_INTERNAL_API)
# define LAUNCHER_ERROR_GENERIC() \
::mozilla::Err(::mozilla::WindowsError::CreateGeneric())
# define LAUNCHER_ERROR_FROM_WIN32(err) \
::mozilla::Err(::mozilla::WindowsError::FromWin32Error(err))
# define LAUNCHER_ERROR_FROM_LAST() \
::mozilla::Err(::mozilla::WindowsError::FromLastError())
# define LAUNCHER_ERROR_FROM_NTSTATUS(ntstatus) \
::mozilla::Err(::mozilla::WindowsError::FromNtStatus(ntstatus))
# define LAUNCHER_ERROR_FROM_HRESULT(hresult) \
::mozilla::Err(::mozilla::WindowsError::FromHResult(hresult))
# define LAUNCHER_ERROR_FROM_MOZ_WINDOWS_ERROR(err) ::mozilla::Err(err)
#else
#if defined(MOZ_USE_LAUNCHER_ERROR)
# define LAUNCHER_ERROR_GENERIC() \
::mozilla::Err(::mozilla::LauncherError( \
@ -282,7 +263,26 @@ using LauncherVoidResultWithLineInfo = LauncherResultWithLineInfo<Ok>;
# define LAUNCHER_ERROR_FROM_MOZ_WINDOWS_ERROR(err) \
::mozilla::Err(::mozilla::LauncherError(__FILE__, __LINE__, err))
#endif // defined(MOZILLA_INTERNAL_API)
#else
# define LAUNCHER_ERROR_GENERIC() \
::mozilla::Err(::mozilla::WindowsError::CreateGeneric())
# define LAUNCHER_ERROR_FROM_WIN32(err) \
::mozilla::Err(::mozilla::WindowsError::FromWin32Error(err))
# define LAUNCHER_ERROR_FROM_LAST() \
::mozilla::Err(::mozilla::WindowsError::FromLastError())
# define LAUNCHER_ERROR_FROM_NTSTATUS(ntstatus) \
::mozilla::Err(::mozilla::WindowsError::FromNtStatus(ntstatus))
# define LAUNCHER_ERROR_FROM_HRESULT(hresult) \
::mozilla::Err(::mozilla::WindowsError::FromHResult(hresult))
# define LAUNCHER_ERROR_FROM_MOZ_WINDOWS_ERROR(err) ::mozilla::Err(err)
#endif // defined(MOZ_USE_LAUNCHER_ERROR)
// How long to wait for a created process to become available for input,
// to prevent that process's windows being forced to the background.

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#define MOZ_USE_LAUNCHER_ERROR
#include "mozilla/UrlmonHeaderOnlyUtils.h"
#include "TestUrisToValidate.h"