Fix Windows build
Change-Id: I2d8d61ff28f72e249b5c700f9353c5d33e405282
diff --git a/base/BUILD b/base/BUILD
index d31df3e..9de3117 100644
--- a/base/BUILD
+++ b/base/BUILD
@@ -13,7 +13,10 @@
"strings/string_util_constants.cc",
"strings/utf_string_conversion_utils.cc",
"strings/utf_string_conversions.cc",
- ],
+ ] + select({
+ "//build_config:windows_x86_64": ["strings/string_util_win.cc"],
+ "//conditions:default": [],
+ }),
hdrs = [
"compiler_specific.h",
"containers/checked_iterators.h",
@@ -45,6 +48,9 @@
"strings/utf_string_conversion_utils.h",
] + build_config.strings_hdrs,
copts = build_config.default_copts,
+ textual_hdrs = [
+ "win/win_handle_types_list.inc",
+ ],
visibility = ["//visibility:public"],
deps = [
"//base/third_party/icu",
diff --git a/base/memory/raw_ptr.h b/base/memory/raw_ptr.h
index 379c0d8..16094d3 100644
--- a/base/memory/raw_ptr.h
+++ b/base/memory/raw_ptr.h
@@ -31,7 +31,7 @@
#endif // BUILDFLAG(USE_BACKUP_REF_PTR)
#if BUILDFLAG(IS_WIN)
-#include "base/win/windows_types.h"
+#include <windows.h>
#endif
// Marks a field as excluded from the raw_ptr usage enforcement clang plugin.
diff --git a/base/strings/string_number_conversions.h b/base/strings/string_number_conversions.h
index 1ef1733..7d1b0b5 100644
--- a/base/strings/string_number_conversions.h
+++ b/base/strings/string_number_conversions.h
@@ -150,7 +150,7 @@
} // namespace base
#if BUILDFLAG(IS_WIN)
-#include "base/strings/string_number_conversions_win.h"
+
#endif
#endif // BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_
diff --git a/base/strings/string_number_conversions_win.cc b/base/strings/string_number_conversions_win.cc
index 381f99d..da67ca2 100644
--- a/base/strings/string_number_conversions_win.cc
+++ b/base/strings/string_number_conversions_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/strings/string_number_conversions_win.h"
+
#include <string>
diff --git a/base/win/win_handle_types_list.inc b/base/win/win_handle_types_list.inc
new file mode 100644
index 0000000..b1dbef6
--- /dev/null
+++ b/base/win/win_handle_types_list.inc
@@ -0,0 +1,25 @@
+// Copyright 2021 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.
+
+// This file intentionally does not have header guards, it's included
+// inside a macro to generate enum values. The following line silences a
+// presubmit and Tricium warning that would otherwise be triggered by this:
+// no-include-guard-because-multiply-included
+// NOLINT(build/header_guard)
+
+// This file contains the list of Windows handle types that can be recognized
+// via specific pointee types declared in //base/win/windows_types.h
+// (e.g. `HDC` points to a fake/forward-declared `HDC__` struct).
+
+CHROME_WINDOWS_HANDLE_TYPE(HDC)
+CHROME_WINDOWS_HANDLE_TYPE(HDESK)
+CHROME_WINDOWS_HANDLE_TYPE(HGLRC)
+CHROME_WINDOWS_HANDLE_TYPE(HICON)
+CHROME_WINDOWS_HANDLE_TYPE(HINSTANCE)
+CHROME_WINDOWS_HANDLE_TYPE(HKEY)
+CHROME_WINDOWS_HANDLE_TYPE(HKL)
+CHROME_WINDOWS_HANDLE_TYPE(HMENU)
+CHROME_WINDOWS_HANDLE_TYPE(HWINSTA)
+CHROME_WINDOWS_HANDLE_TYPE(HWND)
+CHROME_WINDOWS_HANDLE_TYPE(HMONITOR)
diff --git a/copy.bara.sky b/copy.bara.sky
index 0f78461..44173d6 100644
--- a/copy.bara.sky
+++ b/copy.bara.sky
@@ -33,6 +33,7 @@
"base/strings/*.h",
"base/template_util.h",
"base/third_party/icu/**",
+ "base/win/win_handle_types_list.inc",
"build/build_config.h",
"build/buildflag.h",
"url/*.cc",
@@ -71,7 +72,6 @@
"base/debug/alias.h",
"base/export_template.h",
"base/logging.h",
- "base/metrics/histogram_macros.h",
"base/notreached.h",
"base/trace_event/memory_usage_estimator.h",
"third_party/perfetto/include/perfetto/tracing/traced_value.h",
@@ -101,6 +101,9 @@
# Fix some Perfetto includes.
core.replace("perfetto/tracing/traced_value_forward.h", "perfetto/tracing/traced_value.h"),
+ core.replace("#include \"base/win/windows_types.h\"", "#include <windows.h>"),
+ core.replace("#include \"base/strings/string_number_conversions_win.h\"", ""),
+
# Use system ICU.
core.replace(
'"third_party/icu/source/common/unicode/${file}.h"',