Move third_party/base/ptr_util.h to core/fxcrt

Bug: pdfium:2127
Change-Id: I6eaf8cc056cea7a1ad32f303358956637b627d0a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116731
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_linearized_header.cpp b/core/fpdfapi/parser/cpdf_linearized_header.cpp
index 051906c..1b4803d 100644
--- a/core/fpdfapi/parser/cpdf_linearized_header.cpp
+++ b/core/fpdfapi/parser/cpdf_linearized_header.cpp
@@ -16,8 +16,8 @@
 #include "core/fpdfapi/parser/cpdf_parser.h"
 #include "core/fpdfapi/parser/cpdf_syntax_parser.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/ptr_util.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/core/fpdfapi/parser/cpdf_object_stream.cpp b/core/fpdfapi/parser/cpdf_object_stream.cpp
index 16dc92c..9df80a5 100644
--- a/core/fpdfapi/parser/cpdf_object_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_object_stream.cpp
@@ -16,8 +16,8 @@
 #include "core/fpdfapi/parser/fpdf_parser_utility.h"
 #include "core/fxcrt/cfx_read_only_span_stream.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/ptr_util.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp
index f39e40b..cc4c2bd 100644
--- a/core/fpdfdoc/cpdf_nametree.cpp
+++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -16,9 +16,9 @@
 #include "core/fpdfapi/parser/cpdf_reference.h"
 #include "core/fpdfapi/parser/cpdf_string.h"
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/stl_util.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index a26692c..732bd07 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -15,9 +15,9 @@
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/fx_unicode.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/stl_util.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/core/fxcodec/gif/lzw_decompressor.cpp b/core/fxcodec/gif/lzw_decompressor.cpp
index 6261cc7..582cd65 100644
--- a/core/fxcodec/gif/lzw_decompressor.cpp
+++ b/core/fxcodec/gif/lzw_decompressor.cpp
@@ -13,7 +13,7 @@
 #include <utility>
 
 #include "core/fxcrt/fx_safe_types.h"
-#include "third_party/base/memory/ptr_util.h"
+#include "core/fxcrt/ptr_util.h"
 
 namespace fxcodec {
 
diff --git a/core/fxcodec/icc/icc_transform.cpp b/core/fxcodec/icc/icc_transform.cpp
index 9829248..15e7758 100644
--- a/core/fxcodec/icc/icc_transform.cpp
+++ b/core/fxcodec/icc/icc_transform.cpp
@@ -13,7 +13,7 @@
 
 #include "core/fxcrt/data_vector.h"
 #include "core/fxcrt/numerics/safe_conversions.h"
-#include "third_party/base/memory/ptr_util.h"
+#include "core/fxcrt/ptr_util.h"
 #include "third_party/base/notreached.h"
 
 namespace fxcodec {
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index 6ad10d8..d0a82ef 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -25,8 +25,8 @@
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/pauseindicator_iface.h"
+#include "core/fxcrt/ptr_util.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp b/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
index ad09cc1..59f928e 100644
--- a/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
+++ b/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
@@ -14,10 +14,10 @@
 #include "core/fxcodec/jpeg/jpeg_common.h"
 #include "core/fxcodec/scanlinedecoder.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxge/dib/cfx_dibbase.h"
 #include "core/fxge/dib/fx_dib.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 class CJpegContext final : public ProgressiveDecoderIface::Context {
  public:
diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp b/core/fxcodec/jpx/cjpx_decoder.cpp
index 9fb1b4b..85b0b48 100644
--- a/core/fxcodec/jpx/cjpx_decoder.cpp
+++ b/core/fxcodec/jpx/cjpx_decoder.cpp
@@ -16,9 +16,9 @@
 
 #include "core/fxcodec/jpx/jpx_decode_utils.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/span_util.h"
 #include "core/fxge/calculate_pitch.h"
-#include "third_party/base/memory/ptr_util.h"
 
 #if !defined(USE_SYSTEM_LIBOPENJPEG2)
 #include "third_party/libopenjpeg/opj_malloc.h"
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn
index 88d74f3..90b9ec7 100644
--- a/core/fxcrt/BUILD.gn
+++ b/core/fxcrt/BUILD.gn
@@ -98,6 +98,7 @@
     "observed_ptr.cpp",
     "observed_ptr.h",
     "pauseindicator_iface.h",
+    "ptr_util.h",
     "retain_ptr.h",
     "scoped_set_insertion.h",
     "shared_copy_on_write.h",
diff --git a/core/fxcrt/fx_folder_posix.cpp b/core/fxcrt/fx_folder_posix.cpp
index fb873be..7d83119 100644
--- a/core/fxcrt/fx_folder_posix.cpp
+++ b/core/fxcrt/fx_folder_posix.cpp
@@ -9,8 +9,8 @@
 #include <memory>
 
 #include "build/build_config.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/unowned_ptr.h"
-#include "third_party/base/memory/ptr_util.h"
 
 #if BUILDFLAG(IS_WIN)
 #error "built on wrong platform"
diff --git a/core/fxcrt/fx_folder_windows.cpp b/core/fxcrt/fx_folder_windows.cpp
index 6b19dde..40c9db0 100644
--- a/core/fxcrt/fx_folder_windows.cpp
+++ b/core/fxcrt/fx_folder_windows.cpp
@@ -9,7 +9,7 @@
 #include <memory>
 
 #include "build/build_config.h"
-#include "third_party/base/memory/ptr_util.h"
+#include "core/fxcrt/ptr_util.h"
 
 #if !BUILDFLAG(IS_WIN)
 #error "built on wrong platform"
diff --git a/third_party/base/memory/ptr_util.h b/core/fxcrt/ptr_util.h
similarity index 70%
rename from third_party/base/memory/ptr_util.h
rename to core/fxcrt/ptr_util.h
index c9df831..7fbaeae 100644
--- a/third_party/base/memory/ptr_util.h
+++ b/core/fxcrt/ptr_util.h
@@ -1,9 +1,9 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2024 The PDFium Authors
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef THIRD_PARTY_BASE_MEMORY_PTR_UTIL_H_
-#define THIRD_PARTY_BASE_MEMORY_PTR_UTIL_H_
+#ifndef CORE_FXCRT_PTR_UTIL_H_
+#define CORE_FXCRT_PTR_UTIL_H_
 
 #include <memory>
 
@@ -19,4 +19,4 @@
 
 }  // namespace pdfium
 
-#endif  // THIRD_PARTY_BASE_MEMORY_PTR_UTIL_H_
+#endif  // CORE_FXCRT_PTR_UTIL_H_
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 2407d68..c379351 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -32,6 +32,7 @@
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/numerics/safe_conversions.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/span.h"
 #include "core/fxcrt/stl_util.h"
 #include "core/fxge/cfx_defaultrenderdevice.h"
@@ -49,7 +50,6 @@
 #include "core/fxge/text_char_pos.h"
 #include "third_party/base/check.h"
 #include "third_party/base/check_op.h"
-#include "third_party/base/memory/ptr_util.h"
 #include "third_party/base/notreached.h"
 #include "third_party/skia/include/core/SkBlendMode.h"
 #include "third_party/skia/include/core/SkCanvas.h"
diff --git a/fpdfsdk/formfiller/cffl_perwindowdata.cpp b/fpdfsdk/formfiller/cffl_perwindowdata.cpp
index 85f6d03..8560160 100644
--- a/fpdfsdk/formfiller/cffl_perwindowdata.cpp
+++ b/fpdfsdk/formfiller/cffl_perwindowdata.cpp
@@ -6,8 +6,8 @@
 
 #include "fpdfsdk/formfiller/cffl_perwindowdata.h"
 
+#include "core/fxcrt/ptr_util.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
-#include "third_party/base/memory/ptr_util.h"
 
 CFFL_PerWindowData::CFFL_PerWindowData(CPDFSDK_Widget* pWidget,
                                        const CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index e22b029..0523fb3 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -34,13 +34,13 @@
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/fx_string_wrappers.h"
 #include "core/fxcrt/numerics/safe_conversions.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/stl_util.h"
 #include "core/fxge/cfx_color.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_helpers.h"
 #include "fpdfsdk/cpdfsdk_interactiveform.h"
 #include "third_party/base/check.h"
-#include "third_party/base/memory/ptr_util.h"
 
 namespace {
 
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index d612947..1507230 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -36,6 +36,7 @@
 #include "core/fxcrt/fx_stream.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/numerics/safe_conversions.h"
+#include "core/fxcrt/ptr_util.h"
 #include "core/fxcrt/span.h"
 #include "core/fxcrt/span_util.h"
 #include "core/fxcrt/stl_util.h"
@@ -53,7 +54,6 @@
 #include "fxjs/ijs_runtime.h"
 #include "public/fpdf_formfill.h"
 #include "third_party/base/check_op.h"
-#include "third_party/base/memory/ptr_util.h"
 
 #ifdef PDF_ENABLE_V8
 #include "fxjs/cfx_v8_array_buffer_allocator.h"
diff --git a/fxbarcode/cfx_barcode.cpp b/fxbarcode/cfx_barcode.cpp
index 5b2c134..f6a457d 100644
--- a/fxbarcode/cfx_barcode.cpp
+++ b/fxbarcode/cfx_barcode.cpp
@@ -8,6 +8,7 @@
 
 #include <memory>
 
+#include "core/fxcrt/ptr_util.h"
 #include "fxbarcode/cbc_codabar.h"
 #include "fxbarcode/cbc_code128.h"
 #include "fxbarcode/cbc_code39.h"
@@ -18,7 +19,6 @@
 #include "fxbarcode/cbc_pdf417i.h"
 #include "fxbarcode/cbc_qrcode.h"
 #include "fxbarcode/cbc_upca.h"
-#include "third_party/base/memory/ptr_util.h"
 #include "third_party/base/notreached.h"
 
 namespace {
diff --git a/fxjs/xfa/cfxjse_context.cpp b/fxjs/xfa/cfxjse_context.cpp
index 2fd4f70..ed900c5 100644
--- a/fxjs/xfa/cfxjse_context.cpp
+++ b/fxjs/xfa/cfxjse_context.cpp
@@ -8,6 +8,7 @@
 
 #include <utility>
 
+#include "core/fxcrt/ptr_util.h"
 #include "fxjs/cfxjs_engine.h"
 #include "fxjs/fxv8.h"
 #include "fxjs/xfa/cfxjse_class.h"
@@ -17,7 +18,6 @@
 #include "fxjs/xfa/cjx_object.h"
 #include "third_party/base/check.h"
 #include "third_party/base/check_op.h"
-#include "third_party/base/memory/ptr_util.h"
 #include "v8/include/v8-exception.h"
 #include "v8/include/v8-function.h"
 #include "v8/include/v8-message.h"
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 7ce0ee4..f3f56d7 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -556,7 +556,6 @@
     "base/check_op.h",
     "base/component_export.h",
     "base/immediate_crash.h",
-    "base/memory/ptr_util.h",
     "base/no_destructor.h",
     "base/notreached.h",
     "base/template_util.h",