Automated commit: libchrome r1158052 uprev

Merge with upstream commit a8ea3a1befe68221ccfa4091271bebd005f6ac21

BUG=None
TEST=sudo emerge libchrome

Change-Id: I12b390017d33fcd3287d3401bac0b35dd9a3240b
diff --git a/BASE_VER b/BASE_VER
index 36e6b08..f2b4fbc 100644
--- a/BASE_VER
+++ b/BASE_VER
@@ -1 +1 @@
-1157444
+1158052
diff --git a/base/allocator/allocator.gni b/base/allocator/allocator.gni
index 03dc889..3c012c1 100644
--- a/base/allocator/allocator.gni
+++ b/base/allocator/allocator.gni
@@ -3,28 +3,6 @@
 # found in the LICENSE file.
 
 import("//base/allocator/partition_allocator/partition_alloc.gni")
-import("//build_overrides/partition_alloc.gni")
-
-if (is_ios) {
-  import("//build/config/ios/ios_sdk.gni")
-}
-
-declare_args() {
-  # Causes all the allocations to be routed via allocator_shim.cc.
-  use_allocator_shim = use_allocator_shim_default
-}
-
-assert(
-    !use_allocator_shim || is_linux || is_chromeos || is_android || is_win ||
-        is_fuchsia || is_apple,
-    "use_allocator_shim works only on Android, iOS, Linux, macOS, Fuchsia, " +
-        "and Windows.")
-
-if (is_win && use_allocator_shim) {
-  # TODO(crbug.com/1245317): Add a comment indicating why the shim doesn't work.
-  assert(!is_component_build,
-         "The allocator shim doesn't work for the component build on Windows.")
-}
 
 # Chromium-specific asserts. External embedders _may_ elect to use these
 # features even without PA-E.
diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc
index 40c403e..74369ca 100644
--- a/base/allocator/partition_alloc_support.cc
+++ b/base/allocator/partition_alloc_support.cc
@@ -40,6 +40,7 @@
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
+#include "base/pending_task.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
@@ -512,11 +513,13 @@
       "base::RefCountedThreadSafe<>::Release()",
 
       // Windows signatures
-      "internal::RawPtrBackupRefImpl<0>::ReleaseInternal",
+      "internal::RawPtrBackupRefImpl<0,0>::ReleaseInternal",
+      "internal::RawPtrBackupRefImpl<0,1>::ReleaseInternal",
       "_free_base",
 
       // Mac signatures
-      "internal::RawPtrBackupRefImpl<false>::ReleaseInternal",
+      "internal::RawPtrBackupRefImpl<false, false>::ReleaseInternal",
+      "internal::RawPtrBackupRefImpl<false, true>::ReleaseInternal",
 
       // Task traces are prefixed with "Task trace:" in
       // |TaskTrace::OutputToStream|
@@ -612,6 +615,16 @@
       ExtractDanglingPtrSignature(release_task_trace).c_str());
 }
 
+bool operator==(const debug::TaskTrace& lhs, const debug::TaskTrace& rhs) {
+  // Compare the addresses contained in the task traces.
+  // The task traces are at most |PendingTask::kTaskBacktraceLength| long.
+  std::array<const void*, PendingTask::kTaskBacktraceLength> addresses_lhs = {};
+  std::array<const void*, PendingTask::kTaskBacktraceLength> addresses_rhs = {};
+  lhs.GetAddresses(addresses_lhs);
+  rhs.GetAddresses(addresses_rhs);
+  return addresses_lhs == addresses_rhs;
+}
+
 template <features::DanglingPtrMode dangling_pointer_mode,
           features::DanglingPtrType dangling_pointer_type>
 void DanglingRawPtrReleased(uintptr_t id) {
@@ -628,7 +641,7 @@
     if (!free_info) {
       return;
     }
-    if (task_trace_release.ToString() == free_info->task_trace.ToString()) {
+    if (task_trace_release == free_info->task_trace) {
       return;
     }
   }
diff --git a/base/allocator/partition_allocator/partition_alloc.gni b/base/allocator/partition_allocator/partition_alloc.gni
index e0c141b..d8c18eb 100644
--- a/base/allocator/partition_allocator/partition_alloc.gni
+++ b/base/allocator/partition_allocator/partition_alloc.gni
@@ -52,12 +52,40 @@
 }
 
 declare_args() {
+  # Turns on compiler optimizations in PartitionAlloc in Debug build.
+  # If enabling PartitionAlloc-Everywhere in Debug build for tests in Debug
+  # build, since all memory allocations and deallocations are executed by
+  # non-optimized PartitionAlloc, chrome (including tests) will be much
+  # slower. This will cause debug trybots' timeouts. If we want to debug
+  # PartitionAlloc itself, use partition_alloc_optimized_debug=false.
+  # Otherwise, use partition_alloc_optimized_debug=true to enable optimized
+  # PartitionAlloc.
+  partition_alloc_optimized_debug = true
+
   # PartitionAlloc-Everywhere (PA-E).
   use_partition_alloc_as_malloc =
       use_partition_alloc && use_partition_alloc_as_malloc_default
 }
 
 declare_args() {
+  # Causes all the allocations to be routed via allocator_shim.cc.
+  use_allocator_shim = use_allocator_shim_default
+}
+
+assert(!use_allocator_shim || (is_android || is_apple || is_chromeos ||
+                                   is_fuchsia || is_linux || is_win),
+       "The allocator shim does not (yet) support the platform.")
+
+if (use_allocator_shim && is_win) {
+  # It's hard to override CRT's malloc family in every case in the component
+  # build, and it's very easy to override it partially and to be inconsistent
+  # among allocations and deallocations. Then, we'll crash when PA deallocates
+  # a memory region allocated by the CRT's malloc or vice versa.
+  assert(!is_component_build,
+         "The allocator shim doesn't work for the component build on Windows.")
+}
+
+declare_args() {
   use_freeslot_bitmap = false
 
   # Puts the regular and BRP pools right next to each other, so that we can
diff --git a/base/apple/owned_objc.h b/base/apple/owned_objc.h
index 52aff36..6366a8e 100644
--- a/base/apple/owned_objc.h
+++ b/base/apple/owned_objc.h
@@ -38,24 +38,27 @@
 #define OWNED_TYPE_DECL_OBJC_ADDITIONS(name, objctype)
 #endif  // __OBJC__
 
-#define OWNED_OBJC_DECL(name, objctype)                      \
-  namespace base::apple {                                    \
-  class BASE_EXPORT Owned##name {                            \
-   public:                                                   \
-    /* Default-construct in a null state. */                 \
-    Owned##name();                                           \
-    ~Owned##name();                                          \
-    Owned##name(const Owned##name&);                         \
-    Owned##name& operator=(const Owned##name&);              \
-    /* Returns whether the object contains a valid object.*/ \
-    bool IsValid() const;                                    \
-    /* Objective-C-only constructor and getter. */           \
-    OWNED_TYPE_DECL_OBJC_ADDITIONS(name, objctype)           \
-                                                             \
-   private:                                                  \
-    struct ObjCStorage;                                      \
-    std::unique_ptr<ObjCStorage> objc_storage_;              \
-  };                                                         \
+#define OWNED_OBJC_DECL(name, objctype)                       \
+  namespace base::apple {                                     \
+  class BASE_EXPORT Owned##name {                             \
+   public:                                                    \
+    /* Default-construct in a null state. */                  \
+    Owned##name();                                            \
+    ~Owned##name();                                           \
+    Owned##name(const Owned##name&);                          \
+    Owned##name& operator=(const Owned##name&);               \
+    /* Returns whether the object contains a valid object. */ \
+    bool IsValid() const;                                     \
+    /* Comparisons. */                                        \
+    bool operator==(const Owned##name& other) const;          \
+    bool operator!=(const Owned##name& other) const;          \
+    /* Objective-C-only constructor and getter. */            \
+    OWNED_TYPE_DECL_OBJC_ADDITIONS(name, objctype)            \
+                                                              \
+   private:                                                   \
+    struct ObjCStorage;                                       \
+    std::unique_ptr<ObjCStorage> objc_storage_;               \
+  };                                                          \
   }  // namespace base::apple
 
 #define GENERATE_OWNED_OBJC_TYPE(name) OWNED_OBJC_DECL(name, name*)
diff --git a/base/apple/owned_objc.mm b/base/apple/owned_objc.mm
index f919df9..7e68609 100644
--- a/base/apple/owned_objc.mm
+++ b/base/apple/owned_objc.mm
@@ -33,6 +33,12 @@
   bool Owned##name::IsValid() const {                                  \
     return objc_storage_->obj != nil;                                  \
   }                                                                    \
+  bool Owned##name::operator==(const Owned##name& other) const {       \
+    return objc_storage_->obj == other.objc_storage_->obj;             \
+  }                                                                    \
+  bool Owned##name::operator!=(const Owned##name& other) const {       \
+    return !this->operator==(other);                                   \
+  }                                                                    \
   objctype Owned##name::Get() const {                                  \
     return objc_storage_->obj;                                         \
   }                                                                    \
diff --git a/base/apple/owned_objc_types.h b/base/apple/owned_objc_types.h
index 68be95d..e0e3d95 100644
--- a/base/apple/owned_objc_types.h
+++ b/base/apple/owned_objc_types.h
@@ -14,6 +14,7 @@
 #endif
 
 #if BUILDFLAG(IS_MAC)
+GENERATE_OWNED_OBJC_TYPE(NSCursor)
 GENERATE_OWNED_OBJC_TYPE(NSEvent)
 #elif BUILDFLAG(IS_IOS)
 GENERATE_OWNED_OBJC_TYPE(UIEvent)
diff --git a/base/debug/dwarf_line_no.cc b/base/debug/dwarf_line_no.cc
index 7ae2142..2f12ea4 100644
--- a/base/debug/dwarf_line_no.cc
+++ b/base/debug/dwarf_line_no.cc
@@ -11,6 +11,7 @@
 #include <cstdint>
 #include <limits>
 
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.h b/base/trace_event/heap_profiler_allocation_context_tracker.h
index 66cc871..da4f747 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.h
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.h
@@ -6,6 +6,7 @@
 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
 
 #include <atomic>
+#include <cstdint>
 #include <vector>
 
 #include "base/base_export.h"
diff --git a/build/install-build-deps.py b/build/install-build-deps.py
index 81a78d0..9d927e6 100755
--- a/build/install-build-deps.py
+++ b/build/install-build-deps.py
@@ -217,6 +217,7 @@
       "libelf-dev",
       "libevdev-dev",
       "libffi-dev",
+      "libfuse2",
       "libgbm-dev",
       "libglib2.0-dev",
       "libglu1-mesa-dev",