Reland "Remove Windows.h from some PA header files"
This is a reland of0aa06f9cce
The initial land of this change was broken on non-component x86 builds, which is a combination not tested on the CQ. The problem was that allocator_shim_default_dispatch_to_partition_alloc.cc was depending on having windows.h included but wasn't including it. This is now fixed and a full non-component x86 build was done to look for other issues. Original change's description: > Remove Windows.h from some PA header files > > While this change was intended mostly to enable future reductions in > how many translation units include Windows.h this change actually > reduced the count by 1,260 (from 18,045 to 16,785 translation units in a > test build of chrome). Savings were mostly in third_party/blink (869), > services/network (63), and miscellaneous. > > Some partition alloc header files end up being included by a huge number > of translation units so they need to be as lean as possible. In > particular they shouldn't include Windows.h. This change uses > windows_types.h to remove includes of Windows.h from three header files. > These header files are then also included from win_includes_unittests.cc > to make sure that they continue to avoid Windows.h, but oom.h currently > cannot be included from there. > > When removing Windows.h includes from .h files I inevitably find some > .cc files that need Windows.h includes and were getting it from the > headers, so those were added (IWYU). > > A definition for SRWLOCK_INIT was needed and this definition has to > perfectly match the one in winnt.h, which unfortunately has a lot of > trailing spaces. Sorry. > > Chrome has numerous dependencies on the defines that add 'A' or 'W' to > function names. This change exposed the fact that some translation units > were depending on a #define that remapped GetClassName to GetClassNameW. > The standard fix for that is to add the define to windows_types.h so > that it is more cheaply available everywhere (because defining it > nowhere tends to be a trickier problem). Unfortunately this then caused > problems in ui/aura/window.cc. This file had previously handled > GetClassName with an undef but that no longer works. Sorry. > > Bug:1220098
> Change-Id: I84077e52dce6fde59533ccc33fb0e8110b1d2f42 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2967044 > Reviewed-by: Avi Drissman <avi@chromium.org> > Reviewed-by: Chris Palmer <palmer@chromium.org> > Commit-Queue: Bruce Dawson <brucedawson@chromium.org> > Cr-Commit-Position: refs/heads/master@{#893583} Bug:1220098
Change-Id: Ie740353f88bd930e697963c19e971323bbbf8a80 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2971056 Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Wez <wez@chromium.org> Reviewed-by: Chris Palmer <palmer@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Commit-Position: refs/heads/master@{#893894}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
70562e1ae5
commit
7e74d0e28b
@ -27,6 +27,10 @@
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN) && defined(ARCH_CPU_X86)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using base::allocator::AllocatorDispatch;
|
||||
|
||||
namespace {
|
||||
|
@ -11,10 +11,6 @@
|
||||
#include "base/process/memory.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
// The crash is generated in a NOINLINE function so that we can classify the
|
||||
// crash as an OOM solely by analyzing the stack trace. It is tagged as
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "wow64apiset.h"
|
||||
#endif
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "base/win/windows_types.h"
|
||||
#endif
|
||||
|
||||
// Barebones TLS implementation for use in PartitionAlloc. This doesn't use the
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "base/allocator/partition_allocator/partition_tls.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include "base/allocator/partition_allocator/partition_alloc_check.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(PA_HAS_SPINNING_MUTEX)
|
||||
|
||||
#if defined(PA_HAS_LINUX_KERNEL)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "base/win/windows_types.h"
|
||||
#endif
|
||||
|
||||
#if defined(PA_HAS_SPINNING_MUTEX)
|
||||
@ -69,7 +69,7 @@ class LOCKABLE BASE_EXPORT SpinningMutex {
|
||||
|
||||
std::atomic<int32_t> state_{kUnlocked};
|
||||
#else
|
||||
SRWLOCK lock_ = SRWLOCK_INIT;
|
||||
CHROME_SRWLOCK lock_ = SRWLOCK_INIT;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
// This file ensures that these header files don't include Windows.h and can
|
||||
// compile without including Windows.h. This helps to improve compile times.
|
||||
|
||||
#include "base/allocator/partition_allocator/partition_alloc-inl.h"
|
||||
#include "base/allocator/partition_allocator/partition_tls.h"
|
||||
#include "base/allocator/partition_allocator/spinning_mutex.h"
|
||||
#include "base/atomicops.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/platform_file.h"
|
||||
|
@ -208,6 +208,11 @@ struct CHROME_CONDITION_VARIABLE {
|
||||
& \
|
||||
(~SYNCHRONIZE))
|
||||
|
||||
// The trailing white-spaces after this macro are required, for compatibility
|
||||
// with the definition in winnt.h.
|
||||
#define RTL_SRWLOCK_INIT {0} // NOLINT
|
||||
#define SRWLOCK_INIT RTL_SRWLOCK_INIT
|
||||
|
||||
// clang-format on
|
||||
|
||||
// Define some macros needed when prototyping Windows functions.
|
||||
@ -232,6 +237,9 @@ WINUSERAPI BOOL WINAPI GetMessageW(_Out_ LPMSG lpMsg,
|
||||
// Needed for thread_local_storage.h
|
||||
WINBASEAPI LPVOID WINAPI TlsGetValue(_In_ DWORD dwTlsIndex);
|
||||
|
||||
WINBASEAPI BOOL WINAPI TlsSetValue(_In_ DWORD dwTlsIndex,
|
||||
_In_opt_ LPVOID lpTlsValue);
|
||||
|
||||
// Needed for scoped_handle.h
|
||||
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI
|
||||
GetLastError(VOID);
|
||||
@ -264,6 +272,7 @@ WINBASEAPI HLOCAL WINAPI LocalFree(_In_ HLOCAL hMem);
|
||||
#define DrawText DrawTextW
|
||||
#define FindFirstFile FindFirstFileW
|
||||
#define FindNextFile FindNextFileW
|
||||
#define GetClassName GetClassNameW
|
||||
#define GetComputerName GetComputerNameW
|
||||
#define GetCurrentDirectory GetCurrentDirectoryW
|
||||
#define GetCurrentTime() GetTickCount()
|
||||
|
@ -1747,9 +1747,6 @@ void Window::SetVisible(bool visible) {
|
||||
// Changed notification is handled in SetVisibleInternal().
|
||||
}
|
||||
|
||||
// Under Windows this macro is defined.
|
||||
#undef GetClassName
|
||||
|
||||
BEGIN_METADATA_BASE(Window)
|
||||
ADD_READONLY_PROPERTY_METADATA(gfx::Rect, ActualBoundsInRootWindow)
|
||||
ADD_READONLY_PROPERTY_METADATA(gfx::Rect, ActualBoundsInScreen)
|
||||
|
Reference in New Issue
Block a user