Archive this repo
diff --git a/.clang-format b/.clang-format
deleted file mode 100644
index d5c7b08..0000000
--- a/.clang-format
+++ /dev/null
@@ -1,3 +0,0 @@
-# Defines the Chromium style for automatic reformatting.
-# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
-BasedOnStyle: Chromium
diff --git a/.codespellignorelines b/.codespellignorelines
deleted file mode 100644
index 0c7fa5f..0000000
--- a/.codespellignorelines
+++ /dev/null
@@ -1,10 +0,0 @@
- vp9AllowList.get("Technicolor").add("STING");
- return SkSurface::MakeRenderTarget(gr_context_.get(), SkBudgeted::kNo,
- texture_infos.push_back(TextureInfo("uv", "ba"));
-/* If zlib is available and you want to support the flate compression
-// Onces represent initializations that should only ever happen once per
- gr_texture_.reset(new GrBackendTexture(texture_size.width(),
- texture_size.height(),
- GrMipMapped::kNo, texture_info));
-Onces represent initializations that should only ever happen once per process,
- <Resource Language="TE" />
diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index 3b65cb7..0000000
--- a/.coveragerc
+++ /dev/null
@@ -1,13 +0,0 @@
-# pycov configuration
-
-[run]
-source=.
-
-omit=
- # Exclude test files from coverage report
- *_test.py
- cobalt/black_box_tests/tests/*
- cobalt/media_integration_tests/*
-
- # Exclude scripts in third_party/
- third_party/*
diff --git a/.gn b/.gn
deleted file mode 100644
index 5fb6ec2..0000000
--- a/.gn
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2021 The Cobalt Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# The location of the build configuration file.
-buildconfig = "//starboard/build/config/BUILDCONFIG.gn"
-
-# We have `python3` if we're in a container or on buildbot, so use that.
-if (getenv("IS_DOCKER") == "1" || getenv("BUILDBOT_PROJECT") != "") {
- script_executable = "python3"
-}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
deleted file mode 100644
index 4a945f0..0000000
--- a/.pre-commit-config.yaml
+++ /dev/null
@@ -1,204 +0,0 @@
-# See https://pre-commit.com for more information
-# See https://pre-commit.com/hooks.html for more hooks
-default_stages: [commit]
-
-default_language_version:
- python: python3
-
-files: |
- (?x)^(
- (
- .github|
- cobalt|
- docker|
- internal|
- precommit_hooks|
- starboard|
- tools/metrics/actions/cobalt|
- tools/metrics/histograms/metadata/cobalt|
- )/
- | ^[^/]+$ # files in the root
- )
-exclude: |
- (?x)^(
- (
- internal/kokoro/third-party|
- internal/starboard/shared/glimp/include|
- internal/starboard/shared/playstation/glimp/shaders|
- )/
- |
- .*_pb2\.py$ |
- .*\.pb\.cc$ |
- .*\.pb\.h$ |
- .*\.patch$ |
- .*Proto.java$|
- .*\.sig$
- )
-
-repos:
-- repo: https://cobalt.googlesource.com/pre-commit-hooks
- rev: e1668fe86af3810fbca72b8653fe478e66a0afdc # v3.2.0
- hooks:
- - id: check-case-conflict
- - id: end-of-file-fixer
- - id: trailing-whitespace
- - id: mixed-line-ending
- - id: check-xml
-
-- repo: https://cobalt.googlesource.com/codespell
- rev: 67c489d36dd4c52cbb9e4755d90c35c6231842ef # v2.0.0
- hooks:
- - id: codespell
- name: Spell Check
- args: [-x, .codespellignorelines,
- # The --ignore-words-list argument has a bug where it needs to
- # be lowercase, see
- # https://github.com/codespell-project/codespell/issues/1390
- --ignore-words-list, "atleast,varius,ridiculus,statics",
- ]
- exclude: |
- (?x)^(
- (internal/)?starboard/[^/]+/i18n/|
- cobalt/content/licenses/|
- cobalt/content/ssl/|
- cobalt/fetch/embedded_scripts|
- cobalt/streams/embedded_scripts|
- cobalt/loader/cors_preflight.cc|
- internal/cobalt/browser/splash_screen/youtube_splash_screen.html|
- internal/starboard/shared/playstation/storage_internal.cc|
- starboard/loader_app/app_key_test.cc|
- starboard/shared/starboard/player/testdata|
- starboard/shared/win32/media_transform.cc
- )
-
-- repo: local
- hooks:
- - id: sync-keyboxes
- name: sync-keyboxes
- entry: python ./precommit_hooks/sync_keyboxes_wrapper.py
- language: python
- stages: [post-checkout]
- always_run: true
- - id: clang-format
- name: clang-format
- entry: clang-format
- language: python
- types: [c++]
- exclude_types: [objective-c++]
- args: [-i, -style=file]
- additional_dependencies: ['clang-format']
- - id: cpplint
- name: cpplint
- entry: cpplint
- language: system
- types: [c++]
- args: [--verbose=4, --quiet]
- exclude: |
- (?x)(
- ^cobalt/bindings/(templates|generated)/|
- ^internal/starboard/shared/uikit/.*\.h$
- )
- - id: yapf
- name: yapf
- description: Run yapf (the python formatter) in-place on changed files.
- entry: yapf
- language: system
- types: [python]
- args: [-i, -vv]
- - id: pylint
- name: pylint
- entry: pylint
- language: system
- types: [python]
- args: [-d W0201]
- - id: google-java-format
- name: google-java-format
- entry: python ./precommit_hooks/google_java_format_wrapper.py
- language: python
- types: [java]
- args: [-i]
- - id: gcheckstyle
- name: Lint Java With gcheckstyle
- entry: python ./precommit_hooks/gcheckstyle_wrapper.py
- language: python
- types: [java]
- verbose: true
- - id: check-copyright-year
- name: check copyright year
- entry: python ./precommit_hooks/check_copyright_year.py
- language: python
- types: [file, text]
- stages: [push]
- exclude: |
- (?x)^(
- .pylintrc$|
- .pre-commit-config.yaml$|
- cobalt/base/unicode/|
- cobalt/demos/content/|
- cobalt/layout_tests/testdata/|
- cobalt/math/|
- cobalt/media/|
- cobalt/streams/|
- cobalt/webdriver/screencast/|
- cobalt/websocket/|
- components/crx_file/|
- content/|
- internal/starboard/shared/glimp/|
- nb/|
- starboard/android/apk/gradlew|
- starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaDrmBridge.java$|
- starboard/shared/starboard/player/filter/decoded_audio_queue.cc$|
- starboard/shared/starboard/player/filter/decoded_audio_queue.h$|
- starboard/shared/starboard/player/testdata/licences/|
- starboard/shared/starboard/player/filter/wsola_internal.cc$
- )
- exclude_types: [markdown]
- verbose: true
- - id: check-if-starboard-interface-changed
- name: check if starboard interface changed
- entry: python ./precommit_hooks/warn_that_starboard_interface_changed_wrapper.py
- language: python
- files: '^starboard/[^/]+\.h$'
- stages: [push]
- - id: download-resources
- name: download resources
- entry: python ./download_resources.py
- language: python
- stages: [post-checkout]
- always_run: true
- - id: test-download-from-gcs-helper
- name: test download from gcs helper
- entry: python
- language: python
- pass_filenames: false
- always_run: true
- stages: [push]
- args: [-m, unittest, cobalt/tools/download_from_gcs_test.py]
- - id: test-python3-compatibility
- name: Test Python 3 Compatibility
- description: Checks that scripts can be run in Python 3
- entry: python precommit_hooks/python3_check.py
- language: python
- types: [python]
- verbose: true
- - id: check-bug-in-commit-message
- name: Check Bug In Commit Message
- description: Checks for a tracking bug in a commit message
- entry: python precommit_hooks/check_bug_in_description_wrapper.py
- language: python
- stages: [push]
- always_run: true
- pass_filenames: false
- - id: gn-format
- name: GN format
- entry: gn format
- language: system
- files: '.*\.gni?$'
- - id: meta-validate
- name: Validate METADATA files
- entry: python -m cobalt.tools.metadata.validate
- language: python
- additional_dependencies:
- - "protobuf"
- always_run: true
- pass_filenames: false
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index 3707dea..0000000
--- a/.pylintrc
+++ /dev/null
@@ -1,431 +0,0 @@
-# This Pylint rcfile contains a best-effort configuration to uphold the
-# best-practices and style described in the Google Python style guide:
-# https://google.github.io/styleguide/pyguide.html
-#
-# Its canonical open-source location is:
-# https://google.github.io/styleguide/pylintrc
-#
-# Last updated for Cobalt (YYYY-MM-DD): 2022-12-29
-
-[MASTER]
-
-# Files or directories to be skipped. They should be base names, not paths.
-ignore=third_party
-
-# Files or directories matching the regex patterns are skipped. The regex
-# matches against base names, not paths.
-ignore-patterns=
-
-# Pickle collected data for later comparisons.
-persistent=no
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-# Use multiple processes to speed up Pylint.
-jobs=4
-
-# Allow loading of arbitrary C extensions. Extensions are imported into the
-# active Python interpreter and may run arbitrary code.
-unsafe-load-any-extension=no
-
-
-[MESSAGES CONTROL]
-
-# Only show warnings with the listed confidence levels. Leave empty to show
-# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
-confidence=
-
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time (only on the command line, not in the configuration file where
-# it should appear only once). See also the "--disable" option for examples.
-#enable=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifiers separated by comma (,) or put this
-# option multiple times (only on the command line, not in the configuration
-# file where it should appear only once).You can also use "--disable=all" to
-# disable everything first and then reenable specific checks. For example, if
-# you want to run only the similarities checker, you can use "--disable=all
-# --enable=similarities". If you want to run only the classes checker, but have
-# no Warning level messages displayed, use"--disable=all --enable=classes
-# --disable=W"
-disable=abstract-method,
- apply-builtin,
- arguments-differ,
- attribute-defined-outside-init,
- backtick,
- bad-option-value,
- basestring-builtin,
- buffer-builtin,
- c-extension-no-member,
- consider-using-enumerate,
- cmp-builtin,
- cmp-method,
- coerce-builtin,
- coerce-method,
- delslice-method,
- div-method,
- duplicate-code,
- eq-without-hash,
- execfile-builtin,
- file-builtin,
- filter-builtin-not-iterating,
- fixme,
- getslice-method,
- global-statement,
- hex-method,
- idiv-method,
- implicit-str-concat,
- import-error,
- import-self,
- import-star-module-level,
- inconsistent-return-statements,
- input-builtin,
- intern-builtin,
- invalid-str-codec,
- locally-disabled,
- long-builtin,
- long-suffix,
- map-builtin-not-iterating,
- misplaced-comparison-constant,
- missing-function-docstring,
- metaclass-assignment,
- next-method-called,
- next-method-defined,
- no-absolute-import,
- no-else-break,
- no-else-continue,
- no-else-raise,
- no-else-return,
- no-init, # added
- no-member,
- no-name-in-module,
- no-self-use,
- nonzero-method,
- oct-method,
- old-division,
- old-ne-operator,
- old-octal-literal,
- old-raise-syntax,
- parameter-unpacking,
- print-statement,
- raising-string,
- range-builtin-not-iterating,
- raw_input-builtin,
- rdiv-method,
- reduce-builtin,
- relative-import,
- reload-builtin,
- round-builtin,
- setslice-method,
- signature-differs,
- standarderror-builtin,
- suppressed-message,
- sys-max-int,
- too-few-public-methods,
- too-many-ancestors,
- too-many-arguments,
- too-many-boolean-expressions,
- too-many-branches,
- too-many-instance-attributes,
- too-many-locals,
- too-many-nested-blocks,
- too-many-public-methods,
- too-many-return-statements,
- too-many-statements,
- trailing-newlines,
- unichr-builtin,
- unicode-builtin,
- unnecessary-pass,
- unpacking-in-except,
- useless-else-on-loop,
- useless-object-inheritance,
- useless-suppression,
- using-cmp-argument,
- wrong-import-order,
- xrange-builtin,
- zip-builtin-not-iterating,
-
-
-[REPORTS]
-
-# Set the output format. Available formats are text, parseable, colorized, msvs
-# (visual studio) and html. You can also give a reporter class, eg
-# mypackage.mymodule.MyReporterClass.
-output-format=text
-
-# Tells whether to display a full report or only the messages
-reports=no
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note). You have access to the variables errors warning, statement which
-# respectively contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (RP0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Template used to display messages. This is a python new-style format string
-# used to format the message information. See doc for all details
-#msg-template=
-
-
-[BASIC]
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=main,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=
-
-# Colon-delimited sets of names that determine each other's naming style when
-# the name regexes allow several styles.
-name-group=
-
-# Include a hint for the correct naming format with invalid-name
-include-naming-hint=no
-
-# List of decorators that produce properties, such as abc.abstractproperty. Add
-# to this list to register other decorators that produce valid properties.
-property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl
-
-# Regular expression matching correct function names
-function-rgx=^(?:(?P<exempt>setUp|tearDown|setUpModule|tearDownModule)|(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$
-
-# Regular expression matching correct variable names
-variable-rgx=^[a-z][a-z0-9_]*$
-
-# Regular expression matching correct constant names
-const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
-
-# Regular expression matching correct attribute names
-attr-rgx=^_{0,2}[a-z][a-z0-9_]*$
-
-# Regular expression matching correct argument names
-argument-rgx=^[a-z][a-z0-9_]*$
-
-# Regular expression matching correct class attribute names
-class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
-
-# Regular expression matching correct inline iteration names
-inlinevar-rgx=^[a-z][a-z0-9_]*$
-
-# Regular expression matching correct class names
-class-rgx=^_?[A-Z][a-zA-Z0-9]*$
-
-# Regular expression matching correct module names
-module-rgx=^(_?[a-z][a-z0-9_]*|__init__|2)$
-
-# Regular expression matching correct method names
-method-rgx=(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
-
-# Regular expression which should only match function or class names that do
-# not require a docstring.
-no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$
-
-# Minimum line length for functions/classes that require docstrings, shorter
-# ones are exempt.
-docstring-min-length=10
-
-
-[TYPECHECK]
-
-# List of decorators that produce context managers, such as
-# contextlib.contextmanager. Add to this list to register other decorators that
-# produce valid context managers.
-contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# List of module names for which member attributes should not be checked
-# (useful for modules/projects where namespaces are manipulated during runtime
-# and thus existing member attributes cannot be deduced by static analysis. It
-# supports qualified module names, as well as Unix pattern matching.
-ignored-modules=
-
-# List of class names for which member attributes should not be checked (useful
-# for classes with dynamically set attributes). This supports the use of
-# qualified names.
-ignored-classes=optparse.Values,thread._local,_thread._local
-
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E1101 when accessed. Python regular
-# expressions are accepted.
-generated-members=
-
-
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=80
-
-# TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt
-# lines made too long by directives to pytype.
-
-# Regexp for a line that is allowed to be longer than the limit.
-ignore-long-lines=(?x)(
- ^\s*(\#\ )?<?https?://\S+>?$|
- ^\s*(from\s+\S+\s+)?import\s+.+$)
-
-# Allow the body of an if to be on the same line as the test if there is no
-# else.
-single-line-if-stmt=yes
-
-# Maximum number of lines in a module
-max-module-lines=99999
-
-# String used as indentation unit. The internal Google style guide mandates 2
-# spaces. Google's externaly-published style guide says 4, consistent with
-# PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google
-# projects (like TensorFlow).
-indent-string=' '
-
-# Number of spaces of indent required inside a hanging or continued line.
-indent-after-paren=4
-
-# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
-expected-line-ending-format=
-
-
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=TODO
-
-
-[STRING]
-
-# This flag controls whether inconsistent-quotes generates a warning when the
-# character used as a quote delimiter is used inconsistently within a module.
-check-quote-consistency=yes
-
-
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching the name of dummy variables (i.e. expectedly
-# not used).
-dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_)
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-# List of strings which can identify a callback function by name. A callback
-# name must start or end with one of those strings.
-callbacks=cb_,_cb
-
-# List of qualified module names which can have objects that can redefine
-# builtins.
-redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools
-
-
-[LOGGING]
-
-# Logging modules to check that the string format arguments are in logging
-# function parameter format
-logging-modules=logging,absl.logging,tensorflow.io.logging
-
-
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-# Ignore imports when computing similarities.
-ignore-imports=no
-
-
-[SPELLING]
-
-# Spelling dictionary name. Available dictionaries: none. To make it working
-# install python-enchant package.
-spelling-dict=
-
-# List of comma separated words that should not be checked.
-spelling-ignore-words=
-
-# A path to a file that contains private dictionary; one word per line.
-spelling-private-dict-file=
-
-# Tells whether to store unknown words to indicated private dictionary in
-# --spelling-private-dict-file option instead of raising a message.
-spelling-store-unknown-words=no
-
-
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,
- TERMIOS,
- Bastion,
- rexec,
- sets
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report RP0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report RP0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report RP0402 must
-# not be disabled)
-int-import-graph=
-
-# Force import order to recognize a module as part of the standard
-# compatibility libraries.
-known-standard-library=
-
-# Force import order to recognize a module as part of a third party library.
-known-third-party=enchant, absl
-
-# Analyse import fallback blocks. This can be used to support both Python 2 and
-# 3 compatible code, which means that the block might have code that exists
-# only in one or another interpreter, leading to false positives when analysed.
-analyse-fallback-blocks=no
-
-
-[CLASSES]
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,
- __new__,
- setUp
-
-# List of member names, which should be excluded from the protected access
-# warning.
-exclude-protected=_asdict,
- _fields,
- _replace,
- _source,
- _make
-
-# List of valid names for the first argument in a class method.
-valid-classmethod-first-arg=cls,
- class_
-
-# List of valid names for the first argument in a metaclass class method.
-valid-metaclass-classmethod-first-arg=mcs
-
-
-[EXCEPTIONS]
-
-# Exceptions that will emit a warning when being caught. Defaults to
-# "Exception"
-overgeneral-exceptions=builtins.StandardError,
- builtins.Exception,
- builtins.BaseException
diff --git a/.style.yapf b/.style.yapf
deleted file mode 100644
index fdd0723..0000000
--- a/.style.yapf
+++ /dev/null
@@ -1,2 +0,0 @@
-[style]
-based_on_style = yapf
diff --git a/BUILD.gn b/BUILD.gn
deleted file mode 100644
index d2d4ccd..0000000
--- a/BUILD.gn
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2021 The Cobalt Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-group("gn_all") {
- testonly = true
-
- deps = [
- "//cobalt:gn_all",
- "//starboard:gn_all",
- ]
-}
-
-group("default") {
- testonly = true
-
- if (is_qa || is_gold) {
- deps = [
- "//cobalt:default",
- "//starboard:default",
- ]
- } else {
- deps = [ ":gn_all" ]
- }
-}
diff --git a/BUILD_STATUS.md b/BUILD_STATUS.md
deleted file mode 100644
index 560e001..0000000
--- a/BUILD_STATUS.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Build Status
-
-## Post-submit
-
-| Workflow | Main | 25.lts.1+ | 24.lts.1+ | 23.lts.1+ |
-| --------- | ---- | --------- | --------- | --------- |
-| Lint | [![lint](https://github.com/youtube/cobalt/actions/workflows/lint.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/lint.yaml?query=event%3Apush+branch%3Amain) | | | |
-| Android | [![android](https://github.com/youtube/cobalt/actions/workflows/android.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/android.yaml?query=event%3Apush+branch%3Amain) | [![android_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/android_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![android_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/android_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![android_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/android_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Evergreen | [![evergreen](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml?query=event%3Apush+branch%3Amain) | [![evergreen_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![evergreen_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![evergreen_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Linux | [![linux](https://github.com/youtube/cobalt/actions/workflows/linux.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux.yaml?query=event%3Apush+branch%3Amain) | [![linux_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![linux_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![linux_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Raspi-2 | [![raspi-2](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml?query=event%3Apush+branch%3Amain) | [![raspi-2_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![raspi-2_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![raspi-2_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Stub | [![stub](https://github.com/youtube/cobalt/actions/workflows/stub.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/stub.yaml?query=event%3Apush+branch%3Amain) | [![stub_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/stub_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/stub_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![stub_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/stub_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/stub_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![stub_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/stub_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/stub_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Win32 | [![win32](https://github.com/youtube/cobalt/actions/workflows/win32.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32.yaml?query=event%3Apush+branch%3Amain) | [![win32_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | [![win32_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32_24.lts.1+.yaml?query=event%3Apush+branch%3A24.lts.1%2B) | [![win32_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32_23.lts.1+.yaml?query=event%3Apush+branch%3A23.lts.1%2B) |
-| Xbox One | [![xb1](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml?query=event%3Apush+branch%3Amain) | [![xb1_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/xb1_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/xb1_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | | |
-| Python | [![python](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml?query=event%3Apush+branch%3Amain) | [![python_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/pytest_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/pytest_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | | |
-| Java | [![java](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml?query=event%3Apush+branch%3Amain) | [![java_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/gradle_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/gradle_25.lts.1+.yaml?query=event%3Apush+branch%3A25.lts.1%2B) | | |
-
-## Nightly builds
-
-| Workflow | main | 25.lts.1+ | 24.lts.1+ | 23.lts.1+ |
-| --------- | ---- | --------- | --------- | --------- |
-| Android | [![android](https://github.com/youtube/cobalt/actions/workflows/android.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/android.yaml?query=event%3Aschedule+branch%3Amain) | [![android_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/android_25.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A25.lts.1%2B) | [![android_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/android_24.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A24.lts.1%2B) | [![android_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/android_23.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A23.lts.1%2B) |
-| Evergreen | [![evergreen](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml?query=event%3Aschedule+branch%3Amain) | [![evergreen_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/evergreen_25.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A25.lts.1%2B) | [![evergreen_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/evergreen_24.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A24.lts.1%2B) | [![evergreen_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/evergreen_23.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A23.lts.1%2B) |
-| Linux | [![linux](https://github.com/youtube/cobalt/actions/workflows/linux.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/linux.yaml?query=event%3Aschedule+branch%3Amain) | [![linux_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_25.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A25.lts.1%2B) | [![linux_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_24.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A24.lts.1%2B) | [![linux_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_23.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A23.lts.1%2B) |
-| Raspi-2 | [![raspi-2](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml?query=event%3Aschedule+branch%3Amain) | [![raspi-2_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_25.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A25.lts.1%2B) | [![raspi-2_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_24.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A24.lts.1%2B) | [![raspi-2_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_23.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A23.lts.1%2B) |
-| Win32 | [![win32](https://github.com/youtube/cobalt/actions/workflows/win32.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/win32.yaml?query=event%3Aschedule+branch%3Amain) | [![win32_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/win32_25.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A25.lts.1%2B) | [![win32_24.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_24.lts.1+.yaml/badge.svg?branch=24.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/win32_24.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A24.lts.1%2B) | [![win32_23.lts.1+](https://github.com/youtube/cobalt/actions/workflows/win32_23.lts.1+.yaml/badge.svg?branch=23.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/win32_23.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A23.lts.1%2B) |
-| Xbox One | [![xb1](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml/badge.svg?branch=main&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml?query=event%3Aschedule+branch%3Amain) | [![xb1_25.lts.1+](https://github.com/youtube/cobalt/actions/workflows/xb1_25.lts.1+.yaml/badge.svg?branch=25.lts.1%2B&event=schedule)](https://github.com/youtube/cobalt/actions/workflows/xb1_25.lts.1+.yaml?query=event%3Aschedule+branch%3A24.lts.1%2B) | | |
-
-
-# Legacy releases
-
-## Post-submit
-
-| 22.lts.1+ | 21.lts.1+ | 20.lts.1+ | 19.lts.1+ | RC11 | COBALT 9 |
-| --------- | --------- | --------- | --------- | ---- | -------- |
-| [![android_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/android_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Apush) | | | | | |
-| [![evergreen_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Apush) | [![evergreen_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen_21.lts.1+.yaml?query=branch%3A21.lts.1%2B+event%3Apush) | | | | |
-| [![linux_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Apush) | [![linux_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_21.lts.1+.yaml?query=branch%3A21.lts.1%2B+event%3Apush) | [![linux_20.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_20.lts.1+.yaml/badge.svg?branch=20.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_20.lts.1+.yaml?query=branch%3A20.lts.1%2B+event%3Apush) | [![linux_19.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_19.lts.1+.yaml/badge.svg?branch=19.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_19.lts.1+.yaml?query=branch%3A19.lts.1%2B+event%3Apush) | [![linux_rc_11](https://github.com/youtube/cobalt/actions/workflows/linux_rc_11.yaml/badge.svg?branch=rc_11&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_rc_11.yaml?query=event%3Apush+branch%3Arc_11) | [![linux_COBALT_9](https://github.com/youtube/cobalt/actions/workflows/linux_COBALT_9.yaml/badge.svg?branch=COBALT_9&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux_COBALT_9.yaml?query=event%3Apush+branch%3ACOBALT_9) |
-| [![raspi-2_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Apush) | [![raspi-2_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_21.lts.1+.yaml?query=branch%3A21.lts.1%2B+event%3Apush) | [![raspi-2_20.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_20.lts.1+.yaml/badge.svg?branch=20.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_20.lts.1+.yaml?query=branch%3A20.lts.1%2B+event%3Apush) | [![raspi-2_19.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_19.lts.1+.yaml/badge.svg?branch=19.lts.1%2B&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_19.lts.1+.yaml?query=branch%3A19.lts.1%2B+event%3Apush) | [![raspi-2_rc_11](https://github.com/youtube/cobalt/actions/workflows/raspi-2_rc_11.yaml/badge.svg?branch=rc_11&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_rc_11.yaml?query=event%3Apush+branch%3Arc_11) | [![raspi-2_COBALT_9](https://github.com/youtube/cobalt/actions/workflows/raspi-2_COBALT_9.yaml/badge.svg?branch=COBALT_9&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_COBALT_9.yaml?query=event%3Apush+branch%3ACOBALT_9) |
-
-## Nightly
-
-| 22.lts.1+ | 21.lts.1+ | 20.lts.1+ | 19.lts.1+ | RC11 | COBALT 9 |
-| --------- | --------- | --------- | --------- | ---- | --------- |
-| [![android_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/android_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/android_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Aworkflow_dispatch) | | | | | |
-| [![evergreen_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/evergreen_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Aworkflow_dispatch) | [![evergreen_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/evergreen_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/evergreen_21.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A21.lts.1%2B) | | | | |
-| [![linux_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Aworkflow_dispatch) | [![linux_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_21.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A21.lts.1%2B) | [![linux_20.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_20.lts.1+.yaml/badge.svg?branch=20.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_20.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A20.lts.1%2B) | [![linux_19.lts.1+](https://github.com/youtube/cobalt/actions/workflows/linux_19.lts.1+.yaml/badge.svg?branch=19.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_19.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A19.lts.1%2B) | [![linux_rc_11](https://github.com/youtube/cobalt/actions/workflows/linux_rc_11.yaml/badge.svg?branch=rc_11&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_rc_11.yaml?query=event%3Aworkflow_dispatch+branch%3Arc_11) | [![linux_COBALT_9](https://github.com/youtube/cobalt/actions/workflows/linux_COBALT_9.yaml/badge.svg?branch=COBALT_9&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/linux_COBALT_9.yaml?query=event%3Aworkflow_dispatch+branch%3ACOBALT_9) |
-| [![raspi-2_22.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_22.lts.1+.yaml/badge.svg?branch=22.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_22.lts.1+.yaml?query=branch%3A22.lts.1%2B+event%3Aworkflow_dispatch) | [![raspi-2_21.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_21.lts.1+.yaml/badge.svg?branch=21.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_21.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A21.lts.1%2B) | [![raspi-2_20.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_20.lts.1+.yaml/badge.svg?branch=20.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_20.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A20.lts.1%2B) | [![raspi-2_19.lts.1+](https://github.com/youtube/cobalt/actions/workflows/raspi-2_19.lts.1+.yaml/badge.svg?branch=19.lts.1%2B&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_19.lts.1+.yaml?query=event%3Aworkflow_dispatch+branch%3A19.lts.1%2B) | [![raspi-2_rc_11](https://github.com/youtube/cobalt/actions/workflows/raspi-2_rc_11.yaml/badge.svg?branch=rc_11&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_rc_11.yaml?query=event%3Aworkflow_dispatch+branch%3Arc_11) | [![raspi-2_COBALT_9](https://github.com/youtube/cobalt/actions/workflows/raspi-2_COBALT_9.yaml/badge.svg?branch=COBALT_9&event=workflow_dispatch)](https://github.com/youtube/cobalt/actions/workflows/raspi-2_COBALT_9.yaml?query=event%3Aworkflow_dispatch+branch%3ACOBALT_9) |
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 0604bc7..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# Contributing guidelines
-
-## Pull Request Checklist
-
-Before sending your pull requests, make sure you do the following:
-
-- Read the [contributing guidelines](CONTRIBUTING.md).
-- Ensure you have signed the
- [Contributor License Agreement (CLA)](https://cla.developers.google.com/).
-- Check if your changes are consistent with the:
- - [General guidelines](#general-guidelines-and-philosophy-for-contribution).
- - [Coding Style](#coding-style).
-- Run the [unit tests](#running-unit-tests).
-
-### Contributor License Agreements
-
-We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles.
-
-Please fill out either the individual or corporate Contributor License Agreement (CLA).
-
- * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](https://code.google.com/legal/individual-cla-v1.0.html).
- * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](https://code.google.com/legal/corporate-cla-v1.0.html).
-
-Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.
-
-***NOTE***: Only original source code from you and other people that have signed the CLA can be accepted into the main repository.
-
-### Community Guidelines
-
-This project follows
-[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
-
-### Contributing code
-
-If you have improvements to Cobalt, send us your pull requests! For those
-just getting started, Github has a
-[how to](https://help.github.com/articles/using-pull-requests/).
-
-Cobalt team members will be assigned to review your pull requests. A team
-member will need to approve the workflow runs for each pull request. Once the
-pull requests are approved and pass *all* presubmit checks, a Cobalt
-team member will merge the pull request.
-
-### Contribution guidelines and standards
-
-Before sending your pull request for
-[review](https://github.com/youtube/cobalt/pulls),
-make sure your changes are consistent with the guidelines and follow the
-Cobalt coding style.
-
-#### General guidelines and philosophy for contribution
-
-* Ensure your change references the bug you are addressing. Follow the
- instructions
- [here](https://cobalt.dev/communication.html#filing-bugs-and-feature-requests)
- to view and create bugs.
-* Include unit tests when you contribute new features, as they help to:
- 1. Prove that your code works correctly
- 1. Guard against future breaking changes to lower the maintenance cost.
-* Bug fixes also generally require unit tests, because the presence of bugs
- usually indicates insufficient test coverage.
-* When you contribute a new feature to Cobalt, the maintenance burden is
- (by default) transferred to the Cobalt team. This means that the benefit
- of the contribution must be compared against the cost of maintaining the
- feature.
-* As every PR requires several CPU/GPU hours of CI testing, we discourage
- submitting PRs to fix one typo, one warning,etc. We recommend fixing the
- same issue at the file level at least (e.g.: fix all typos in a file, fix
- all compiler warning in a file, etc.)
-
-#### License
-
-Include a license at the top of new files. Check existing files for license examples.
-
-#### Coding style
-
-Cobalt follows the
-[Chromium style guide](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/styleguide.md).
-
-Cobalt uses pre-commit to ensure good coding style. Create a python 3 virtual
-environment for working with Cobalt, then install `pre-commit` with:
-
-```bash
-$ pre-commit install -t post-checkout -t pre-commit -t pre-push --allow-missing-config
-```
-
-`pre-commit` will mostly run automatically, and can also be invoked manually.
-You can find documentation about it at https://pre-commit.com/.
-
-#### Running unit tests
-
-First, ensure Docker and Docker Compose are installed on your system. Then,
-you can run unit tests for our linux reference implementation using:
-
-```bash
-$ docker compose up --build --no-start linux-x64x11-unittest
-$ PLATFORM=linux-x64x11 CONFIG=devel TARGET=all docker compose run linux-x64x11
-$ PLATFORM=linux-x64x11 CONFIG=devel docker compose run linux-x64x11-unittest
-```
diff --git a/README.md b/README.md
index f29ca77..769afd2 100644
--- a/README.md
+++ b/README.md
@@ -1,205 +1,7 @@
-# Cobalt [![Build Matrix](https://img.shields.io/badge/-Build%20Matrix-blueviolet)](https://github.com/youtube/cobalt/blob/main/BUILD_STATUS.md)
+## Archival notice
-[![codecov](https://codecov.io/github/youtube/cobalt/branch/main/graph/badge.svg?token=RR6MKKNYNV)](https://codecov.io/github/youtube/cobalt)
-[![lint](https://github.com/youtube/cobalt/actions/workflows/lint.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/lint.yaml?query=event%3Apush+branch%3Amain)
-[![java](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml?query=event%3Apush+branch%3Amain)
-[![python](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml?query=event%3Apush+branch%3Amain) \
-[![android](https://github.com/youtube/cobalt/actions/workflows/android.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/android.yaml?query=event%3Apush+branch%3Amain)
-[![evergreen](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml?query=event%3Apush+branch%3Amain)
-[![linux](https://github.com/youtube/cobalt/actions/workflows/linux.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux.yaml?query=event%3Apush+branch%3Amain)
-[![raspi-2](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml?query=event%3Apush+branch%3Amain)
-[![win32](https://github.com/youtube/cobalt/actions/workflows/win32.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32.yaml?query=event%3Apush+branch%3Amain)
-[![xb1](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/xb1.yaml?query=event%3Apush+branch%3Amain)
+This repository of Cobalt is no longer updated, and is kept for
+reference only.
-## Overview
-
-Cobalt is a lightweight application container (i.e. an application runtime, like
-a JVM or the Flash Player) that is compatible with a subset of the W3C HTML5
-specifications. If you author a single-page web application (SPA) that complies
-with the Cobalt Subset of W3C standards, it will run as well as possible on all
-the devices that Cobalt supports.
-
-
-## Motivation
-
-The Cobalt Authors originally maintained a port of Chromium called H5VCC, the
-HTML5 Video Container for Consoles, ported to each of the major game consoles,
-designed to run our HTML5-based video browse and play application. This took a
-long time to port to each platform, consisted of 9 million lines of C++ code
-(before we touched it), was dangerous to modify without unintended consequences,
-and was thoroughly designed for a resource-rich, multi-process environment
-(e.g. a desktop, laptop, or modern smartphone).
-
-After wrestling with this for several years, we imagined an environment that was
-not designed for traditional scrolling web content, but was intended to be a
-runtime environment for rich client applications built with the same
-technologies -- HTML, CSS, JavaScript -- and designed from the ground-up to run
-on constrained, embedded, Living Room Consumer Electronics (CE) devices, such as
-Game Consoles, Set-Top Boxes (e.g. Cable, Satellite), OTT devices (e.g. Roku,
-Apple TV, Chromecast, Fire TV), Blu-ray Disc Players, and Smart TVs.
-
-These constraints (not intended to be a canonical list) make this device
-spectrum vastly different from the desktop computer environment targeted by
-Chromium, FireFox, and IE:
-
- * **Limited Memory.** All except the very latest, expensive CE devices have a
- very small amount of memory available for applications. This usually is
- somewhere in the ballpark of 500MB, including graphics and media
- memory, as opposed to multiple gigabytes of CPU memory (and more gigabytes
- of GPU memory) in modern desktop and laptop computers, and mobile devices.
- * **Slow CPUs.** Most CE devices have much slower CPUs than what is available
- on even a budget desktop computer. Minor performance concerns can be greatly
- exaggerated, which seriously affects priorities. Cobalt currently expects a
- 4-core 32-bit ARMv7 CPU as a baseline.
- * **Minimal GPU.** Not all CE devices have a monster GPU to throw shaders at
- to offload CPU work. As CE devices now have a standard GPU (though not
- nearly as powerful as even a laptop), OpenGL ES 2.0 is now required
- by Cobalt.
- * **Sometimes No JIT.** Many CE devices are dealing with "High-Value Content,"
- and, as such, are very sensitive to security concerns. Ensuring that
- writable pages are not executable is a strong security protocol that can
- prevent a wide spectrum of attacks. But, as a side effect, this also means
- no ability to JIT.
- * **Heterogeneous Development Environments.** This is slowly evening out, but
- all CE devices run on custom hardware, often with proprietary methods of
- building, packaging, deploying, and running programs. Sometimes the
- toolchain doesn't support latest C++ language features. Sometimes the OS
- does not support POSIX, or it is only partially implemented.
- Sometimes the program entry point is in another language or architecture
- that requires a "trampoline" over to native binary code.
- * **No navigation.** The point of a Single-Page Application is that you don't
- go through the HTTP page dance every time you switch screens. It's slow, and
- provides poor user feedback, not to mention a jarring transition. Instead,
- one loads data from an XMLHttpRequest (XHR), and then updates one's DOM to
- reflect the new data. AJAX! Web 2.0!!
-
-
-## Architecture
-
-The Cobalt Authors forked H5VCC, removed most of the Chromium code -- in
-particular WebCore and the Chrome Renderer and Compositor -- and built up from
-scratch an implementation of a simplified subset of HTML, the CSS Box Model for
-layout, and the Web APIs that were really needed to build a full-screen SPA
-browse and play application.
-
-The Cobalt technology stack has these major components, roughly in a high-level
-application to a low-level platform order:
-
- * **Web Implementation** - This is where the W3C standards are implemented,
- ultimately producing an annotated DOM tree that can be passed into the
- Layout Engine to produce a Render Tree. Cobalt uses a forked copy of
- [Chrome Blink's Web IDL compiler](https://www.chromium.org/blink/webidl/) to
- turn JavaScript IDLs to generated C++ bindings code.
- * **JavaScript Engine** - We have, perhaps surprisingly, *not* written our own
- JavaScript Engine from scratch. Cobalt is running on [Chromiums V8](https://v8.dev)
- JavaScript engine. V8 supports all of our target platforms, including very
- restricted ones where write-and-execute memory pages (needed for JIT) are
- not available.
- * **Layout Engine** - The Layout Engine takes an annotated DOM Document
- produced by the Web Implementation and JavaScript Engine working together,
- and calculates a tree of rendering commands to send to the renderer (i.e. a
- Render Tree). It caches intermediate layout artifacts so that subsequent
- incremental layouts can be sped up.
- * **Renderer/Skia** - The Renderer walks a Render Tree produced by the Layout
- Engine, rasterizes it using the [Chromium graphics library Skia](https://skia.org/), and swaps
- it to the front buffer. This is accomplished using Hardware Skia on OpenGL
- ES 2.0. Note that the renderer runs in a different thread from the Layout
- Engine, and can interpolate animations that do not require re-layout. This
- decouples rendering from Layout and JavaScript, allowing for smooth,
- consistent animations on platforms with a variety of capabilities.
- * **Net / Media** - These are Chromium's Network and Media engines. We are
- using them directly, as they don't cause any particular problems with the
- extra constraints listed above.
- * **Base** - This is Chromium's "Base" library, which contains a wide variety
- of useful things used throughout Cobalt, Net, and Media. Cobalt uses a
- combination of standard C++ containers (e.g. vector, string) and Base as the
- foundation library for all of its code.
- * **Other Third-party Libraries** - Most of these are venerable, straight-C,
- open-source libraries that are commonly included in other open-source
- software. Mostly format decoders and parsers (e.g. libpng, libxml2,
- zlib). We fork these from Chromium, as we want them to be the most
- battle-tested versions of these libraries.
- * **Starboard** - **Starboard** is the Cobalt porting
- interface. One major difference between Cobalt and Chromium is that we have
- created a hard straight-C porting layer, and ported ALL of the compiled
- code, including Base and all third-party libraries, to use it instead of
- directly using POSIX standard libraries, which are not consistent, even on
- modern systems (see Android, Windows, MacOS X, and iOS). Additionally,
- Starboard includes APIs that haven't been effectively standardized across
- platforms, such as display Window creation, Input events, and Media
- playback. A good overview of which OS interfaces are abstracted by Starboard
- can be found in the [reference documentation.](https://cobalt.dev/reference/starboard/modules/configuration.html)
- * **ANGLE and Glimp** [**ANGLE** is a Chromium library](https://angleproject.org/)
- that adapts OpenGL ES 2.0 graphics to various other platform-native graphics APIs.
- Cobalt uses it on Windows platforms to run on DirectX. Glimp is a similar
- custom adapter layer that translatest from GL ES2.0 to PlayStation native graphics.
-
-## The Cobalt Subset
-
-> Oh, we got both kinds of HTML tags,\
-> we got `<span>` and `<div>`! \
-> We even have CSS Flexbox now, hooray!
-
-See the [Cobalt Subset
-specification](https://cobalt.dev/development/reference/supported-features.html)
-for more details on which tags, properties, and Web APIs are supported in
-Cobalt.
-
-## Interesting Source Locations
-
-All source locations are specified relative to `src/` (this directory).
-
- * `base/` - Chromium's Base library. Contains common utilities, and a light
- platform abstraction, which has been superseded in Cobalt by Starboard.
- * `net/` - Chromium's Network library. Contains enough infrastructure to
- support the network needs of an HTTP User-Agent (like Chromium or Cobalt),
- an HTTP server, a DIAL server, and several abstractions for networking
- primitives. Also contains SPDY and QUIC implementations.
- * `cobalt/` - The home of all Cobalt application code. This includes the Web
- Implementation, Layout Engine, Renderer, and some other Cobalt-specific
- features.
- * `cobalt/build/` - The core build generation system, `gn.py`, and
- configurations for supported platforms.
- * `cobalt/doc/` - Contains a wide range of detailed information and guides
- on Cobalt features, functionality and best practices for Cobalt
- development.
- * `cobalt/media/` - Chromium's Media library. Contains all the code that
- parses, processes, and manages buffers of video and audio data. It
- send the buffers to the SbPlayer implementation for playback.
- * `starboard/` - Cobalt's porting layer. Please see Starboard's
- [`README.md`](starboard/README.md) for more detailed information about
- porting Starboard (and Cobalt) to a new platform.
- * `third_party/` - Where all of Cobalt's third-party dependencies live. We
- don't mean to be pejorative, we love our third-party libraries! This
- location is dictated by Google OSS release management rules...
-
-
-## Building and Running the Code
-
- See the below reference port setup guides for more details:
-
- * [Linux](cobalt/site/docs/development/setup-linux.md)
- * [Raspi](cobalt/site/docs/development/setup-raspi.md)
- * [Android](cobalt/site/docs/development/setup-android.md)
- * [Docker](cobalt/site/docs/development/setup-docker.md)
- * [RDK](cobalt/site/docs/development/setup-rdk.md)
-
-## Build Types
-
-Cobalt has four build optimization levels, going from the slowest, least
-optimized, with the most debug information at the top (debug) to the fastest,
-most optimized, and with the least debug information at the bottom (gold):
-
- Type | Optimizations | Logging | Asserts | Debug Info | Console
- :---- | :------------ | :------ | :------ | :--------- | :-------
- debug | None | Full | Full | Full | Enabled
- devel | Full | Full | Full | Full | Enabled
- qa | Full | Limited | None | None | Enabled
- gold | Full | None | None | None | Disabled
-
-When building for release, you should always use a gold build for the final
-product.
-
-## Origin of this Repository
-
-This is a fork of the chromium repository at http://git.chromium.org/git/chromium.git
+Please use https://github.com/youtube/cobalt. Refer to https://cobalt.dev for
+further details.
diff --git a/SECURITY.md b/SECURITY.md
deleted file mode 100644
index e6b03a4..0000000
--- a/SECURITY.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-Currently supported stable Cobalt versions are.
-
-| Version | Release status | Supported |
-| ------- | -----------------|------------------- |
-| 25.lts | upcoming release | :white_check_mark: |
-| 24.lts | last stable | :white_check_mark: |
-| 23.lts | maintenance | :white_check_mark: |
-| 22.lts | EOL | :no_entry: |
-| < 21.lts| no support | :x: |
-
-
-## Model
-
-Although Cobalt is built to process web content similar to browsers,
-it is not a web browser. Our security model assumes _only trusted content
-processing_.
-
-## Reporting a Vulnerability
-
-Please use [https://developers.google.com/youtube/cobalt](https://developers.google.com/youtube/cobalt/docs/communication) as an overall guide where to report issues.
-
-Critical security vulnerabilities should be reported via yt-cobalt-security@google.com.
diff --git a/base/BUILD.gn b/base/BUILD.gn
deleted file mode 100644
index 5ad4e48..0000000
--- a/base/BUILD.gn
+++ /dev/null
@@ -1,5142 +0,0 @@
-# Copyright 2013 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# HOW TO WRITE CONDITIONALS IN THIS FILE
-# ======================================
-#
-# In many other places, one would write a conditional that expresses all the
-# cases when a source file is used or unused, and then either add or subtract
-# it from the sources list in that case
-#
-# Since base includes so many low-level things that vary widely and
-# unpredictably for the various build types, we prefer a slightly different
-# style. Instead, there are big per-platform blocks of inclusions and
-# exclusions. If a given file has an inclusion or exclusion rule that applies
-# for multiple conditions, prefer to duplicate it in both lists. This makes it
-# a bit easier to see which files apply in which cases rather than having a
-# huge sequence of random-looking conditionals.
-
-import("//base/allocator/allocator.gni")
-import("//base/allocator/partition_allocator/partition_alloc.gni")
-import("//base/debug/debug.gni")
-import("//base/trace_event/tracing.gni")
-import("//build/buildflag_header.gni")
-import("//build/config/arm.gni")
-import("//build/config/c++/c++.gni")
-import("//build/config/chromecast_build.gni")
-import("//build/config/chromeos/ui_mode.gni")
-import("//build/config/compiler/compiler.gni")
-import("//build/config/cronet/config.gni")
-import("//build/config/dcheck_always_on.gni")
-import("//build/config/ios/config.gni")
-import("//build/config/logging.gni")
-import("//build/config/nacl/config.gni")
-import("//build/config/profiling/profiling.gni")
-import("//build/config/rust.gni")
-import("//build/config/sanitizers/sanitizers.gni")
-import("//build/config/sysroot.gni")
-import("//build/config/ui.gni")
-import("//build/nocompile.gni")
-import("//build/timestamp.gni")
-import("//build_overrides/build.gni")
-import("//testing/libfuzzer/fuzzer_test.gni")
-import("//testing/test.gni")
-
-if (is_mac) {
- # Used to generate fuzzer corpus :base_mach_port_rendezvous_convert_corpus.
- import("//third_party/protobuf/proto_library.gni")
-}
-
-if (is_apple) {
- # Buildflags to control time behavior on iOS in file shared with mac.
- import("//base/time/buildflags/buildflags.gni")
-}
-
-if (is_win) {
- import("//build/config/win/control_flow_guard.gni")
-}
-
-declare_args() {
- # Unsafe developer build. Has developer-friendly features that may weaken or
- # disable security measures like sandboxing or ASLR.
- # IMPORTANT: Unsafe developer builds should never be distributed to end users.
- is_unsafe_developer_build = !is_official_build
-
- # Set to true to disable COM init check hooks.
- com_init_check_hook_disabled = false
-
- # Set to true to enable mutex priority inheritance. See the comments in
- # LockImpl::PriorityInheritanceAvailable() in lock_impl_posix.cc for the
- # platform requirements to safely enable priority inheritance.
- enable_mutex_priority_inheritance = false
-
- # Control whether the ios stack sampling profiler is enabled. This flag is
- # only supported on iOS 64-bit architecture, but some project build //base
- # for 32-bit architecture.
- ios_stack_profiler_enabled = true
-}
-
-# Mutex priority inheritance is disabled by default due to security
-# vulnerabilities in older versions of Linux kernel and glibc. However,
-# Chromecast builds have full control over the platform and ensure that
-# the kernel and glibc versions used have patched the vulnerabilities,
-# so it is safe to use mutex priority inheritance on Chromecast platform.
-assert(!enable_mutex_priority_inheritance || is_castos || is_cast_android,
- "Do not enable PI mutexes without consulting the security team")
-
-assert(!is_nacl || is_nacl_saigo,
- "base must not be built in most nacl toolchains")
-
-# This is here instead of in //build because //build is DEPS'd in by a few
-# subprojects that still support MSVC.
-assert(!is_win || is_clang || use_cobalt_customizations,
- "only clang-cl is supported on Windows, see https://crbug.com/988071")
-
-if (is_apple) {
- assert(!use_blink || enable_mach_absolute_time_ticks,
- "use_blink requires mach absolute time ticks")
-
- assert(!is_mac || enable_mach_absolute_time_ticks,
- "mac requires mach absolute time ticks")
-}
-
-# Determines whether libevent should be dep.
-dep_libevent = !is_fuchsia && !is_win && !is_mac && !is_nacl
- && !use_cobalt_customizations
-
-# Determines whether message_pump_libevent should be used.
-use_libevent = dep_libevent && !is_ios
-
-if (is_android || is_robolectric) {
- import("//build/config/android/rules.gni")
-}
-
-if (is_fuchsia) {
- import("//third_party/fuchsia-sdk/sdk/build/fidl_library.gni")
-}
-
-# TODO(crbug.com/1280708): Drop toolchain_has_rust and move the C++ parser into
-# components/nacl to just run in-process there. Don't compile base::JSONReader
-# on NaCL at all.
-#
-# TODO(crbug.com/1304707): Drop toolchain_has_rust after we have support for all
-# our toolchains: Linux x86 is missing in order to build for Android.
-#
-# Rust to C++ type conversions.
-build_rust_base_conversions = toolchain_has_rust && enable_rust_base_conversions
-
-# The Rust implementation of base::JSONReader.
-build_rust_json_reader = toolchain_has_rust && enable_rust_json
-
-assert(build_rust_base_conversions || !build_rust_json_reader,
- "Cannot enable Rust JSON decoder without also base conversions")
-
-buildflag_header("rust_buildflags") {
- header = "rust_buildflags.h"
- flags = [
- "BUILD_RUST_JSON_READER=$build_rust_json_reader",
- "BUILD_RUST_BASE_CONVERSIONS=$build_rust_base_conversions",
- ]
-}
-
-if (is_win) {
- # This is in a separate config so the flags can be applied to dependents.
- # ldflags in GN aren't automatically inherited.
- config("base_win_linker_flags") {
- ldflags = [
- # Linking with shcore.lib causes the shcore api forwarder dll to load.
- "/DELAYLOAD:api-ms-win-shcore-scaling-l1-1-1.dll",
-
- # Linking with OneCore.lib causes the next two dlls to load.
- "/DELAYLOAD:api-ms-win-power-base-l1-1-0.dll",
- "/DELAYLOAD:api-ms-win-power-setting-l1-1-0.dll",
- "/DELAYLOAD:cfgmgr32.dll",
- "/DELAYLOAD:powrprof.dll",
- "/DELAYLOAD:setupapi.dll",
- "/DELAYLOAD:shcore.dll",
- ]
- }
-}
-
-if (is_android) {
- config("android_system_libs") {
- libs = [
- "android",
- "log", # Used by logging.cc.
- ]
- }
-}
-
-if (is_fuchsia) {
- config("fuchsia_sync_lib") {
- libs = [
- "sync", # Used by spinning_mutex.h.
- ]
- }
-}
-
-config("perfetto_config") {
- if (use_perfetto_client_library) {
- defines = [
- # Use TRACE_EVENT macro implementation from Perfetto. See
- # trace_event/trace_event_common.h.
- "BASE_USE_PERFETTO_CLIENT_LIBRARY=1",
- ]
- }
-}
-
-if (enable_pkeys && is_debug) {
- config("no_stack_protector") {
- cflags = [ "-fno-stack-protector" ]
- }
-}
-
-if (is_starboard) {
- config("starboard_config") {
- if (!is_gold) {
- defines = [ "ENABLE_TEST_DATA" ]
- }
- }
-}
-
-buildflag_header("ios_cronet_buildflags") {
- header = "ios_cronet_buildflags.h"
- header_dir = "base/message_loop"
- flags = [ "CRONET_BUILD=$is_cronet_build" ]
-}
-
-enable_message_pump_epoll =
- !use_cobalt_customizations && (is_linux || is_chromeos || is_android)
-buildflag_header("message_pump_buildflags") {
- header = "message_pump_buildflags.h"
- header_dir = "base/message_loop"
- flags = [ "ENABLE_MESSAGE_PUMP_EPOLL=$enable_message_pump_epoll" ]
-}
-
-# Base and everything it depends on should be a static library rather than
-# a source set. Base is more of a "library" in the classic sense in that many
-# small parts of it are used in many different contexts. This combined with a
-# few static initializers floating around means that dead code stripping
-# still leaves a lot of code behind that isn't always used. For example, this
-# saves more than 40K for a smaller target like chrome_elf.
-#
-# Use static libraries for the helper stuff as well for things like
-# //base/debug since those targets refer back to base code, which will force
-# base compilation units to be linked in where they wouldn't have otherwise.
-# This does not include test code (test support and anything in the test
-# directory) which should use source_set as is recommended for GN targets).
-component("base") {
- sources = [
- "allocator/allocator_check.cc",
- "allocator/allocator_check.h",
- "allocator/allocator_extension.cc",
- "allocator/allocator_extension.h",
- "allocator/dispatcher/configuration.h",
- "allocator/dispatcher/dispatcher.cc",
- "allocator/dispatcher/dispatcher.h",
- "allocator/dispatcher/initializer.h",
- "allocator/dispatcher/internal/dispatch_data.cc",
- "allocator/dispatcher/internal/dispatch_data.h",
- "allocator/dispatcher/internal/dispatcher_internal.h",
- "allocator/dispatcher/internal/tools.h",
- "allocator/dispatcher/reentry_guard.cc",
- "allocator/dispatcher/reentry_guard.h",
- "allocator/dispatcher/subsystem.h",
- "allocator/dispatcher/tls.cc",
- "allocator/dispatcher/tls.h",
- "at_exit.cc",
- "at_exit.h",
- "atomic_ref_count.h",
- "atomic_sequence_num.h",
- "atomicops.h",
- "atomicops_internals_atomicword_compat.h",
- "atomicops_internals_portable.h",
- "auto_reset.h",
- "barrier_callback.h",
- "barrier_closure.cc",
- "barrier_closure.h",
- "base64.cc",
- "base64.h",
- "base64url.cc",
- "base64url.h",
- "base_switches.h",
- "big_endian.cc",
- "big_endian.h",
- "bit_cast.h",
- "bits.h",
- "build_time.h",
- "callback_list.cc",
- "callback_list.h",
- "cancelable_callback.h",
- "check.cc",
- "check.h",
- "check_deref.h",
- "check_is_test.cc",
- "check_is_test.h",
- "check_op.cc",
- "check_op.h",
- "command_line.cc",
- "command_line.h",
- "compiler_specific.h",
- "component_export.h",
- "containers/adapters.h",
- "containers/buffer_iterator.h",
- "containers/checked_iterators.h",
- "containers/circular_deque.h",
- "containers/contains.h",
- "containers/contiguous_iterator.h",
- "containers/cxx20_erase.h",
- "containers/cxx20_erase_deque.h",
- "containers/cxx20_erase_forward_list.h",
- "containers/cxx20_erase_internal.h",
- "containers/cxx20_erase_list.h",
- "containers/cxx20_erase_map.h",
- "containers/cxx20_erase_set.h",
- "containers/cxx20_erase_string.h",
- "containers/cxx20_erase_unordered_map.h",
- "containers/cxx20_erase_unordered_set.h",
- "containers/cxx20_erase_vector.h",
- "containers/enum_set.h",
- "containers/extend.h",
- "containers/fixed_flat_map.h",
- "containers/fixed_flat_set.h",
- "containers/flat_map.h",
- "containers/flat_set.h",
- "containers/flat_tree.cc",
- "containers/flat_tree.h",
- "containers/id_map.h",
- "containers/intrusive_heap.cc",
- "containers/intrusive_heap.h",
- "containers/linked_list.cc",
- "containers/linked_list.h",
- "containers/lru_cache.h",
- "containers/small_map.h",
- "containers/span.h",
- "containers/span_rust.h",
- "containers/stack.h",
- "containers/stack_container.h",
- "containers/unique_ptr_adapters.h",
- "containers/util.h",
- "containers/vector_buffer.h",
- "cpu_reduction_experiment.cc",
- "cpu_reduction_experiment.h",
- "critical_closure.h",
- "cxx17_backports.h",
- "cxx20_is_constant_evaluated.h",
- "cxx20_to_address.h",
- "dcheck_is_on.h",
- "debug/alias.cc",
- "debug/alias.h",
- "debug/asan_invalid_access.cc",
- "debug/asan_invalid_access.h",
- "debug/asan_service.cc",
- "debug/asan_service.h",
- "debug/buffered_dwarf_reader.cc",
- "debug/buffered_dwarf_reader.h",
- "debug/debugger.cc",
- "debug/debugger.h",
- "debug/dump_without_crashing.cc",
- "debug/dump_without_crashing.h",
- "debug/dwarf_line_no.cc",
- "debug/dwarf_line_no.h",
- "debug/leak_annotations.h",
- "debug/profiler.cc",
- "debug/profiler.h",
- "debug/task_trace.cc",
- "debug/task_trace.h",
- "environment.cc",
- "environment.h",
- "export_template.h",
- "feature_list.cc",
- "feature_list.h",
- "features.cc",
- "features.h",
- "file_version_info.h",
- "files/dir_reader_fallback.h",
- "files/file.cc",
- "files/file.h",
- "files/file_error_or.h",
- "files/file_path.cc",
- "files/file_path.h",
- "files/file_tracing.cc",
- "files/file_tracing.h",
- "files/memory_mapped_file.cc",
- "files/memory_mapped_file.h",
- "files/platform_file.h",
- "files/safe_base_name.cc",
- "files/safe_base_name.h",
- "files/scoped_file.cc",
- "files/scoped_file.h",
- "format_macros.h",
- "functional/bind.h",
- "functional/bind_internal.h",
- "functional/callback.h",
- "functional/callback_forward.h",
- "functional/callback_helpers.cc",
- "functional/callback_helpers.h",
- "functional/callback_internal.cc",
- "functional/callback_internal.h",
- "functional/callback_tags.h",
- "functional/disallow_unretained.h",
- "functional/function_ref.h",
- "functional/identity.h",
- "functional/invoke.h",
- "functional/not_fn.h",
- "functional/overloaded.h",
- "functional/unretained_traits.h",
- "gtest_prod_util.h",
- "guid.h",
- "hash/hash.cc",
- "hash/hash.h",
- "hash/legacy_hash.cc",
- "hash/legacy_hash.h",
- "json/json_common.h",
- "json/json_parser.cc",
- "json/json_parser.h",
- "json/json_reader.cc",
- "json/json_reader.h",
- "json/json_string_value_serializer.cc",
- "json/json_string_value_serializer.h",
- "json/json_value_converter.cc",
- "json/json_value_converter.h",
- "json/json_writer.cc",
- "json/json_writer.h",
- "json/string_escape.cc",
- "json/string_escape.h",
- "json/values_util.cc",
- "json/values_util.h",
- "lazy_instance.h",
- "lazy_instance_helpers.cc",
- "lazy_instance_helpers.h",
- "linux_util.cc",
- "linux_util.h",
- "location.cc",
- "location.h",
- "logging.cc",
- "logging.h",
- "memory/aligned_memory.cc",
- "memory/aligned_memory.h",
- "memory/free_deleter.h",
- "memory/memory_pressure_listener.cc",
- "memory/memory_pressure_listener.h",
- "memory/memory_pressure_monitor.cc",
- "memory/memory_pressure_monitor.h",
- "memory/nonscannable_memory.cc",
- "memory/nonscannable_memory.h",
- "memory/page_size.h",
- "memory/platform_shared_memory_handle.cc",
- "memory/platform_shared_memory_handle.h",
- "memory/platform_shared_memory_mapper.h",
- "memory/platform_shared_memory_region.cc",
- "memory/platform_shared_memory_region.h",
- "memory/ptr_util.h",
- "memory/raw_ptr.h",
- "memory/raw_ptr_asan_bound_arg_tracker.cc",
- "memory/raw_ptr_asan_bound_arg_tracker.h",
- "memory/raw_ptr_asan_hooks.cc",
- "memory/raw_ptr_asan_hooks.h",
- "memory/raw_ptr_asan_service.cc",
- "memory/raw_ptr_asan_service.h",
- "memory/raw_ptr_exclusion.h",
- "memory/raw_ref.h",
- "memory/raw_scoped_refptr_mismatch_checker.h",
- "memory/read_only_shared_memory_region.cc",
- "memory/read_only_shared_memory_region.h",
- "memory/ref_counted.cc",
- "memory/ref_counted.h",
- "memory/ref_counted_delete_on_sequence.h",
- "memory/ref_counted_memory.cc",
- "memory/ref_counted_memory.h",
- "memory/safe_ref.h",
- "memory/scoped_policy.h",
- "memory/scoped_refptr.h",
- "memory/shared_memory_hooks.h",
- "memory/shared_memory_mapper.cc",
- "memory/shared_memory_mapper.h",
- "memory/shared_memory_mapping.cc",
- "memory/shared_memory_mapping.h",
- "memory/shared_memory_security_policy.cc",
- "memory/shared_memory_security_policy.h",
- "memory/shared_memory_tracker.cc",
- "memory/shared_memory_tracker.h",
- "memory/singleton.h",
- "memory/stack_allocated.h",
- "memory/unsafe_shared_memory_pool.cc",
- "memory/unsafe_shared_memory_pool.h",
- "memory/unsafe_shared_memory_region.cc",
- "memory/unsafe_shared_memory_region.h",
- "memory/values_equivalent.h",
- "memory/weak_auto_reset.h",
- "memory/weak_ptr.cc",
- "memory/weak_ptr.h",
- "memory/writable_shared_memory_region.cc",
- "memory/writable_shared_memory_region.h",
- "message_loop/message_pump.cc",
- "message_loop/message_pump.h",
- "message_loop/message_pump_default.cc",
- "message_loop/message_pump_default.h",
- "message_loop/message_pump_for_io.h",
- "message_loop/message_pump_for_ui.h",
- "message_loop/message_pump_type.h",
- "message_loop/timer_slack.h",
- "message_loop/work_id_provider.cc",
- "message_loop/work_id_provider.h",
- "metrics/bucket_ranges.cc",
- "metrics/bucket_ranges.h",
- "metrics/crc32.cc",
- "metrics/crc32.h",
- "metrics/dummy_histogram.cc",
- "metrics/dummy_histogram.h",
- "metrics/field_trial.cc",
- "metrics/field_trial.h",
- "metrics/field_trial_list_including_low_anonymity.cc",
- "metrics/field_trial_list_including_low_anonymity.h",
- "metrics/field_trial_param_associator.cc",
- "metrics/field_trial_param_associator.h",
- "metrics/field_trial_params.cc",
- "metrics/field_trial_params.h",
- "metrics/histogram.cc",
- "metrics/histogram.h",
- "metrics/histogram_base.cc",
- "metrics/histogram_base.h",
- "metrics/histogram_delta_serialization.cc",
- "metrics/histogram_delta_serialization.h",
- "metrics/histogram_flattener.h",
- "metrics/histogram_functions.cc",
- "metrics/histogram_functions.h",
- "metrics/histogram_macros.h",
- "metrics/histogram_macros_internal.h",
- "metrics/histogram_macros_local.h",
- "metrics/histogram_samples.cc",
- "metrics/histogram_samples.h",
- "metrics/histogram_snapshot_manager.cc",
- "metrics/histogram_snapshot_manager.h",
- "metrics/metrics_hashes.cc",
- "metrics/metrics_hashes.h",
- "metrics/persistent_histogram_allocator.cc",
- "metrics/persistent_histogram_allocator.h",
- "metrics/persistent_memory_allocator.cc",
- "metrics/persistent_memory_allocator.h",
- "metrics/persistent_sample_map.cc",
- "metrics/persistent_sample_map.h",
- "metrics/ranges_manager.cc",
- "metrics/ranges_manager.h",
- "metrics/record_histogram_checker.h",
- "metrics/sample_map.cc",
- "metrics/sample_map.h",
- "metrics/sample_vector.cc",
- "metrics/sample_vector.h",
- "metrics/single_sample_metrics.cc",
- "metrics/single_sample_metrics.h",
- "metrics/sparse_histogram.cc",
- "metrics/sparse_histogram.h",
- "metrics/statistics_recorder.cc",
- "metrics/statistics_recorder.h",
- "metrics/user_metrics.cc",
- "metrics/user_metrics.h",
- "metrics/user_metrics_action.h",
- "no_destructor.h",
- "notreached.h",
- "observer_list.h",
- "observer_list_internal.cc",
- "observer_list_internal.h",
- "observer_list_threadsafe.cc",
- "observer_list_threadsafe.h",
- "observer_list_types.cc",
- "observer_list_types.h",
- "one_shot_event.cc",
- "one_shot_event.h",
- "parameter_pack.h",
- "pending_task.cc",
- "pending_task.h",
- "pickle.cc",
- "pickle.h",
- "power_monitor/battery_level_provider.cc",
- "power_monitor/battery_level_provider.h",
- "power_monitor/battery_state_sampler.cc",
- "power_monitor/battery_state_sampler.h",
- "power_monitor/moving_average.cc",
- "power_monitor/moving_average.h",
- "power_monitor/power_monitor.cc",
- "power_monitor/power_monitor.h",
- "power_monitor/power_monitor_device_source.cc",
- "power_monitor/power_monitor_device_source.h",
- "power_monitor/power_monitor_features.cc",
- "power_monitor/power_monitor_features.h",
- "power_monitor/power_monitor_source.cc",
- "power_monitor/power_monitor_source.h",
- "power_monitor/power_observer.h",
- "power_monitor/sampling_event_source.cc",
- "power_monitor/sampling_event_source.h",
- "power_monitor/timer_sampling_event_source.cc",
- "power_monitor/timer_sampling_event_source.h",
- "process/current_process.cc",
- "process/current_process.h",
- "process/current_process_test.h",
- "process/environment_internal.cc",
- "process/environment_internal.h",
- "process/process.h",
- "process/process_handle.cc",
- "process/process_handle.h",
- "process/process_info.h",
- "process/process_metrics_iocounters.h",
- "profiler/frame.cc",
- "profiler/frame.h",
- "profiler/metadata_recorder.cc",
- "profiler/metadata_recorder.h",
- "profiler/module_cache.cc",
- "profiler/module_cache.h",
- "profiler/profile_builder.h",
- "profiler/register_context.h",
- "profiler/sample_metadata.cc",
- "profiler/sample_metadata.h",
- "profiler/sampling_profiler_thread_token.cc",
- "profiler/sampling_profiler_thread_token.h",
- "profiler/stack_buffer.cc",
- "profiler/stack_buffer.h",
- "profiler/stack_copier.cc",
- "profiler/stack_copier.h",
- "profiler/stack_copier_suspend.cc",
- "profiler/stack_copier_suspend.h",
- "profiler/stack_sampler.cc",
- "profiler/stack_sampler.h",
- "profiler/stack_sampling_profiler.cc",
- "profiler/stack_sampling_profiler.h",
- "profiler/suspendable_thread_delegate.h",
- "profiler/thread_delegate.h",
- "profiler/unwinder.cc",
- "profiler/unwinder.h",
- "rand_util.cc",
- "rand_util.h",
- "ranges/algorithm.h",
- "ranges/functional.h",
- "ranges/ranges.h",
- "run_loop.cc",
- "run_loop.h",
- "sampling_heap_profiler/lock_free_address_hash_set.cc",
- "sampling_heap_profiler/lock_free_address_hash_set.h",
- "sampling_heap_profiler/poisson_allocation_sampler.cc",
- "sampling_heap_profiler/poisson_allocation_sampler.h",
- "sampling_heap_profiler/sampling_heap_profiler.cc",
- "sampling_heap_profiler/sampling_heap_profiler.h",
- "scoped_add_feature_flags.cc",
- "scoped_add_feature_flags.h",
- "scoped_clear_last_error.h",
- "scoped_environment_variable_override.cc",
- "scoped_environment_variable_override.h",
- "scoped_generic.h",
- "scoped_multi_source_observation.h",
- "scoped_observation.h",
- "scoped_observation_traits.h",
- "scoped_observation_traits_internal.h",
- "sequence_checker.cc",
- "sequence_checker.h",
- "sequence_checker_impl.cc",
- "sequence_checker_impl.h",
- "sequence_token.cc",
- "sequence_token.h",
- "state_transitions.h",
- "stl_util.h",
- "strings/abseil_string_number_conversions.cc",
- "strings/abseil_string_number_conversions.h",
- "strings/escape.cc",
- "strings/escape.h",
- "strings/latin1_string_conversions.cc",
- "strings/latin1_string_conversions.h",
- "strings/pattern.cc",
- "strings/pattern.h",
- "strings/safe_sprintf.cc",
- "strings/safe_sprintf.h",
- "strings/strcat.cc",
- "strings/strcat.h",
- "strings/strcat_internal.h",
- "strings/string_number_conversions.cc",
- "strings/string_number_conversions.h",
- "strings/string_number_conversions_internal.h",
- "strings/string_piece.cc",
- "strings/string_piece.h",
- "strings/string_piece_forward.h",
- "strings/string_piece_rust.h",
- "strings/string_split.cc",
- "strings/string_split.h",
- "strings/string_split_internal.h",
- "strings/string_tokenizer.h",
- "strings/string_util.cc",
- "strings/string_util.h",
- "strings/string_util_constants.cc",
- "strings/string_util_impl_helpers.h",
- "strings/string_util_internal.h",
- "strings/stringize_macros.h",
- "strings/stringprintf.cc",
- "strings/stringprintf.h",
- "strings/sys_string_conversions.h",
- "strings/to_string.h",
- "strings/utf_offset_string_conversions.cc",
- "strings/utf_offset_string_conversions.h",
- "strings/utf_string_conversion_utils.cc",
- "strings/utf_string_conversion_utils.h",
- "strings/utf_string_conversions.cc",
- "strings/utf_string_conversions.h",
- "substring_set_matcher/matcher_string_pattern.cc",
- "substring_set_matcher/matcher_string_pattern.h",
- "substring_set_matcher/substring_set_matcher.cc",
- "substring_set_matcher/substring_set_matcher.h",
- "supports_user_data.cc",
- "supports_user_data.h",
- "synchronization/atomic_flag.cc",
- "synchronization/atomic_flag.h",
- "synchronization/condition_variable.h",
- "synchronization/lock.cc",
- "synchronization/lock.h",
- "synchronization/lock_impl.h",
- "synchronization/waitable_event.cc",
- "synchronization/waitable_event.h",
- "synchronization/waitable_event_watcher.h",
- "sys_byteorder.h",
- "syslog_logging.cc",
- "syslog_logging.h",
- "system/system_monitor.cc",
- "system/system_monitor.h",
- "task/bind_post_task.h",
- "task/bind_post_task_internal.h",
- "task/cancelable_task_tracker.cc",
- "task/cancelable_task_tracker.h",
- "task/common/checked_lock.h",
- "task/common/checked_lock_impl.cc",
- "task/common/checked_lock_impl.h",
- "task/common/lazy_now.cc",
- "task/common/lazy_now.h",
- "task/common/operations_controller.cc",
- "task/common/operations_controller.h",
- "task/common/scoped_defer_task_posting.cc",
- "task/common/scoped_defer_task_posting.h",
- "task/common/task_annotator.cc",
- "task/common/task_annotator.h",
- "task/current_thread.cc",
- "task/current_thread.h",
- "task/default_delayed_task_handle_delegate.cc",
- "task/default_delayed_task_handle_delegate.h",
- "task/deferred_sequenced_task_runner.cc",
- "task/deferred_sequenced_task_runner.h",
- "task/delay_policy.h",
- "task/delayed_task_handle.cc",
- "task/delayed_task_handle.h",
- "task/lazy_thread_pool_task_runner.cc",
- "task/lazy_thread_pool_task_runner.h",
- "task/post_job.cc",
- "task/post_job.h",
- "task/post_task_and_reply_with_result_internal.h",
- "task/scoped_set_task_priority_for_current_thread.cc",
- "task/scoped_set_task_priority_for_current_thread.h",
- "task/sequence_manager/associated_thread_id.cc",
- "task/sequence_manager/associated_thread_id.h",
- "task/sequence_manager/atomic_flag_set.cc",
- "task/sequence_manager/atomic_flag_set.h",
- "task/sequence_manager/delayed_task_handle_delegate.cc",
- "task/sequence_manager/delayed_task_handle_delegate.h",
- "task/sequence_manager/enqueue_order.h",
- "task/sequence_manager/enqueue_order_generator.cc",
- "task/sequence_manager/enqueue_order_generator.h",
- "task/sequence_manager/fence.cc",
- "task/sequence_manager/fence.h",
- "task/sequence_manager/hierarchical_timing_wheel.cc",
- "task/sequence_manager/hierarchical_timing_wheel.h",
- "task/sequence_manager/lazily_deallocated_deque.h",
- "task/sequence_manager/sequence_manager.cc",
- "task/sequence_manager/sequence_manager.h",
- "task/sequence_manager/sequence_manager_impl.cc",
- "task/sequence_manager/sequence_manager_impl.h",
- "task/sequence_manager/sequenced_task_source.cc",
- "task/sequence_manager/sequenced_task_source.h",
- "task/sequence_manager/task_order.cc",
- "task/sequence_manager/task_order.h",
- "task/sequence_manager/task_queue.cc",
- "task/sequence_manager/task_queue.h",
- "task/sequence_manager/task_queue_impl.cc",
- "task/sequence_manager/task_queue_impl.h",
- "task/sequence_manager/task_queue_selector.cc",
- "task/sequence_manager/task_queue_selector.h",
- "task/sequence_manager/task_time_observer.h",
- "task/sequence_manager/tasks.cc",
- "task/sequence_manager/tasks.h",
- "task/sequence_manager/thread_controller.cc",
- "task/sequence_manager/thread_controller.h",
- "task/sequence_manager/thread_controller_impl.cc",
- "task/sequence_manager/thread_controller_impl.h",
- "task/sequence_manager/thread_controller_power_monitor.cc",
- "task/sequence_manager/thread_controller_power_monitor.h",
- "task/sequence_manager/thread_controller_with_message_pump_impl.cc",
- "task/sequence_manager/thread_controller_with_message_pump_impl.h",
- "task/sequence_manager/time_domain.cc",
- "task/sequence_manager/time_domain.h",
- "task/sequence_manager/timing_wheel.cc",
- "task/sequence_manager/timing_wheel.h",
- "task/sequence_manager/wake_up_queue.cc",
- "task/sequence_manager/wake_up_queue.h",
- "task/sequence_manager/work_deduplicator.cc",
- "task/sequence_manager/work_deduplicator.h",
- "task/sequence_manager/work_queue.cc",
- "task/sequence_manager/work_queue.h",
- "task/sequence_manager/work_queue_sets.cc",
- "task/sequence_manager/work_queue_sets.h",
- "task/sequenced_task_runner.cc",
- "task/sequenced_task_runner.h",
- "task/sequenced_task_runner_helpers.h",
- "task/single_thread_task_executor.cc",
- "task/single_thread_task_executor.h",
- "task/single_thread_task_runner.cc",
- "task/single_thread_task_runner.h",
- "task/single_thread_task_runner_thread_mode.h",
- "task/task_features.cc",
- "task/task_features.h",
- "task/task_observer.h",
- "task/task_runner.cc",
- "task/task_runner.h",
- "task/task_traits.cc",
- "task/task_traits.h",
- "task/thread_pool.cc",
- "task/thread_pool.h",
- "task/thread_pool/delayed_priority_queue.cc",
- "task/thread_pool/delayed_priority_queue.h",
- "task/thread_pool/delayed_task_manager.cc",
- "task/thread_pool/delayed_task_manager.h",
- "task/thread_pool/environment_config.cc",
- "task/thread_pool/environment_config.h",
- "task/thread_pool/job_task_source.cc",
- "task/thread_pool/job_task_source.h",
- "task/thread_pool/pooled_parallel_task_runner.cc",
- "task/thread_pool/pooled_parallel_task_runner.h",
- "task/thread_pool/pooled_sequenced_task_runner.cc",
- "task/thread_pool/pooled_sequenced_task_runner.h",
- "task/thread_pool/pooled_single_thread_task_runner_manager.cc",
- "task/thread_pool/pooled_single_thread_task_runner_manager.h",
- "task/thread_pool/pooled_task_runner_delegate.cc",
- "task/thread_pool/pooled_task_runner_delegate.h",
- "task/thread_pool/priority_queue.cc",
- "task/thread_pool/priority_queue.h",
- "task/thread_pool/sequence.cc",
- "task/thread_pool/sequence.h",
- "task/thread_pool/service_thread.cc",
- "task/thread_pool/service_thread.h",
- "task/thread_pool/task.cc",
- "task/thread_pool/task.h",
- "task/thread_pool/task_source.cc",
- "task/thread_pool/task_source.h",
- "task/thread_pool/task_source_sort_key.cc",
- "task/thread_pool/task_source_sort_key.h",
- "task/thread_pool/task_tracker.cc",
- "task/thread_pool/task_tracker.h",
- "task/thread_pool/thread_group.cc",
- "task/thread_pool/thread_group.h",
- "task/thread_pool/thread_group_impl.cc",
- "task/thread_pool/thread_group_impl.h",
- "task/thread_pool/thread_pool_impl.cc",
- "task/thread_pool/thread_pool_impl.h",
- "task/thread_pool/thread_pool_instance.cc",
- "task/thread_pool/thread_pool_instance.h",
- "task/thread_pool/tracked_ref.h",
- "task/thread_pool/worker_thread.cc",
- "task/thread_pool/worker_thread.h",
- "task/thread_pool/worker_thread_observer.h",
- "task/thread_pool/worker_thread_set.cc",
- "task/thread_pool/worker_thread_set.h",
- "task/updateable_sequenced_task_runner.h",
- "template_util.h",
- "test/malloc_wrapper.h",
- "test/scoped_logging_settings.h",
- "test/spin_wait.h",
- "third_party/cityhash/city.cc",
- "third_party/cityhash/city.h",
- "third_party/cityhash_v103/src/city_v103.cc",
- "third_party/cityhash_v103/src/city_v103.h",
- "third_party/icu/icu_utf.h",
- "third_party/nspr/prtime.cc",
- "third_party/nspr/prtime.h",
- "third_party/superfasthash/superfasthash.c",
- "thread_annotations.h",
- "threading/hang_watcher.cc",
- "threading/hang_watcher.h",
- "threading/platform_thread.cc",
- "threading/platform_thread.h",
- "threading/platform_thread_ref.cc",
- "threading/platform_thread_ref.h",
- "threading/post_task_and_reply_impl.cc",
- "threading/post_task_and_reply_impl.h",
- "threading/scoped_blocking_call.cc",
- "threading/scoped_blocking_call.h",
- "threading/scoped_blocking_call_internal.cc",
- "threading/scoped_blocking_call_internal.h",
- "threading/scoped_thread_priority.cc",
- "threading/scoped_thread_priority.h",
- "threading/sequence_bound.h",
- "threading/sequence_bound_internal.h",
- "threading/sequence_local_storage_map.cc",
- "threading/sequence_local_storage_map.h",
- "threading/sequence_local_storage_slot.cc",
- "threading/sequence_local_storage_slot.h",
- "threading/simple_thread.cc",
- "threading/simple_thread.h",
- "threading/thread.cc",
- "threading/thread.h",
- "threading/thread_checker.cc",
- "threading/thread_checker.h",
- "threading/thread_checker_impl.cc",
- "threading/thread_checker_impl.h",
- "threading/thread_collision_warner.cc",
- "threading/thread_collision_warner.h",
- "threading/thread_id_name_manager.cc",
- "threading/thread_id_name_manager.h",
- "threading/thread_local.h",
- "threading/thread_local_internal.h",
- "threading/thread_local_storage.cc",
- "threading/thread_local_storage.h",
- "threading/thread_restrictions.cc",
- "threading/thread_restrictions.h",
- "threading/threading_features.h",
- "threading/watchdog.cc",
- "threading/watchdog.h",
- "time/clock.cc",
- "time/clock.h",
- "time/default_clock.cc",
- "time/default_clock.h",
- "time/default_tick_clock.cc",
- "time/default_tick_clock.h",
- "time/tick_clock.cc",
- "time/tick_clock.h",
- "time/time.cc",
- "time/time.h",
- "time/time_delta_from_string.cc",
- "time/time_delta_from_string.h",
- "time/time_override.cc",
- "time/time_override.h",
- "time/time_to_iso8601.cc",
- "time/time_to_iso8601.h",
- "timer/elapsed_timer.cc",
- "timer/elapsed_timer.h",
- "timer/hi_res_timer_manager.h",
- "timer/lap_timer.cc",
- "timer/lap_timer.h",
- "timer/timer.cc",
- "timer/timer.h",
- "timer/wall_clock_timer.cc",
- "timer/wall_clock_timer.h",
- "token.cc",
- "token.h",
- "trace_event/base_tracing.h",
- "trace_event/base_tracing_forward.h",
- "trace_event/common/trace_event_common.h",
- "trace_event/heap_profiler_allocation_context.cc",
- "trace_event/heap_profiler_allocation_context.h",
- "trace_event/heap_profiler_allocation_context_tracker.cc",
- "trace_event/heap_profiler_allocation_context_tracker.h",
- "trace_event/memory_allocator_dump_guid.cc",
- "trace_event/memory_allocator_dump_guid.h",
- "trace_event/trace_id_helper.cc",
- "trace_event/trace_id_helper.h",
- "traits_bag.h",
- "tuple.h",
- "types/always_false.h",
- "types/cxx23_to_underlying.h",
- "types/expected.h",
- "types/expected_internal.h",
- "types/id_type.h",
- "types/optional_ref.h",
- "types/optional_util.h",
- "types/pass_key.h",
- "types/strong_alias.h",
- "types/supports_ostream_operator.h",
- "types/token_type.h",
- "types/variant_util.h",
- "unguessable_token.cc",
- "unguessable_token.h",
- "uuid.cc",
- "uuid.h",
- "value_iterators.cc",
- "value_iterators.h",
- "values.cc",
- "values.h",
- "version.cc",
- "version.h",
- "vlog.cc",
- "vlog.h",
- ]
-
- if (use_cobalt_customizations && current_toolchain == default_toolchain) {
- sources += [
- "base_paths_starboard.cc",
- "base_paths_starboard.h",
- "debug/debugger_starboard.cc",
- "debug/stack_trace_starboard.cc",
- "files/file_enumerator_starboard.cc",
- "files/file_path_watcher_stub.cc",
- "files/file_starboard.cc",
- "files/file_util_starboard.cc",
- "files/memory_mapped_file_starboard.cc",
- "memory/page_size_starboard.cc",
- "memory/platform_shared_memory_mapper_starboard.cc",
- "memory/platform_shared_memory_region_starboard.cc",
- "message_loop/message_pump_io_starboard.cc",
- "message_loop/message_pump_io_starboard.h",
- "message_loop/message_pump_ui_starboard.cc",
- "message_loop/message_pump_ui_starboard.h",
- "process/launch.cc",
- "process/launch.h",
- "process/launch_starboard.cc",
- "process/memory_starboard.cc",
- "process/process_starboard.cc",
- "profiler/module_cache_starboard.cc",
- "profiler/stack_sampler_starboard.cc",
- "rand_util_starboard.cc",
- "strings/string_util_starboard.cc",
- "strings/string_util_starboard.h",
- "strings/sys_string_conversions_starboard.cc",
- "synchronization/condition_variable_starboard.cc",
- "synchronization/lock_impl_starboard.cc",
- "synchronization/waitable_event_starboard.cc",
- "synchronization/waitable_event_watcher_starboard.cc",
- "sys_info_starboard.cc",
- "threading/platform_thread_starboard.cc",
- "threading/thread_local_storage_starboard.cc",
- "threading/thread_task_runner_handle.cc",
- "time/time_now_starboard.cc",
- "time/time_starboard.cc",
- ]
- }
-
- # Various files that are unused in the Chromium build, but presumably here to
- # make downstream's life easier. They are not included in the main sources
- # list to avoid breaking GN formatting's auto-sorting.
- sources += [
- #"process/process_handle_freebsd.cc",
- #"process/process_iterator_freebsd.cc",
- #"process/process_metrics_freebsd.cc",
- #"system/sys_info_freebsd.cc",
- #"process/process_iterator_openbsd.cc",
- #"process/process_handle_openbsd.cc",
- #"process/process_metrics_openbsd.cc",
- #"system/sys_info_openbsd.cc",
- ]
-
- if (!use_cobalt_customizations && is_posix) {
- sources += [
- "debug/debugger_posix.cc",
- "file_descriptor_posix.cc",
- "file_descriptor_posix.h",
- "files/dir_reader_posix.h",
- "files/file_posix.cc",
- "files/memory_mapped_file_posix.cc",
- "message_loop/watchable_io_message_pump_posix.cc",
- "message_loop/watchable_io_message_pump_posix.h",
- "posix/eintr_wrapper.h",
- "posix/file_descriptor_shuffle.cc",
- "posix/file_descriptor_shuffle.h",
- "posix/global_descriptors.cc",
- "posix/global_descriptors.h",
- "posix/safe_strerror.cc",
- "posix/safe_strerror.h",
- "process/process_handle_posix.cc",
- "strings/string_util_posix.h",
- "synchronization/condition_variable_posix.cc",
- "synchronization/lock_impl_posix.cc",
- "threading/platform_thread_posix.cc",
- "threading/thread_local_storage_posix.cc",
- "time/time_conversion_posix.cc",
- "timer/hi_res_timer_manager_posix.cc",
- ]
- }
-
- if (!use_cobalt_customizations && (is_linux || is_chromeos)) {
- sources += [
- "debug/proc_maps_linux.cc",
- "debug/proc_maps_linux.h",
- "files/dir_reader_linux.h",
- "files/scoped_file_linux.cc",
- "process/internal_linux.cc",
- "process/internal_linux.h",
- "process/memory_linux.cc",
- "process/process_handle_linux.cc",
- "process/process_iterator_linux.cc",
- "process/process_linux.cc",
- "process/process_metrics_linux.cc",
- "threading/platform_thread_linux.cc",
- "threading/thread_type_delegate.cc",
- "threading/thread_type_delegate.h",
- ]
- }
-
- if (use_cobalt_customizations) {
- sources += [
- "process/internal_linux.cc",
- "process/internal_linux.h",
- ]
- }
-
- if (!use_cobalt_customizations && (is_linux || is_chromeos || is_android)) {
- sources += [
- "files/file_path_watcher_inotify.cc",
- "files/file_path_watcher_inotify.h",
- ]
- }
-
- all_dependent_configs = []
- defines = [ "BASE_IMPLEMENTATION" ]
- data = []
- data_deps = []
- libs = []
- frameworks = []
-
- configs += [
- "//build/config:precompiled_headers",
- "//build/config/compiler:prevent_unsafe_narrowing",
- "//build/config/compiler:wexit_time_destructors",
- "//build/config/compiler:wglobal_constructors",
- ]
-
- deps = [
- ":message_pump_buildflags",
- "//base/allocator:buildflags",
- "//base/allocator/partition_allocator:raw_ptr",
- "//base/third_party/double_conversion",
- "//base/third_party/dynamic_annotations",
- "//build:blink_buildflags",
- "//build:branding_buildflags",
- "//build/config/compiler:compiler_buildflags",
- "//third_party/modp_b64",
- ]
-
- if (is_starboard) {
- deps -= [ "//base/allocator/partition_allocator:raw_ptr" ]
- # TODO: b/330221826 Change to |public_configs| with matching dependencies.
- all_dependent_configs += [ ":starboard_config" ]
- }
-
- if (is_starboard && current_toolchain != host_toolchain) {
- deps += [ "//starboard:starboard_group" ]
- }
-
- # `raw_ptr` cannot be made a component due to CRT symbol issues.
- # Its gateway to being a component is through `//base`, so we have
- # to provide the appropriate `#define` here.
- defines += [ "IS_RAW_PTR_IMPL" ]
-
- if (is_apple) {
- deps += [ "//base/time/buildflags:buildflags" ]
- }
-
- if (build_rust_json_reader) {
- deps += [ "//third_party/rust/serde_json_lenient/v0_1/wrapper" ]
- }
-
- # native_unwinder_android is intended for use solely via a dynamic feature
- # module, to avoid increasing Chrome's executable size.
- assert_no_deps = [ ":native_unwinder_android" ]
-
- public_deps = [
- ":anchor_functions_buildflags",
- ":base_static",
- ":build_date",
- ":cfi_buildflags",
- ":clang_profiling_buildflags",
- ":debugging_buildflags",
- ":feature_list_buildflags",
- ":ios_cronet_buildflags",
- ":logging_buildflags",
- ":orderfile_buildflags",
- ":power_monitor_buildflags",
- ":profiler_buildflags",
- ":rust_buildflags",
- ":sanitizer_buildflags",
- ":synchronization_buildflags",
- ":tracing_buildflags",
- "//base/allocator/partition_allocator:buildflags",
- "//base/numerics:base_numerics",
- "//build:chromecast_buildflags",
- "//build:chromeos_buildflags",
- "//third_party/abseil-cpp:absl",
- ]
-
- if (is_starboard) {
- public_deps -= [ "//base/allocator/partition_allocator:buildflags" ]
- }
-
- if (build_rust_base_conversions) {
- # Base provides conversions between CXX types and base types (e.g.
- # StringPiece).
- public_deps += [ "//build/rust:cxx_cppdeps" ]
- }
-
- if (use_custom_libcxx && enable_safe_libcxx && !is_debug) {
- public_deps += [ ":nodebug_assertion" ]
- }
-
- # Needed for <atomic> if using newer C++ library than sysroot, except if
- # building inside the cros_sdk environment - use host_toolchain as a
- # more robust check for this.
- if (!use_sysroot && (is_android || is_chromeos || (is_linux && !is_castos)) &&
- host_toolchain != "//build/toolchain/cros:host" && !sb_is_modular) {
- libs += [ "atomic" ]
- }
-
- if (use_allocator_shim) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim.cc",
- "allocator/partition_allocator/shim/allocator_shim.h",
- "allocator/partition_allocator/shim/allocator_shim_internals.h",
- ]
- if (use_partition_alloc) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.cc",
- "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.h",
- ]
- }
- if (is_android) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim_override_cpp_symbols.h",
- "allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h",
- ]
- all_dependent_configs += [ "//base/allocator:wrap_malloc_symbols" ]
- }
- if (is_apple) {
- sources += [
- "allocator/early_zone_registration_mac.h",
- "allocator/partition_allocator/shim/allocator_shim_override_mac_default_zone.h",
- "allocator/partition_allocator/shim/allocator_shim_override_mac_symbols.h",
- ]
- configs += [ "//base/allocator:mac_no_default_new_delete_symbols" ]
- }
- if (is_chromeos || is_linux) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim_override_cpp_symbols.h",
- "allocator/partition_allocator/shim/allocator_shim_override_glibc_weak_symbols.h",
- "allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h",
- ]
- }
- if (is_win) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim_override_ucrt_symbols_win.h",
- "allocator/partition_allocator/shim/winheap_stubs_win.cc",
- "allocator/partition_allocator/shim/winheap_stubs_win.h",
- ]
- }
-
- if (!use_partition_alloc_as_malloc) {
- if (is_android) {
- sources += [ "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc" ]
- }
- if (is_apple) {
- sources += [ "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc" ]
- }
- if (is_chromeos || is_linux) {
- sources += [ "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_glibc.cc" ]
- }
- if (is_win) {
- sources += [ "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_winheap.cc" ]
- }
- }
- }
-
- if (use_clang_profiling) {
- # Call-sites use this conditional on the CLANG_PROFILING macro, for clarity.
- sources += [
- "test/clang_profiling.cc",
- "test/clang_profiling.h",
- ]
- }
-
- # Allow more direct string conversions on platforms with native utf8
- # strings
- if (is_apple || is_chromeos || is_castos || is_cast_android || is_fuchsia) {
- defines += [ "SYSTEM_NATIVE_UTF8" ]
- }
-
- # Android.
- if (is_android && !use_cobalt_customizations) {
- sources += [
- "android/android_hardware_buffer_compat.cc",
- "android/android_hardware_buffer_compat.h",
- "android/android_image_reader_abi.h",
- "android/android_image_reader_compat.cc",
- "android/android_image_reader_compat.h",
- "android/apk_assets.cc",
- "android/apk_assets.h",
- "android/application_status_listener.cc",
- "android/application_status_listener.h",
- "android/base_feature_list.cc",
- "android/base_features.cc",
- "android/base_features.h",
- "android/build_info.cc",
- "android/build_info.h",
- "android/bundle_utils.cc",
- "android/bundle_utils.h",
- "android/child_process_binding_types.h",
- "android/child_process_service.cc",
- "android/content_uri_utils.cc",
- "android/content_uri_utils.h",
- "android/cpu_features.cc",
- "android/early_trace_event_binding.cc",
- "android/early_trace_event_binding.h",
- "android/event_log.cc",
- "android/event_log.h",
- "android/feature_list_jni.cc",
- "android/features_jni.cc",
- "android/field_trial_list.cc",
- "android/important_file_writer_android.cc",
- "android/int_string_callback.cc",
- "android/int_string_callback.h",
- "android/java_handler_thread.cc",
- "android/java_handler_thread.h",
- "android/java_heap_dump_generator.cc",
- "android/java_heap_dump_generator.h",
- "android/java_runtime.cc",
- "android/java_runtime.h",
- "android/library_loader/anchor_functions.cc",
- "android/library_loader/anchor_functions.h",
- "android/library_loader/library_prefetcher.cc",
- "android/library_loader/library_prefetcher.h",
- "android/library_loader/library_prefetcher_hooks.cc",
- "android/locale_utils.cc",
- "android/locale_utils.h",
- "android/meminfo_dump_provider.cc",
- "android/meminfo_dump_provider.h",
- "android/memory_pressure_listener_android.cc",
- "android/memory_pressure_listener_android.h",
- "android/path_service_android.cc",
- "android/path_utils.cc",
- "android/path_utils.h",
- "android/radio_utils.cc",
- "android/radio_utils.h",
- "android/reached_addresses_bitset.cc",
- "android/reached_addresses_bitset.h",
- "android/reached_code_profiler.cc",
- "android/reached_code_profiler.h",
- "android/remove_stale_data.cc",
- "android/remove_stale_data.h",
- "android/scoped_hardware_buffer_fence_sync.cc",
- "android/scoped_hardware_buffer_fence_sync.h",
- "android/scoped_hardware_buffer_handle.cc",
- "android/scoped_hardware_buffer_handle.h",
- "android/statistics_recorder_android.cc",
- "android/sys_utils.cc",
- "android/sys_utils.h",
- "android/task_scheduler/post_task_android.cc",
- "android/task_scheduler/post_task_android.h",
- "android/task_scheduler/task_runner_android.cc",
- "android/task_scheduler/task_runner_android.h",
- "android/task_scheduler/task_traits_android.h",
- "android/thread_instruction_count.cc",
- "android/thread_instruction_count.h",
- "android/timezone_utils.cc",
- "android/timezone_utils.h",
- "android/unguessable_token_android.cc",
- "android/unguessable_token_android.h",
- "debug/stack_trace_android.cc",
- "files/file_util_android.cc",
- "files/scoped_file_android.cc",
- "memory/platform_shared_memory_mapper_android.cc",
- "memory/platform_shared_memory_region_android.cc",
- "message_loop/message_pump_android.cc",
- "message_loop/message_pump_android.h",
- "os_compat_android.cc",
- "os_compat_android.h",
- "process/process_android.cc",
- "profiler/native_unwinder_android_map_delegate.h",
- "profiler/native_unwinder_android_memory_regions_map.h",
- "profiler/stack_sampler_android.cc",
- "system/sys_info_android.cc",
- "threading/platform_thread_android.cc",
-
- # Android uses some Linux sources.
- "debug/elf_reader.cc",
- "debug/elf_reader.h",
- "debug/proc_maps_linux.cc",
- "debug/proc_maps_linux.h",
- "power_monitor/power_monitor_device_source_android.cc",
- "process/internal_linux.cc",
- "process/internal_linux.h",
- "process/memory_linux.cc",
- "process/process_handle_linux.cc",
- "process/process_iterator_linux.cc",
- "process/process_metrics_linux.cc",
- "system/sys_info_linux.cc",
- ]
-
- deps += [
- "//third_party/android_ndk:cpu_features",
- "//third_party/ashmem",
- ]
-
- # Needs to be a public config so that dependent targets link against it as
- # well when doing a component build.
- public_configs = [ ":android_system_libs" ]
-
- if (can_unwind_with_cfi_table) {
- sources += [
- "trace_event/cfi_backtrace_android.cc",
- "trace_event/cfi_backtrace_android.h",
- ]
- }
- if (current_cpu == "arm") {
- sources += [
- "profiler/chrome_unwind_info_android.cc",
- "profiler/chrome_unwind_info_android.h",
- "profiler/chrome_unwinder_android.cc",
- "profiler/chrome_unwinder_android.h",
- ]
- }
-
- if (current_cpu == "arm64") {
- sources += [
- "profiler/frame_pointer_unwinder.cc",
- "profiler/frame_pointer_unwinder.h",
- ]
- }
-
- if (current_cpu != "arm" && current_cpu != "arm64") {
- # The reached code profiler is only supported on Android arm arch.
- sources -= [ "android/reached_code_profiler.cc" ]
- sources += [ "android/reached_code_profiler_stub.cc" ]
- }
-
- # This is actually a linker script, but it can be added to the link in the
- # same way as a library.
- libs += [ "android/library_loader/anchor_functions.lds" ]
- } # is_android
-
- if (build_allocation_stack_trace_recorder) {
- sources += [
- "debug/allocation_trace.cc",
- "debug/allocation_trace.h",
- ]
- }
-
- if (is_robolectric) {
- # Make jni.h available.
- configs += [ "//third_party/jdk" ]
- }
- if ((is_android || is_robolectric) && !use_cobalt_customizations) {
- sources += [
- "android/base_jni_onload.cc",
- "android/base_jni_onload.h",
- "android/callback_android.cc",
- "android/callback_android.h",
- "android/command_line_android.cc",
- "android/java_exception_reporter.cc",
- "android/java_exception_reporter.h",
- "android/jni_android.cc",
- "android/jni_android.h",
- "android/jni_array.cc",
- "android/jni_array.h",
- "android/jni_generator/jni_generator_helper.h",
- "android/jni_int_wrapper.h",
- "android/jni_registrar.cc",
- "android/jni_registrar.h",
- "android/jni_string.cc",
- "android/jni_string.h",
- "android/jni_utils.cc",
- "android/jni_utils.h",
- "android/jni_weak_ref.cc",
- "android/jni_weak_ref.h",
- "android/library_loader/library_loader_hooks.cc",
- "android/library_loader/library_loader_hooks.h",
- "android/native_uma_recorder.cc",
- "android/scoped_java_ref.cc",
- "android/scoped_java_ref.h",
- "android/trace_event_binding.cc",
- "android/trace_event_binding.h",
- ]
- deps += [ ":base_jni_headers" ]
- } # is_android || is_robolectric
-
- # Chromeos.
- if (is_chromeos) {
- sources += [
- "logging_chromeos.cc",
- "system/sys_info_chromeos.cc",
- ]
-
- sources += [ "power_monitor/power_monitor_device_source_chromeos.cc" ]
-
- if (current_cpu == "x64") {
- sources += [
- "profiler/frame_pointer_unwinder.cc",
- "profiler/frame_pointer_unwinder.h",
- ]
- }
- }
-
- # Fuchsia.
- if (is_fuchsia) {
- sources += [
- "base_paths_fuchsia.cc",
- "debug/debugger_fuchsia.cc",
- "debug/elf_reader.cc",
- "debug/elf_reader.h",
- "debug/stack_trace_fuchsia.cc",
- "file_descriptor_posix.cc",
- "file_descriptor_posix.h",
- "files/dir_reader_posix.h",
- "files/file_path_watcher_stub.cc", # See crbug.com/851641.
- "files/file_posix.cc",
- "files/file_util_fuchsia.cc",
- "files/memory_mapped_file_posix.cc",
- "fuchsia/default_job.cc",
- "fuchsia/default_job.h",
- "fuchsia/fidl_event_handler.h",
- "fuchsia/file_utils.cc",
- "fuchsia/file_utils.h",
- "fuchsia/filtered_service_directory.cc",
- "fuchsia/filtered_service_directory.h",
- "fuchsia/fuchsia_component_connect.h",
- "fuchsia/fuchsia_logging.cc",
- "fuchsia/fuchsia_logging.h",
- "fuchsia/intl_profile_watcher.cc",
- "fuchsia/intl_profile_watcher.h",
- "fuchsia/koid.cc",
- "fuchsia/koid.h",
- "fuchsia/mem_buffer_util.cc",
- "fuchsia/mem_buffer_util.h",
- "fuchsia/process_context.cc",
- "fuchsia/process_context.h",
- "fuchsia/process_lifecycle.cc",
- "fuchsia/process_lifecycle.h",
- "fuchsia/scheduler.h",
- "fuchsia/scoped_fx_logger.cc",
- "fuchsia/scoped_fx_logger.h",
- "fuchsia/scoped_service_binding.h",
- "fuchsia/scoped_service_publisher.h",
- "fuchsia/startup_context.cc",
- "fuchsia/startup_context.h",
- "fuchsia/system_info.cc",
- "fuchsia/system_info.h",
- "memory/platform_shared_memory_mapper_fuchsia.cc",
- "memory/platform_shared_memory_region_fuchsia.cc",
- "message_loop/message_pump_fuchsia.cc",
- "message_loop/message_pump_fuchsia.h",
- "message_loop/watchable_io_message_pump_posix.cc",
- "message_loop/watchable_io_message_pump_posix.h",
- "native_library_fuchsia.cc",
- "posix/eintr_wrapper.h",
- "posix/file_descriptor_shuffle.cc",
- "posix/file_descriptor_shuffle.h",
- "posix/global_descriptors.cc",
- "posix/global_descriptors.h",
- "posix/safe_strerror.cc",
- "posix/safe_strerror.h",
- "process/kill_fuchsia.cc",
- "process/launch_fuchsia.cc",
- "process/memory_fuchsia.cc",
- "process/process_fuchsia.cc",
- "process/process_handle_fuchsia.cc",
- "process/process_iterator_fuchsia.cc",
- "process/process_metrics_fuchsia.cc",
- "profiler/module_cache_posix.cc",
- "rand_util_fuchsia.cc",
- "strings/string_util_posix.h",
- "strings/sys_string_conversions_posix.cc",
- "synchronization/condition_variable_posix.cc",
- "synchronization/lock_impl_posix.cc",
- "synchronization/waitable_event_posix.cc",
- "synchronization/waitable_event_watcher_posix.cc",
- "system/sys_info_fuchsia.cc",
- "threading/platform_thread_fuchsia.cc",
- "threading/platform_thread_posix.cc",
- "threading/thread_local_storage_posix.cc",
- "time/time_conversion_posix.cc",
- "time/time_exploded_icu.cc",
- "time/time_fuchsia.cc",
- "timer/hi_res_timer_manager_posix.cc",
- ]
-
- # These only need to be public deps because of includes of their headers
- # by public //base headers, which requires they be on the include path.
- # TODO(https://crbug.com/841171): Move these back to |deps|.
- public_deps += [
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.runner:fuchsia.component.runner_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.intl:fuchsia.intl_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/async",
- "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/fdio",
- "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp_wire",
- "//third_party/fuchsia-sdk/sdk/pkg/sync",
- "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/syslog_structured_backend",
- "//third_party/fuchsia-sdk/sdk/pkg/vfs_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/zx",
- ]
-
- deps += [
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp_hlcpp_conversion",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.media:fuchsia.media_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/async-default",
- "//third_party/fuchsia-sdk/sdk/pkg/async-loop-cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/async-loop-default",
- "//third_party/fuchsia-sdk/sdk/pkg/fidl",
- "//third_party/fuchsia-sdk/sdk/pkg/sys_inspect_cpp",
- "//third_party/icu",
- ]
-
- # Needed for users of spinning_mutex.h, which for performance reasons,
- # contains inlined calls to `libsync` inside the header file.
- # It appends an entry to the "libs" section of the dependent target.
- public_configs = [ ":fuchsia_sync_lib" ]
- }
-
- # Several helpers in //base are backed by BoringSSL; however, NaCl builds
- # cannot easily depend on BoringSSL due to the nacl_io library, so NaCl builds
- # still retain a dedicated local implementation of the functionality.
- #
- # TODO(crbug.com/702997) Use only boringssl when NaCl is removed.
- sources += [
- "hash/md5.h",
- "hash/md5_constexpr.h",
- "hash/md5_constexpr_internal.h",
- "hash/sha1.h",
- ]
- if (is_nacl) {
- sources += [
- "hash/md5_nacl.cc",
- "hash/md5_nacl.h",
- "hash/sha1_nacl.cc",
- "hash/sha1_nacl.h",
- ]
- } else {
- sources += [
- "hash/md5_boringssl.cc",
- "hash/md5_boringssl.h",
- "hash/sha1_boringssl.cc",
- "hash/sha1_boringssl.h",
- ]
- public_deps += [ "//third_party/boringssl" ]
- }
-
- # NaCl.
- if (is_nacl) {
- # Explicitly include the linux file.
- sources += [
- "debug/stack_trace_nacl.cc",
- "files/file_path_watcher_stub.cc",
- "memory/page_size_nacl.cc",
- "os_compat_nacl.cc",
- "os_compat_nacl.h",
- "process/process_stubs.cc",
- "rand_util_nacl.cc",
- "sync_socket_nacl.cc",
- "system/sys_info_nacl.cc",
- "threading/platform_thread_linux.cc",
- ]
- } else {
- sources += [
- "base_paths.cc",
- "base_paths.h",
- "cpu.cc",
- "cpu.h",
- "debug/crash_logging.cc",
- "debug/crash_logging.h",
- "debug/stack_trace.cc",
- "debug/stack_trace.h",
- "files/file_enumerator.cc",
- "files/file_enumerator.h",
- "files/file_proxy.cc",
- "files/file_proxy.h",
- "files/file_util.cc",
- "files/file_util.h",
- "files/important_file_writer.cc",
- "files/important_file_writer.h",
- "files/important_file_writer_cleaner.cc",
- "files/important_file_writer_cleaner.h",
- "files/scoped_temp_dir.cc",
- "files/scoped_temp_dir.h",
- "json/json_file_value_serializer.cc",
- "json/json_file_value_serializer.h",
- "memory/discardable_memory.cc",
- "memory/discardable_memory.h",
- "memory/discardable_memory_allocator.cc",
- "memory/discardable_memory_allocator.h",
- "memory/discardable_memory_internal.h",
- "metrics/persistent_histogram_storage.cc",
- "metrics/persistent_histogram_storage.h",
- "native_library.cc",
- "native_library.h",
- "path_service.cc",
- "path_service.h",
- "scoped_native_library.cc",
- "scoped_native_library.h",
- "system/sys_info.cc",
- "system/sys_info.h",
- "system/sys_info_internal.h",
- "task/thread_pool/initialization_util.cc",
- "task/thread_pool/initialization_util.h",
- ]
-
- if (is_starboard) {
- sources -= [
- # Not used by cobalt.
- "native_library.cc",
- "native_library.h",
- "scoped_native_library.cc",
- "scoped_native_library.h",
- ]
- }
-
- if (is_win && !is_starboard) {
- sources += [
- "base_paths_win.cc",
- "base_paths_win.h",
- ]
- }
-
- if (is_mac && !is_starboard) {
- sources += [
- "base_paths_mac.h",
- "base_paths_mac.mm",
- ]
- }
-
- if (is_android && !is_starboard) {
- sources += [
- "base_paths_android.cc",
- "base_paths_android.h",
- ]
- }
-
- if (!use_cobalt_customizations && is_posix) {
- sources += [
- "base_paths_posix.h",
- "memory/madv_free_discardable_memory_allocator_posix.cc",
- "memory/madv_free_discardable_memory_allocator_posix.h",
- "memory/madv_free_discardable_memory_posix.cc",
- "memory/madv_free_discardable_memory_posix.h",
- "posix/unix_domain_socket.cc",
- "posix/unix_domain_socket.h",
- "rand_util_posix.cc",
- "system/sys_info_posix.cc",
- ]
- }
-
- if (!use_cobalt_customizations && (is_posix || is_fuchsia)) {
- sources += [
- "files/file_descriptor_watcher_posix.cc",
- "files/file_descriptor_watcher_posix.h",
- "files/file_enumerator_posix.cc",
- "files/file_util_posix.cc",
- "memory/page_size_posix.cc",
- ]
- }
-
- if ((!use_cobalt_customizations && is_posix && !is_ios) || is_fuchsia) {
- sources += [
- "process/process_metrics_posix.cc",
- "sync_socket_posix.cc",
- ]
- }
-
- if (!use_cobalt_customizations && is_posix && !is_apple) {
- sources += [
- "native_library_posix.cc",
- "posix/can_lower_nice_to.cc",
- "posix/can_lower_nice_to.h",
- "process/launch_posix.cc",
- "profiler/module_cache_posix.cc",
- "profiler/stack_base_address_posix.cc",
- "profiler/stack_base_address_posix.h",
- "profiler/stack_copier_signal.cc",
- "profiler/stack_copier_signal.h",
- "profiler/thread_delegate_posix.cc",
- "profiler/thread_delegate_posix.h",
- ]
- }
-
- if (!use_cobalt_customizations && is_posix && !is_android) {
- sources += [ "debug/stack_trace_posix.cc" ]
- }
-
- if (!use_cobalt_customizations && is_posix && !is_ios) {
- sources += [
- "process/kill_posix.cc",
- "process/process_posix.cc",
- ]
- }
-
- if (use_blink) {
- sources += [
- "memory/discardable_shared_memory.cc",
- "memory/discardable_shared_memory.h",
- "process/kill.cc",
- "process/kill.h",
- "process/launch.cc",
- "process/launch.h",
- "process/memory.cc",
- "process/memory.h",
- "process/process_iterator.cc",
- "process/process_iterator.h",
- "process/process_metrics.cc",
- "process/process_metrics.h",
- ]
- }
-
- if ((is_linux || is_chromeos) && !is_starboard) {
- sources += [
- "base_paths_posix.cc",
- "debug/elf_reader.cc",
- "debug/elf_reader.h",
- "stack_canary_linux.cc",
- "stack_canary_linux.h",
- ]
- }
- if (use_partition_alloc) {
- # Add stuff that doesn't work in NaCl.
- sources += [
- # PartitionAlloc uses SpinLock, which doesn't work in NaCl (see below).
- "allocator/partition_alloc_features.cc",
- "allocator/partition_alloc_features.h",
- "allocator/partition_alloc_support.cc",
- "allocator/partition_alloc_support.h",
- ]
- }
-
- # Need this to pass gn check, because gn check doesn't see
- # BUILDFLAG(USE_PARTITION_ALLOC). A linker will remove all
- # partition_alloc code if use_partition_alloc = false because no code uses
- # partition_alloc.
- public_deps += [
- "allocator/partition_allocator:partition_alloc",
- "allocator/partition_allocator:raw_ptr",
- ]
- }
-
- # Windows.
- if (is_win && !is_starboard) {
- sources += [
- "debug/debugger_win.cc",
- "debug/gdi_debug_util_win.cc",
- "debug/gdi_debug_util_win.h",
- "debug/handle_hooks_win.cc",
- "debug/handle_hooks_win.h",
- "debug/invalid_access_win.cc",
- "debug/invalid_access_win.h",
- "debug/stack_trace_win.cc",
- "enterprise_util.cc",
- "enterprise_util.h",
- "enterprise_util_win.cc",
- "file_version_info_win.cc",
- "file_version_info_win.h",
- "files/file_enumerator_win.cc",
- "files/file_path_watcher_win.cc",
- "files/file_util_win.cc",
- "files/file_win.cc",
- "files/memory_mapped_file_win.cc",
- "logging_win.cc",
- "logging_win.h",
- "memory/page_size_win.cc",
- "memory/platform_shared_memory_mapper_win.cc",
- "memory/platform_shared_memory_region_win.cc",
- "message_loop/message_pump_win.cc",
- "message_loop/message_pump_win.h",
- "native_library_win.cc",
- "power_monitor/battery_level_provider_win.cc",
- "power_monitor/power_monitor_device_source_win.cc",
- "power_monitor/speed_limit_observer_win.cc",
- "power_monitor/speed_limit_observer_win.h",
- "process/kill_win.cc",
- "process/launch_win.cc",
- "process/memory_win.cc",
- "process/process_handle_win.cc",
- "process/process_info_win.cc",
- "process/process_iterator_win.cc",
- "process/process_metrics_win.cc",
- "process/process_win.cc",
- "profiler/module_cache_win.cc",
- "profiler/native_unwinder_win.cc",
- "profiler/native_unwinder_win.h",
- "profiler/stack_sampler_win.cc",
- "profiler/suspendable_thread_delegate_win.cc",
- "profiler/suspendable_thread_delegate_win.h",
- "profiler/win32_stack_frame_unwinder.cc",
- "profiler/win32_stack_frame_unwinder.h",
- "rand_util_win.cc",
- "scoped_clear_last_error_win.cc",
- "strings/strcat_win.cc",
- "strings/strcat_win.h",
- "strings/string_number_conversions_win.cc",
- "strings/string_number_conversions_win.h",
- "strings/string_split_win.cc",
- "strings/string_split_win.h",
- "strings/string_util_win.cc",
- "strings/string_util_win.h",
- "strings/sys_string_conversions_win.cc",
- "sync_socket_win.cc",
- "synchronization/condition_variable_win.cc",
- "synchronization/lock_impl_win.cc",
- "synchronization/waitable_event_watcher_win.cc",
- "synchronization/waitable_event_win.cc",
- "system/sys_info_win.cc",
- "threading/platform_thread_win.cc",
- "threading/platform_thread_win.h",
- "threading/thread_local_storage_win.cc",
- "time/time_win.cc",
- "timer/hi_res_timer_manager_win.cc",
- "win/access_control_list.cc",
- "win/access_control_list.h",
- "win/access_token.cc",
- "win/access_token.h",
- "win/async_operation.h",
- "win/atl.h",
- "win/atl_throw.cc",
- "win/atl_throw.h",
- "win/com_init_balancer.cc",
- "win/com_init_balancer.h",
- "win/com_init_check_hook.cc",
- "win/com_init_check_hook.h",
- "win/com_init_util.cc",
- "win/com_init_util.h",
- "win/core_winrt_util.cc",
- "win/core_winrt_util.h",
- "win/current_module.h",
- "win/dark_mode_support.cc",
- "win/dark_mode_support.h",
- "win/default_apps_util.cc",
- "win/default_apps_util.h",
- "win/embedded_i18n/language_selector.cc",
- "win/embedded_i18n/language_selector.h",
- "win/enum_variant.cc",
- "win/enum_variant.h",
- "win/event_trace_consumer.h",
- "win/event_trace_controller.cc",
- "win/event_trace_controller.h",
- "win/event_trace_provider.cc",
- "win/event_trace_provider.h",
- "win/hstring_reference.cc",
- "win/hstring_reference.h",
- "win/i18n.cc",
- "win/i18n.h",
- "win/iat_patch_function.cc",
- "win/iat_patch_function.h",
- "win/map.h",
- "win/message_window.cc",
- "win/message_window.h",
- "win/nt_status.cc",
- "win/nt_status.h",
- "win/object_watcher.cc",
- "win/object_watcher.h",
- "win/patch_util.cc",
- "win/patch_util.h",
- "win/pe_image_reader.cc",
- "win/pe_image_reader.h",
- "win/post_async_results.h",
- "win/process_startup_helper.cc",
- "win/process_startup_helper.h",
- "win/propvarutil.h",
- "win/reference.h",
- "win/registry.cc",
- "win/registry.h",
- "win/resource_util.cc",
- "win/resource_util.h",
- "win/scoped_bstr.cc",
- "win/scoped_bstr.h",
- "win/scoped_co_mem.h",
- "win/scoped_com_initializer.cc",
- "win/scoped_com_initializer.h",
- "win/scoped_gdi_object.h",
- "win/scoped_handle.cc",
- "win/scoped_handle.h",
- "win/scoped_handle_verifier.cc",
- "win/scoped_handle_verifier.h",
- "win/scoped_hdc.h",
- "win/scoped_hglobal.h",
- "win/scoped_hstring.cc",
- "win/scoped_hstring.h",
- "win/scoped_localalloc.h",
- "win/scoped_process_information.cc",
- "win/scoped_process_information.h",
- "win/scoped_propvariant.h",
- "win/scoped_safearray.h",
- "win/scoped_select_object.h",
- "win/scoped_variant.cc",
- "win/scoped_variant.h",
- "win/scoped_windows_thread_environment.h",
- "win/scoped_winrt_initializer.cc",
- "win/scoped_winrt_initializer.h",
- "win/security_descriptor.cc",
- "win/security_descriptor.h",
- "win/security_util.cc",
- "win/security_util.h",
- "win/shlwapi.h",
- "win/shortcut.cc",
- "win/shortcut.h",
- "win/sid.cc",
- "win/sid.h",
- "win/sphelper.h",
- "win/startup_information.cc",
- "win/startup_information.h",
- "win/variant_conversions.h",
- "win/variant_vector.cc",
- "win/variant_vector.h",
- "win/vector.cc",
- "win/vector.h",
- "win/win_handle_types.h",
- "win/win_handle_types_list.inc",
- "win/win_util.cc",
- "win/win_util.h",
- "win/wincrypt_shim.h",
- "win/windows_defines.inc",
- "win/windows_h_disallowed.h",
- "win/windows_types.h",
- "win/windows_undefines.inc",
- "win/windows_version.cc",
- "win/windows_version.h",
- "win/windowsx_shim.h",
- "win/winrt_foundation_helpers.h",
- "win/winrt_storage_util.cc",
- "win/winrt_storage_util.h",
- "win/wmi.cc",
- "win/wmi.h",
- "win/wrapped_window_proc.cc",
- "win/wrapped_window_proc.h",
- ]
-
- deps += [ "//base/win:base_win_buildflags" ]
-
- data_deps += [ "//build/win:runtime_libs" ]
-
- if (com_init_check_hook_disabled) {
- defines += [ "COM_INIT_CHECK_HOOK_DISABLED" ]
- }
-
- libs += [
- "cfgmgr32.lib",
- "ntdll.lib",
- "onecore.lib",
- "powrprof.lib",
- "propsys.lib",
- "setupapi.lib",
- "shcore.lib",
- "userenv.lib",
- "wbemuuid.lib",
- "winmm.lib",
- ]
- all_dependent_configs += [
- ":base_win_linker_flags",
- "//tools/win/DebugVisualizers:chrome",
- ]
- inputs = [
- # chrome.natvis listed as an input here instead of in
- # //tools/win/DebugVisualizers:chrome to prevent unnecessary size increase
- # in generated build files.
- "//tools/win/DebugVisualizers/chrome.natvis",
- ]
- }
-
- if (!is_win) {
- sources += [
- "file_descriptor_store.cc",
- "file_descriptor_store.h",
- ]
- }
-
- # Desktop Mac.
- if (is_mac && !is_starboard) {
- sources += [
- "allocator/partition_allocator/shim/allocator_interception_mac.h",
- "allocator/partition_allocator/shim/allocator_interception_mac.mm",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac.cc",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac.h",
- "enterprise_util.cc",
- "enterprise_util.h",
- "enterprise_util_mac.mm",
- "files/file_path_watcher_fsevents.cc",
- "files/file_path_watcher_fsevents.h",
- "files/file_path_watcher_kqueue.cc",
- "files/file_path_watcher_kqueue.h",
- "files/file_path_watcher_mac.cc",
- "mac/authorization_util.h",
- "mac/authorization_util.mm",
- "mac/close_nocancel.cc",
- "mac/launch_application.h",
- "mac/launch_application.mm",
- "mac/launchd.cc",
- "mac/launchd.h",
- "mac/mac_util.h",
- "mac/mac_util.mm",
- "mac/mach_port_rendezvous.cc",
- "mac/mach_port_rendezvous.h",
- "mac/os_crash_dumps.cc",
- "mac/os_crash_dumps.h",
- "mac/scoped_aedesc.h",
- "mac/scoped_authorizationref.h",
- "mac/scoped_authorizationref.mm",
- "mac/scoped_cffiledescriptorref.h",
- "mac/scoped_cftyperef.h",
- "mac/scoped_dispatch_object.h",
- "mac/scoped_ionotificationportref.h",
- "mac/scoped_ioobject.h",
- "mac/scoped_ioplugininterface.h",
- "mac/scoped_launch_data.h",
- "mac/scoped_mach_msg_destroy.h",
- "mac/scoped_sending_event.h",
- "mac/scoped_sending_event.mm",
- "mac/wrap_cg_display.h",
- "message_loop/message_pump_kqueue.cc",
- "message_loop/message_pump_kqueue.h",
- "native_library_mac.mm",
- "power_monitor/battery_level_provider_mac.mm",
- "power_monitor/battery_state_sampler_mac.cc",
- "power_monitor/iopm_power_source_sampling_event_source.cc",
- "power_monitor/iopm_power_source_sampling_event_source.h",
- "power_monitor/power_monitor_device_source_mac.mm",
- "power_monitor/thermal_state_observer_mac.h",
- "power_monitor/thermal_state_observer_mac.mm",
- "process/kill_mac.cc",
- "process/launch_mac.cc",
- "process/memory_mac.mm",
- "process/port_provider_mac.cc",
- "process/port_provider_mac.h",
- "process/process_handle_mac.cc",
- "process/process_info_mac.cc",
- "process/process_iterator_mac.cc",
- "process/process_mac.cc",
- "process/process_metrics_mac.cc",
- "profiler/frame_pointer_unwinder.cc",
- "profiler/frame_pointer_unwinder.h",
- "profiler/stack_sampler_mac.cc",
- "profiler/suspendable_thread_delegate_mac.cc",
- "profiler/suspendable_thread_delegate_mac.h",
- "synchronization/waitable_event_watcher_mac.cc",
- "system/sys_info_mac.mm",
- "time/time_exploded_posix.cc",
- ]
-
- libs += [
- "bsm",
- "pmenergy",
- "pmsample",
- ]
- frameworks += [
- "ApplicationServices.framework",
- "AppKit.framework",
- "CoreFoundation.framework",
- "IOKit.framework",
- "OpenDirectory.framework",
- ]
- }
-
- # Mac or iOS.
- if (is_apple && !is_starboard) {
- sources += [
- "file_version_info_mac.h",
- "file_version_info_mac.mm",
- "files/file_util_mac.mm",
- "mac/backup_util.h",
- "mac/backup_util.mm",
- "mac/bundle_locations.h",
- "mac/bundle_locations.mm",
- "mac/call_with_eh_frame.cc",
- "mac/call_with_eh_frame.h",
- "mac/call_with_eh_frame_asm.S",
- "mac/dispatch_source_mach.cc",
- "mac/dispatch_source_mach.h",
- "mac/foundation_util.h",
- "mac/foundation_util.mm",
- "mac/mac_logging.h",
- "mac/mac_logging.mm",
- "mac/mach_logging.cc",
- "mac/mach_logging.h",
- "mac/scoped_block.h",
- "mac/scoped_mach_port.cc",
- "mac/scoped_mach_port.h",
- "mac/scoped_mach_vm.cc",
- "mac/scoped_mach_vm.h",
- "mac/scoped_nsautorelease_pool.cc",
- "mac/scoped_nsautorelease_pool.h",
- "mac/scoped_nsobject.h",
- "mac/scoped_objc_class_swizzler.h",
- "mac/scoped_objc_class_swizzler.mm",
- "mac/scoped_typeref.h",
- "memory/platform_shared_memory_mapper_mac.cc",
- "memory/platform_shared_memory_region_mac.cc",
- "message_loop/message_pump_mac.h",
- "message_loop/message_pump_mac.mm",
- "profiler/module_cache_mac.cc",
- "strings/sys_string_conversions_mac.mm",
- "synchronization/waitable_event_mac.cc",
- "system/sys_info_apple.mm",
- "threading/platform_thread_mac.mm",
- "time/time_mac.mm",
- ]
- frameworks += [ "Security.framework" ]
- }
-
- # Linux.
- if (!use_cobalt_customizations && (is_linux || is_chromeos)) {
- # TODO(brettw) this will need to be parameterized at some point.
- linux_configs = []
- if (use_glib) {
- linux_configs += [ "//build/config/linux:glib" ]
- }
-
- configs += linux_configs
- all_dependent_configs += linux_configs
- sources += [ "system/sys_info_linux.cc" ]
- if (!is_cronet_build) {
- # These dependencies are not required on Android, and in the case
- # of xdg_mime must be excluded due to licensing restrictions.
- sources += [
- "nix/mime_util_xdg.cc",
- "nix/mime_util_xdg.h",
- "nix/xdg_util.cc",
- "nix/xdg_util.h",
- ]
- defines += [ "USE_SYMBOLIZE" ]
- deps += [
- "//base/third_party/symbolize",
- "//base/third_party/xdg_mime",
- "//base/third_party/xdg_user_dirs",
- ]
- }
- } else {
- if (!is_android || is_starboard) {
- sources -= [
- "linux_util.cc",
- "linux_util.h",
- ]
- }
- }
-
- # iOS
- if (is_ios && !is_starboard) {
- sources += [
- "base_paths_mac.h",
- "base_paths_mac.mm",
- "critical_closure_internal_ios.mm",
- "ios/block_types.h",
- "ios/device_util.h",
- "ios/device_util.mm",
- "ios/ios_util.h",
- "ios/ios_util.mm",
- "ios/ns_error_util.h",
- "ios/ns_error_util.mm",
- "ios/ns_range.h",
- "ios/scoped_critical_action.h",
- "ios/scoped_critical_action.mm",
- "mac/bridging.h",
- "native_library_ios.mm",
- "power_monitor/power_monitor_device_source_ios.mm",
- "process/process_metrics_ios.cc",
- "profiler/stack_sampler_ios.cc",
- "system/sys_info_ios.mm",
- ]
-
- if (use_blink) {
- sources += [
- "files/file_path_watcher_kqueue.cc",
- "files/file_path_watcher_kqueue.h",
- "files/file_path_watcher_mac.cc",
- "ios/sim_header_shims.h",
- "mac/mach_port_rendezvous.cc",
- "mac/mach_port_rendezvous.h",
- "process/kill_mac.cc",
- "process/launch_mac.cc",
- "process/memory_mac.mm",
- "process/port_provider_mac.cc",
- "process/port_provider_mac.h",
- "process/process_handle_mac.cc",
- "process/process_iterator_ios.mm",
- "process/process_mac.cc",
- "process/process_metrics_posix.cc",
- "process/process_posix.cc",
- "sync_socket_posix.cc",
- "synchronization/waitable_event_watcher_mac.cc",
- ]
- libs += [ "bsm" ]
- } else {
- sources += [
- "process/launch_ios.cc",
- "process/memory_stubs.cc",
- "process/process_stubs.cc",
- ]
- }
-
- if (is_cronet_build) {
- sources += [
- "message_loop/message_pump_io_ios.cc",
- "message_loop/message_pump_io_ios.h",
- ]
- } else {
- sources += [
- "message_loop/message_pump_kqueue.cc",
- "message_loop/message_pump_kqueue.h",
- ]
- }
-
- if (ios_stack_profiler_enabled) {
- sources += [
- "profiler/frame_pointer_unwinder.cc",
- "profiler/frame_pointer_unwinder.h",
- "profiler/suspendable_thread_delegate_mac.cc",
- "profiler/suspendable_thread_delegate_mac.h",
- ]
- }
- if (use_allocator_shim) {
- sources += [
- "allocator/partition_allocator/shim/allocator_interception_mac.h",
- "allocator/partition_allocator/shim/allocator_interception_mac.mm",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac.cc",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac.h",
- ]
- } else {
- sources -= [
- "sampling_heap_profiler/poisson_allocation_sampler.cc",
- "sampling_heap_profiler/poisson_allocation_sampler.h",
- "sampling_heap_profiler/sampling_heap_profiler.cc",
- "sampling_heap_profiler/sampling_heap_profiler.h",
- ]
- }
-
- if (current_cpu == "x64" || current_cpu == "arm64") {
- sources += [ "time/time_exploded_posix.cc" ]
- } else {
- sources += [ "time/time_exploded_ios.cc" ]
- }
-
- frameworks += [ "UIKit.framework" ]
- }
-
- if (use_blink || true) {
- sources += [
- "files/file_path_watcher.cc",
- "files/file_path_watcher.h",
- "sync_socket.cc",
- "sync_socket.h",
- ]
- }
-
- if (dep_libevent) {
- deps += [ "//third_party/libevent" ]
- }
-
- if (use_libevent) {
- sources += [
- "message_loop/message_pump_libevent.cc",
- "message_loop/message_pump_libevent.h",
- ]
- }
-
- if (enable_message_pump_epoll) {
- sources += [
- "message_loop/message_pump_epoll.cc",
- "message_loop/message_pump_epoll.h",
- ]
- }
-
- # Android and MacOS have their own custom shared memory handle
- # implementations. e.g. due to supporting both POSIX and native handles.
- if (!use_cobalt_customizations && is_posix && !is_android && !is_apple) {
- sources += [
- "memory/platform_shared_memory_mapper_posix.cc",
- "memory/platform_shared_memory_region_posix.cc",
- ]
- }
-
- if (!use_cobalt_customizations && is_posix && !is_apple) {
- sources += [
- "strings/sys_string_conversions_posix.cc",
- "synchronization/waitable_event_posix.cc",
- "synchronization/waitable_event_watcher_posix.cc",
- "threading/platform_thread_internal_posix.cc",
- "threading/platform_thread_internal_posix.h",
- "time/time_exploded_posix.cc",
- "time/time_now_posix.cc",
- ]
-
- # TODO(b/167763382) Find an alternate solution for Chromecast devices, since
- # adding the icui18n and icuuc deps significantly increases the binary size.
- if (!is_castos && !is_cast_android) {
- sources += [ "time/time_exploded_icu.cc" ]
-
- # The ICU dependency is only needed on systems with a 32-bit time_t.
- # However, that cannot be determined from build variables, like
- # |current_cpu|, since some 32-bit systems have a 64-bit time_t (and vice
- # versa). Thus, the dependency is taken here for all POSIX platforms and
- # the compiler+linker should be able to easily detect when the ICU
- # routines will not be called and delete them in the final linking.
- deps += [
- "//third_party/icu:icui18n",
- "//third_party/icu:icuuc",
- ]
- }
- }
-
- if (!is_starboard) {
- if ((is_posix && !is_apple && !is_android) || is_fuchsia) {
- sources += [ "profiler/stack_sampler_posix.cc" ]
- }
- }
-
- if ((is_posix && !is_apple && !is_android && !is_chromeos) || is_fuchsia || is_starboard) {
- sources += [ "power_monitor/power_monitor_device_source_stub.cc" ]
- }
-
- # On ARC++-enabled ChromeOS system, we need TimeTicks::FromUptimeMillis to
- # interpret time values sent from Android container.
- if ((is_android || is_chromeos_ash) && !is_starboard) {
- sources += [ "time/time_android.cc" ]
- }
-
- if (use_glib) {
- sources += [
- "message_loop/message_pump_glib.cc",
- "message_loop/message_pump_glib.h",
- ]
- }
-
- if (enable_base_tracing) {
- sources += [
- "trace_event/auto_open_close_event.h",
- "trace_event/builtin_categories.cc",
- "trace_event/builtin_categories.h",
- "trace_event/category_registry.cc",
- "trace_event/category_registry.h",
- "trace_event/heap_profiler.h",
- "trace_event/interned_args_helper.cc",
- "trace_event/interned_args_helper.h",
- "trace_event/log_message.cc",
- "trace_event/log_message.h",
- "trace_event/malloc_dump_provider.cc",
- "trace_event/malloc_dump_provider.h",
- "trace_event/memory_allocator_dump.cc",
- "trace_event/memory_allocator_dump.h",
- "trace_event/memory_dump_manager.cc",
- "trace_event/memory_dump_manager.h",
- "trace_event/memory_dump_manager_test_utils.h",
- "trace_event/memory_dump_provider.h",
- "trace_event/memory_dump_provider_info.cc",
- "trace_event/memory_dump_provider_info.h",
- "trace_event/memory_dump_request_args.cc",
- "trace_event/memory_dump_request_args.h",
- "trace_event/memory_dump_scheduler.cc",
- "trace_event/memory_dump_scheduler.h",
- "trace_event/memory_infra_background_allowlist.cc",
- "trace_event/memory_infra_background_allowlist.h",
- "trace_event/memory_pressure_level_proto.cc",
- "trace_event/memory_pressure_level_proto.h",
- "trace_event/memory_usage_estimator.cc",
- "trace_event/memory_usage_estimator.h",
- "trace_event/optional_trace_event.h",
- "trace_event/process_memory_dump.cc",
- "trace_event/process_memory_dump.h",
- "trace_event/trace_arguments.cc",
- "trace_event/trace_arguments.h",
- "trace_event/trace_buffer.cc",
- "trace_event/trace_buffer.h",
- "trace_event/trace_category.h",
- "trace_event/trace_config.cc",
- "trace_event/trace_config.h",
- "trace_event/trace_config_category_filter.cc",
- "trace_event/trace_config_category_filter.h",
- "trace_event/trace_conversion_helper.h",
- "trace_event/trace_event.h",
- "trace_event/trace_event_impl.cc",
- "trace_event/trace_event_impl.h",
- "trace_event/trace_event_memory_overhead.cc",
- "trace_event/trace_event_memory_overhead.h",
- "trace_event/trace_log.cc",
- "trace_event/trace_log.h",
- "trace_event/trace_log_constants.cc",
- "trace_event/traced_value.cc",
- "trace_event/traced_value.h",
- "trace_event/traced_value_support.h",
- "trace_event/tracing_agent.cc",
- "trace_event/tracing_agent.h",
- "trace_event/typed_macros.h",
- "trace_event/typed_macros_embedder_support.h",
- "trace_event/typed_macros_internal.cc",
- "trace_event/typed_macros_internal.h",
- "tracing/perfetto_platform.cc",
- "tracing/perfetto_platform.h",
- "tracing/perfetto_task_runner.cc",
- "tracing/perfetto_task_runner.h",
- "tracing/trace_time.cc",
- "tracing/trace_time.h",
- "tracing/tracing_tls.cc",
- "tracing/tracing_tls.h",
- ]
- if (use_cobalt_customizations && use_xcode_clang) {
- defines = [ "USES_XCODE_CLANG" ]
- }
-
- public_deps += [
- "//base/tracing/protos:chrome_track_event_zero",
- "//third_party/perfetto:libperfetto",
- ]
-
- deps += [
- "//base/tracing/protos:chrome_track_event",
- "//third_party/perfetto/include/perfetto/protozero",
- ]
-
- all_dependent_configs += [
- ":perfetto_config",
- "//third_party/perfetto/gn:public_config",
- ]
-
- if (is_win && !is_starboard) {
- sources += [
- "trace_event/trace_event_etw_export_win.cc",
- "trace_event/trace_event_etw_export_win.h",
- "trace_event/trace_logging_minimal_win.cc",
- "trace_event/trace_logging_minimal_win.h",
- ]
- }
-
- if (is_android && !is_starboard) {
- sources += [
- "trace_event/application_state_proto_android.cc",
- "trace_event/application_state_proto_android.h",
- "trace_event/cpufreq_monitor_android.cc",
- "trace_event/cpufreq_monitor_android.h",
- "trace_event/java_heap_dump_provider_android.cc",
- "trace_event/java_heap_dump_provider_android.h",
- ]
- }
-
- if (use_partition_alloc_as_malloc) {
- sources += [
- "trace_event/address_space_dump_provider.cc",
- "trace_event/address_space_dump_provider.h",
- ]
- }
- } else {
- sources += [
- "trace_event/trace_event_stub.cc",
- "trace_event/trace_event_stub.h",
- ]
- }
-
- if (using_sanitizer && !is_fuchsia) {
- data += [ "//tools/valgrind/asan/" ]
- data_deps +=
- [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
- }
-
- if (!is_debug) {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_max" ]
- }
-
- if (!use_allocation_event_dispatcher && (!is_ios || use_allocator_shim)) {
- # The old hooks depend on PoissonAllocationSampler, which is not always enabled.
- sources += [
- "allocator/dispatcher/standard_hooks.cc",
- "allocator/dispatcher/standard_hooks.h",
- ]
- }
-}
-
-# Build flags for Control Flow Integrity
-# https://www.chromium.org/developers/testing/control-flow-integrity
-buildflag_header("cfi_buildflags") {
- header = "cfi_buildflags.h"
-
- flags = [
- # TODO(pcc): remove CFI_CAST_CHECK, see https://crbug.com/626794.
- "CFI_CAST_CHECK=$is_cfi && $use_cfi_cast",
- "CFI_DIAG=$is_cfi && $use_cfi_diag",
- "CFI_ICALL_CHECK=$is_cfi && $use_cfi_icall",
- "CFI_ENFORCEMENT_TRAP=$is_cfi && !$use_cfi_diag",
- "CFI_ENFORCEMENT_DIAGNOSTIC=$is_cfi && $use_cfi_diag && !$use_cfi_recover",
- ]
-}
-
-buildflag_header("debugging_buildflags") {
- header = "debugging_buildflags.h"
- header_dir = "base/debug"
- enable_gdbinit_warning =
- is_debug && (strip_absolute_paths_from_debug_symbols || use_custom_libcxx)
- enable_lldbinit_warning =
- is_debug && strip_absolute_paths_from_debug_symbols && is_mac
-
- # TODO(crbug.com/1420774): Try and enable these checks on Android too.
- enable_commandline_sequence_checks =
- (is_debug || dcheck_always_on) && !is_android
-
- flags = [
- "DCHECK_IS_CONFIGURABLE=$dcheck_is_configurable",
- "ENABLE_PROFILING=$enable_profiling",
- "CAN_UNWIND_WITH_FRAME_POINTERS=$can_unwind_with_frame_pointers",
- "UNSAFE_DEVELOPER_BUILD=$is_unsafe_developer_build",
- "CAN_UNWIND_WITH_CFI_TABLE=$can_unwind_with_cfi_table",
- "EXCLUDE_UNWIND_TABLES=$exclude_unwind_tables",
- "ENABLE_GDBINIT_WARNING=$enable_gdbinit_warning",
- "ENABLE_LLDBINIT_WARNING=$enable_lldbinit_warning",
- "EXPENSIVE_DCHECKS_ARE_ON=$enable_expensive_dchecks",
- "ENABLE_STACK_TRACE_LINE_NUMBERS=$enable_stack_trace_line_numbers",
- "ENABLE_COMMANDLINE_SEQUENCE_CHECKS=$enable_commandline_sequence_checks",
- "ENABLE_ALLOCATION_STACK_TRACE_RECORDER=$build_allocation_stack_trace_recorder",
- ]
-}
-
-buildflag_header("feature_list_buildflags") {
- header = "feature_list_buildflags.h"
-
- if (is_chromeos_ash) {
- flags = [
- "ENABLE_BANNED_BASE_FEATURE_PREFIX=true",
- "BANNED_BASE_FEATURE_PREFIX=\"CrOSLateBoot\"",
- ]
- } else {
- flags = [ "ENABLE_BANNED_BASE_FEATURE_PREFIX=false" ]
- }
-}
-
-buildflag_header("logging_buildflags") {
- header = "logging_buildflags.h"
-
- flags = [
- "ENABLE_LOG_ERROR_NOT_REACHED=$enable_log_error_not_reached",
- "USE_RUNTIME_VLOG=$use_runtime_vlog",
- ]
-}
-
-buildflag_header("orderfile_buildflags") {
- header = "orderfile_buildflags.h"
- header_dir = "base/android/orderfile"
- using_order_profiling = is_android && use_order_profiling
- using_devtools_dumping =
- is_android && devtools_instrumentation_dumping && enable_base_tracing
-
- flags = [
- "DEVTOOLS_INSTRUMENTATION_DUMPING=$using_devtools_dumping",
- "ORDERFILE_INSTRUMENTATION=$using_order_profiling",
- ]
-}
-
-buildflag_header("synchronization_buildflags") {
- header = "synchronization_buildflags.h"
- header_dir = "base/synchronization"
-
- flags =
- [ "ENABLE_MUTEX_PRIORITY_INHERITANCE=$enable_mutex_priority_inheritance" ]
-}
-
-buildflag_header("anchor_functions_buildflags") {
- header = "anchor_functions_buildflags.h"
- header_dir = "base/android/library_loader"
- _supports_code_ordering =
- is_android && (current_cpu == "arm" || current_cpu == "arm64" ||
- current_cpu == "x86" || current_cpu == "x64")
-
- flags = [
- "USE_LLD=$use_lld",
- "SUPPORTS_CODE_ORDERING=$_supports_code_ordering",
- ]
-}
-
-buildflag_header("clang_profiling_buildflags") {
- header = "clang_profiling_buildflags.h"
- header_dir = "base"
-
- flags = [
- "CLANG_PROFILING=$use_clang_profiling",
- "CLANG_PROFILING_INSIDE_SANDBOX=$use_clang_profiling_inside_sandbox",
- "USE_CLANG_COVERAGE=$use_clang_coverage",
- ]
-}
-
-buildflag_header("sanitizer_buildflags") {
- header = "sanitizer_buildflags.h"
- header_dir = "base"
-
- flags = [
- "IS_HWASAN=$is_hwasan",
- "USING_SANITIZER=$using_sanitizer",
- ]
-}
-
-buildflag_header("tracing_buildflags") {
- header = "tracing_buildflags.h"
-
- flags = [
- "ENABLE_BASE_TRACING=$enable_base_tracing",
- "USE_PERFETTO_CLIENT_LIBRARY=$use_perfetto_client_library",
- "OPTIONAL_TRACE_EVENTS_ENABLED=$optional_trace_events_enabled",
- ]
-}
-
-buildflag_header("profiler_buildflags") {
- header = "profiler_buildflags.h"
- header_dir = "base/profiler"
-
- flags = [
- "ENABLE_ARM_CFI_TABLE=$enable_arm_cfi_table",
- "IOS_STACK_PROFILER_ENABLED=$ios_stack_profiler_enabled",
- ]
-}
-
-buildflag_header("power_monitor_buildflags") {
- header = "power_monitor_buildflags.h"
- header_dir = "base/power_monitor"
- _has_battery_provider_impl = is_win || is_mac
-
- flags = [ "HAS_BATTERY_LEVEL_PROVIDER_IMPL=$_has_battery_provider_impl" ]
-}
-
-# This is the subset of files from base that should not be used with a dynamic
-# library. Note that this library cannot depend on base because base depends on
-# base_static.
-static_library("base_static") {
- sources = [
- "base_export.h",
- "base_switches.cc",
- "base_switches.h",
- "immediate_crash.h",
- ]
-
- deps = [ "//build:chromeos_buildflags" ]
-
- if (is_starboard && current_toolchain != host_toolchain) {
- deps += [ "//starboard:starboard_group" ]
- }
-
- if (is_win) {
- sources += [
- "win/static_constants.cc",
- "win/static_constants.h",
- ]
-
- public_deps = [ "//base/win:pe_image" ]
-
- # Disable sanitizer coverage in win/pe_image.cc. It is called by the sandbox
- # before sanitizer coverage can initialize. http://crbug.com/484711
- configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
- configs +=
- [ "//build/config/sanitizers:default_sanitizer_flags_but_coverage" ]
- }
-
- if (!is_debug) {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_max" ]
- }
-}
-
-if (use_custom_libcxx && enable_safe_libcxx && !is_debug) {
- # nodebug_assertion.cc has to be in its own source_set instead of being
- # included as a source in //base as otherwise its symbols won't be linked in
- # if they end up in an archive.
- source_set("nodebug_assertion") {
- defines = [ "BASE_IMPLEMENTATION" ]
- sources = [ "nodebug_assertion.cc" ]
- deps = [ ":base_static" ]
- }
-}
-
-component("i18n") {
- output_name = "base_i18n"
- sources = [
- "i18n/base_i18n_export.h",
- "i18n/base_i18n_switches.cc",
- "i18n/base_i18n_switches.h",
- "i18n/break_iterator.cc",
- "i18n/break_iterator.h",
- "i18n/case_conversion.cc",
- "i18n/case_conversion.h",
- "i18n/char_iterator.cc",
- "i18n/char_iterator.h",
- "i18n/character_encoding.cc",
- "i18n/character_encoding.h",
- "i18n/encoding_detection.cc",
- "i18n/encoding_detection.h",
- "i18n/file_util_icu.cc",
- "i18n/file_util_icu.h",
- "i18n/i18n_constants.cc",
- "i18n/i18n_constants.h",
- "i18n/icu_string_conversions.cc",
- "i18n/icu_string_conversions.h",
- "i18n/icu_util.cc",
- "i18n/icu_util.h",
- "i18n/message_formatter.cc",
- "i18n/message_formatter.h",
- "i18n/number_formatting.cc",
- "i18n/number_formatting.h",
- "i18n/rtl.cc",
- "i18n/rtl.h",
- "i18n/streaming_utf8_validator.cc",
- "i18n/streaming_utf8_validator.h",
- "i18n/string_compare.cc",
- "i18n/string_compare.h",
- "i18n/time_formatting.cc",
- "i18n/time_formatting.h",
- "i18n/timezone.cc",
- "i18n/timezone.h",
- "i18n/unicodestring.h",
- "i18n/utf8_validator_tables.cc",
- "i18n/utf8_validator_tables.h",
- ]
- defines = [ "BASE_I18N_IMPLEMENTATION" ]
- configs += [ "//build/config/compiler:wexit_time_destructors" ]
- public_deps = [
- "//third_party/ced",
- "//third_party/icu",
- ]
- deps = [
- ":base",
- "//base/third_party/dynamic_annotations",
- "//build:chromecast_buildflags",
- "//build:chromeos_buildflags",
- "//starboard/client_porting/icu_init",
- ]
-
- if (is_starboard) {
- public_deps -= [ "//third_party/ced" ]
- }
-
- if (!is_debug) {
- if (is_starboard) {
- configs -= [ "//starboard/build/config:size" ]
- configs += [ "//starboard/build/config:speed" ]
- } else {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_max" ]
- }
- }
-
- if (is_chromeos_lacros) {
- sources += [
- "i18n/icu_mergeable_data_file.cc",
- "i18n/icu_mergeable_data_file.h",
- ]
- }
-
- if (is_mac && !is_starboard) {
- frameworks = [ "CoreFoundation.framework" ]
- }
-}
-
-if (!is_starboard) {
-test("base_perftests") {
- sources = [
- "hash/hash_perftest.cc",
- "message_loop/message_pump_perftest.cc",
- "observer_list_perftest.cc",
- "rand_util_perftest.cc",
- "strings/string_util_perftest.cc",
- "substring_set_matcher/substring_set_matcher_perftest.cc",
- "task/job_perftest.cc",
- "task/sequence_manager/sequence_manager_perftest.cc",
- "task/thread_pool/thread_pool_perftest.cc",
- "threading/counter_perftest.cc",
- "threading/thread_local_storage_perftest.cc",
-
- # "test/run_all_unittests.cc",
- "json/json_perftest.cc",
- "synchronization/lock_perftest.cc",
- "synchronization/waitable_event_perftest.cc",
- "threading/thread_perftest.cc",
- ]
-
- deps = [
- ":base",
- ":debugging_buildflags",
- "//base/test:test_support",
- "//base/test:test_support_perf",
- "//testing/gtest",
- "//testing/perf",
- ]
-
- if (use_partition_alloc) {
- sources += [
- "allocator/partition_allocator/partition_alloc_perftest.cc",
- "allocator/partition_allocator/partition_lock_perftest.cc",
- ]
- deps += [ ":partition_alloc_test_support" ]
- }
-
- data_deps = [
- # Needed for isolate script to execute.
- "//testing:run_perf_test",
- ]
-
- if (is_android) {
- deps += [ "//testing/android/native_test:native_test_native_code" ]
- shard_timeout = 600
- }
-
- if (is_fuchsia) {
- # Run these performance tests against the actual system.
- run_as_chromium_system_test = true
- }
-
- if (!is_official_build) {
- # The extra data tables required by stack traces are turned off for official
- # build, only do stack trace perftest for unofficial build
- sources += [ "debug/stack_trace_perftest.cc" ]
- }
-
- if (build_allocation_stack_trace_recorder) {
- sources += [ "debug/allocation_trace_perftest.cc" ]
- }
-}
-
-test("base_i18n_perftests") {
- sources = [ "i18n/streaming_utf8_validator_perftest.cc" ]
- deps = [
- ":base",
- ":i18n",
- "//base/test:test_support",
- "//base/test:test_support_perf",
- "//testing/gtest",
- ]
-}
-}
-
-if (!is_ios && !use_cobalt_customizations) {
- executable("build_utf8_validator_tables") {
- sources = [ "i18n/build_utf8_validator_tables.cc" ]
- deps = [
- ":base",
- "//build/win:default_exe_manifest",
- "//third_party/icu:icuuc",
- ]
- }
-
- executable("check_example") {
- sources = [ "check_example.cc" ]
- deps = [
- ":base",
- "//build/win:default_exe_manifest",
- ]
- }
-
- executable("json_perftest_decodebench") {
- sources = [ "json/json_perftest_decodebench.cc" ]
- deps = [ ":base" ]
- }
-}
-
-if (is_win && !is_starboard) {
- # Target to manually rebuild pe_image_test.dll which is checked into
- # base/test/data/pe_image.
- shared_library("pe_image_test") {
- sources = [ "win/pe_image_test.cc" ]
- ldflags = [
- "/DELAYLOAD:cfgmgr32.dll",
- "/DELAYLOAD:shell32.dll",
- "/SUBSYSTEM:WINDOWS",
- ]
- libs = [
- "cfgmgr32.lib",
- "shell32.lib",
- ]
- }
-
- loadable_module("scoped_handle_test_dll") {
- sources = [ "win/scoped_handle_test_dll.cc" ]
- deps = [
- ":base",
- "//base/win:base_win_buildflags",
- ]
- }
-}
-
-if ((is_win && (current_cpu == "x64" || current_cpu == "arm64") && !is_starboard) ||
- (is_mac && !is_starboard) ||
- (is_android && (current_cpu == "arm" || current_cpu == "arm64")) ||
- (is_chromeos && current_cpu == "x64")) {
- # Must be a loadable module so that it can be loaded/unloaded at runtime
- # during testing.
- loadable_module("base_profiler_test_support_library") {
- testonly = true
- sources = [ "profiler/test_support_library.cc" ]
- }
-}
-
-if (is_android && (current_cpu == "arm" || current_cpu == "arm64") && !use_cobalt_customizations) {
- # Use separate library for
- # |LibunwindstackUnwinderAndroidTest.ReparsesMapsOnNewDynamicLibraryLoad|
- # testcase. We can't use the existing `base_profiler_test_support_library`
- # library for this test since this gets loaded by other tests and unloading
- # a library in Android doesn't guarantee it will actually be unloaded.
- # And in the test we would like to observe the change in /proc/self/maps
- # on loading a dynamic library.
- loadable_module("base_profiler_reparsing_test_support_library") {
- testonly = true
- sources = [ "profiler/test_support_library.cc" ]
- }
-}
-
-if (is_android && !use_cobalt_customizations) {
- source_set("native_unwinder_android") {
- # This target is intended to be used only within the stack_unwinder dynamic
- # feature module, to avoid binary size increase in Chrome due to the
- # libunwindstack dependency. The additional :* visibility is needed to allow
- # use by base test targets.
- visibility = [
- ":*",
- "//chrome/android/modules/stack_unwinder/internal:*",
- ]
- sources = [
- "profiler/libunwindstack_unwinder_android.cc",
- "profiler/libunwindstack_unwinder_android.h",
- "profiler/native_unwinder_android.cc",
- "profiler/native_unwinder_android.h",
- ]
-
- public_deps = [
- ":base",
- "//third_party/libunwindstack",
- ]
- }
-}
-
-source_set("base_stack_sampling_profiler_test_util") {
- testonly = true
- sources = [
- "profiler/stack_sampling_profiler_test_util.cc",
- "profiler/stack_sampling_profiler_test_util.h",
- ]
- deps = [
- ":base",
- "//base/test:test_support",
- "//testing/gtest",
- ]
- if (is_android && !use_cobalt_customizations) {
- sources += [
- "profiler/stack_sampling_profiler_java_test_util.cc",
- "profiler/stack_sampling_profiler_java_test_util.h",
- ]
- deps += [
- ":base_profiler_test_support_jni_headers",
- ":native_unwinder_android",
- ]
- }
-}
-
-copy("base_unittests_bundle_data") {
- testonly = true
- if (is_starboard) {
- install_content = true
- }
- sources = [
- "//tools/metrics/histograms/enums.xml",
- "test/data/file_util/binary_file.bin",
- "test/data/file_util/binary_file_diff.bin",
- "test/data/file_util/binary_file_same.bin",
- "test/data/file_util/blank_line.txt",
- "test/data/file_util/blank_line_crlf.txt",
- "test/data/file_util/crlf.txt",
- "test/data/file_util/different.txt",
- "test/data/file_util/different_first.txt",
- "test/data/file_util/different_last.txt",
- "test/data/file_util/empty1.txt",
- "test/data/file_util/empty2.txt",
- "test/data/file_util/first1.txt",
- "test/data/file_util/first2.txt",
- "test/data/file_util/original.txt",
- "test/data/file_util/same.txt",
- "test/data/file_util/same_length.txt",
- "test/data/file_util/shortened.txt",
- "test/data/json/bom_feff.json",
- "test/data/pe_image_reader/signed.exe",
- "test/data/serializer_nested_test.json",
- "test/data/serializer_test.json",
- "test/data/serializer_test_nowhitespace.json",
- ]
- if (is_starboard) {
- outputs = [ "$sb_static_contents_output_data_dir/test/base/{{source_target_relative}}" ]
- } else {
- outputs = [ "{{bundle_resources_dir}}/" +
- "{{source_root_relative_dir}}/{{source_file_part}}" ]
- }
-}
-
-if (is_apple && !is_starboard) {
- source_set("base_unittests_arc") {
- testonly = true
- sources = [
- "ios/crb_protocol_observers_unittest.mm",
- "mac/bind_objc_block_unittest_arc.mm",
- "mac/scoped_nsobject_unittest_arc.mm",
- ]
- configs += [ "//build/config/compiler:enable_arc" ]
- deps = [
- ":base",
- "//base/ios",
- "//base/test:test_support",
- "//testing/gtest",
- ]
- }
-}
-
-if (!is_nacl && (is_linux || is_chromeos) && !use_cobalt_customizations) {
- # This test must compile with -fstack-protector-all
- source_set("stack_canary_linux_unittests") {
- testonly = true
-
- sources = [ "stack_canary_linux_unittest.cc" ]
- cflags = [ "-fstack-protector-all" ]
-
- deps = [
- "//base",
- "//testing/gtest",
- ]
- }
-}
-
-if (is_fuchsia) {
- fidl_library("testfidl") {
- library_name = "base.testfidl"
-
- sources = [ "fuchsia/test.test-fidl" ]
- }
-
- # TODO(crbug.com/1416553): remove this once all users are migrated to natural bindings.
- source_set("test_interface_impl") {
- testonly = true
- sources = [
- "fuchsia/test_interface_impl.cc",
- "fuchsia/test_interface_impl.h",
- ]
- deps = [
- ":base",
- "//testing/gtest",
- ]
- public_deps = [
- ":testfidl_hlcpp",
- "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/zx",
- ]
- }
-
- source_set("test_interface_natural_impl") {
- testonly = true
- public = [ "fuchsia/test_interface_natural_impl.h" ]
- sources = [ "fuchsia/test_interface_natural_impl.cc" ]
- deps = [
- ":base",
- "//testing/gtest",
- "//third_party/fuchsia-sdk/sdk/pkg/async",
- ]
- public_deps = [
- ":testfidl_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp_common",
- "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp_wire",
- "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
- ]
- }
-
- source_set("test_log_listener_safe") {
- testonly = true
- sources = [
- "fuchsia/test_log_listener_safe.cc",
- "fuchsia/test_log_listener_safe.h",
- ]
- deps = [
- ":base",
- "//base/test:test_support",
- "//testing/gtest",
- ]
- public_deps = [
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_hlcpp",
- ]
- }
-}
-
-source_set("arm_bti_testfunctions") {
- testonly = true
-
- sources = []
-
- if (target_cpu == "arm64" && (is_linux || is_android)) {
- sources = [
- "allocator/partition_allocator/arm_bti_test_functions.S",
- "allocator/partition_allocator/arm_bti_test_functions.h",
- ]
- }
-}
-
-test("base_unittests") {
- sources = [
- "allocator/dispatcher/dispatcher_unittest.cc",
- "allocator/dispatcher/initializer_unittest.cc",
- "allocator/dispatcher/internal/dispatcher_internal_unittest.cc",
- "allocator/dispatcher/testing/dispatcher_test.cc",
- "allocator/dispatcher/testing/dispatcher_test.h",
- "allocator/dispatcher/testing/observer_mock.h",
- "allocator/dispatcher/testing/tools.h",
- "allocator/dispatcher/tls_unittest.cc",
- "allocator/partition_allocator/pointers/raw_ptr_test_support.h",
- "allocator/partition_allocator/pointers/raw_ptr_unittest.cc",
- "allocator/partition_allocator/pointers/raw_ref_unittest.cc",
- "at_exit_unittest.cc",
- "atomicops_unittest.cc",
- "auto_reset_unittest.cc",
- "barrier_callback_unittest.cc",
- "barrier_closure_unittest.cc",
- "base64_unittest.cc",
- "base64url_unittest.cc",
- "big_endian_unittest.cc",
- "bit_cast_unittest.cc",
- "bits_unittest.cc",
- "build_time_unittest.cc",
- "callback_list_unittest.cc",
- "cancelable_callback_unittest.cc",
- "check_is_test_unittest.cc",
- "check_unittest.cc",
- "command_line_unittest.cc",
- "component_export_unittest.cc",
- "containers/adapters_unittest.cc",
- "containers/buffer_iterator_unittest.cc",
- "containers/checked_iterators_unittest.cc",
- "containers/circular_deque_unittest.cc",
- "containers/contains_unittest.cc",
- "containers/contiguous_iterator_unittest.cc",
- "containers/enum_set_unittest.cc",
- "containers/erase_unittest.cc",
- "containers/extend_unittest.cc",
- "containers/fixed_flat_map_unittest.cc",
- "containers/fixed_flat_set_unittest.cc",
- "containers/flat_map_unittest.cc",
- "containers/flat_set_unittest.cc",
- "containers/flat_tree_unittest.cc",
- "containers/id_map_unittest.cc",
- "containers/intrusive_heap_unittest.cc",
- "containers/linked_list_unittest.cc",
- "containers/lru_cache_unittest.cc",
- "containers/small_map_unittest.cc",
- "containers/span_unittest.cc",
- "containers/stack_container_unittest.cc",
- "containers/unique_ptr_adapters_unittest.cc",
- "containers/vector_buffer_unittest.cc",
- "cpu_unittest.cc",
- "cxx17_backports_unittest.cc",
- "cxx20_is_constant_evaluated_unittest.cc",
- "debug/alias_unittest.cc",
- "debug/asan_service_unittest.cc",
- "debug/crash_logging_unittest.cc",
- "debug/debugger_unittest.cc",
- "debug/dump_without_crashing_unittest.cc",
- "debug/stack_trace_unittest.cc",
- "debug/task_trace_unittest.cc",
- "environment_unittest.cc",
- "feature_list_unittest.cc",
- "files/file_enumerator_unittest.cc",
- "files/file_error_or_unittest.cc",
- "files/file_path_unittest.cc",
- "files/file_path_watcher_unittest.cc",
- "files/file_proxy_unittest.cc",
- "files/file_unittest.cc",
- "files/file_util_unittest.cc",
- "files/important_file_writer_cleaner_unittest.cc",
- "files/important_file_writer_unittest.cc",
- "files/memory_mapped_file_unittest.cc",
- "files/safe_base_name_unittest.cc",
- "files/scoped_temp_dir_unittest.cc",
- "functional/bind_unittest.cc",
- "functional/callback_helpers_unittest.cc",
- "functional/callback_unittest.cc",
- "functional/function_ref_unittest.cc",
- "functional/identity_unittest.cc",
- "functional/invoke_unittest.cc",
- "functional/not_fn_unittest.cc",
- "functional/overloaded_unittest.cc",
- "gmock_unittest.cc",
- "hash/hash_unittest.cc",
- "hash/legacy_hash_unittest.cc",
- "hash/md5_constexpr_unittest.cc",
- "hash/md5_unittest.cc",
- "hash/sha1_unittest.cc",
- "i18n/break_iterator_unittest.cc",
- "i18n/case_conversion_unittest.cc",
- "i18n/char_iterator_unittest.cc",
- "i18n/character_encoding_unittest.cc",
- "i18n/file_util_icu_unittest.cc",
- "i18n/icu_string_conversions_unittest.cc",
- "i18n/icu_util_unittest.cc",
- "i18n/message_formatter_unittest.cc",
- "i18n/number_formatting_unittest.cc",
- "i18n/rtl_unittest.cc",
- "i18n/streaming_utf8_validator_unittest.cc",
- "i18n/string_search_unittest.cc",
- "i18n/time_formatting_unittest.cc",
- "i18n/timezone_unittest.cc",
- "i18n/transliterator_unittest.cc",
- "immediate_crash_unittest.cc",
- "json/json_parser_unittest.cc",
- "json/json_reader_unittest.cc",
- "json/json_value_converter_unittest.cc",
- "json/json_value_serializer_unittest.cc",
- "json/json_writer_unittest.cc",
- "json/string_escape_unittest.cc",
- "json/values_util_unittest.cc",
- "lazy_instance_unittest.cc",
- "logging_unittest.cc",
- "memory/aligned_memory_unittest.cc",
- "memory/discardable_memory_backing_field_trial_unittest.cc",
- "memory/discardable_shared_memory_unittest.cc",
- "memory/memory_pressure_listener_unittest.cc",
- "memory/platform_shared_memory_region_unittest.cc",
- "memory/ptr_util_unittest.cc",
- "memory/raw_ptr_asan_unittest.cc",
- "memory/ref_counted_memory_unittest.cc",
- "memory/ref_counted_unittest.cc",
- "memory/safe_ref_unittest.cc",
- "memory/shared_memory_hooks_unittest.cc",
- "memory/shared_memory_mapping_unittest.cc",
- "memory/shared_memory_region_unittest.cc",
- "memory/singleton_unittest.cc",
- "memory/unsafe_shared_memory_pool_unittest.cc",
- "memory/values_equivalent_unittest.cc",
- "memory/weak_auto_reset_unittest.cc",
- "memory/weak_ptr_unittest.cc",
- "message_loop/message_pump_glib_unittest.cc",
- "message_loop/message_pump_unittest.cc",
- "message_loop/work_id_provider_unittest.cc",
- "metrics/bucket_ranges_unittest.cc",
- "metrics/crc32_unittest.cc",
- "metrics/field_trial_params_unittest.cc",
- "metrics/field_trial_unittest.cc",
- "metrics/histogram_base_unittest.cc",
- "metrics/histogram_delta_serialization_unittest.cc",
- "metrics/histogram_functions_unittest.cc",
- "metrics/histogram_macros_unittest.cc",
- "metrics/histogram_samples_unittest.cc",
- "metrics/histogram_snapshot_manager_unittest.cc",
- "metrics/histogram_threadsafe_unittest.cc",
- "metrics/histogram_unittest.cc",
- "metrics/metrics_hashes_unittest.cc",
- "metrics/persistent_histogram_allocator_unittest.cc",
- "metrics/persistent_histogram_storage_unittest.cc",
- "metrics/persistent_memory_allocator_unittest.cc",
- "metrics/persistent_sample_map_unittest.cc",
- "metrics/ranges_manager_unittest.cc",
- "metrics/sample_map_unittest.cc",
- "metrics/sample_vector_unittest.cc",
- "metrics/single_sample_metrics_unittest.cc",
- "metrics/sparse_histogram_unittest.cc",
- "metrics/statistics_recorder_unittest.cc",
- "native_library_unittest.cc",
- "no_destructor_unittest.cc",
- "observer_list_threadsafe_unittest.cc",
- "observer_list_unittest.cc",
- "one_shot_event_unittest.cc",
- "parameter_pack_unittest.cc",
- "path_service_unittest.cc",
- "pickle_unittest.cc",
- "power_monitor/battery_level_provider_unittest.cc",
- "power_monitor/battery_state_sampler_unittest.cc",
- "power_monitor/moving_average_unittest.cc",
- "power_monitor/power_monitor_device_source_unittest.cc",
- "power_monitor/power_monitor_unittest.cc",
- "power_monitor/timer_sampling_event_source_unittest.cc",
- "process/environment_internal_unittest.cc",
- "process/memory_unittest.cc",
- "process/process_metrics_unittest.cc",
- "process/process_unittest.cc",
- "process/process_util_unittest.cc",
- "profiler/metadata_recorder_unittest.cc",
- "profiler/module_cache_unittest.cc",
- "profiler/sample_metadata_unittest.cc",
- "profiler/stack_buffer_unittest.cc",
- "profiler/stack_copier_suspend_unittest.cc",
- "profiler/stack_copier_unittest.cc",
- "profiler/stack_sampler_unittest.cc",
- "profiler/stack_sampling_profiler_unittest.cc",
- "rand_util_unittest.cc",
- "ranges/algorithm_unittest.cc",
- "ranges/functional_unittest.cc",
- "ranges/ranges_unittest.cc",
- "run_loop_unittest.cc",
- "safe_numerics_unittest.cc",
- "sampling_heap_profiler/lock_free_address_hash_set_unittest.cc",
- "scoped_add_feature_flags_unittest.cc",
- "scoped_clear_last_error_unittest.cc",
- "scoped_generic_unittest.cc",
- "scoped_multi_source_observation_unittest.cc",
- "scoped_native_library_unittest.cc",
- "scoped_observation_unittest.cc",
- "security_unittest.cc",
- "sequence_checker_unittest.cc",
- "sequence_token_unittest.cc",
- "state_transitions_unittest.cc",
- "stl_util_unittest.cc",
- "strings/abseil_string_number_conversions_unittest.cc",
- "strings/escape_unittest.cc",
- "strings/no_trigraphs_unittest.cc",
- "strings/pattern_unittest.cc",
- "strings/safe_sprintf_unittest.cc",
- "strings/strcat_unittest.cc",
- "strings/string_number_conversions_unittest.cc",
- "strings/string_piece_unittest.cc",
- "strings/string_split_unittest.cc",
- "strings/string_tokenizer_unittest.cc",
- "strings/string_util_unittest.cc",
- "strings/stringize_macros_unittest.cc",
- "strings/stringprintf_unittest.cc",
- "strings/sys_string_conversions_unittest.cc",
- "strings/to_string_test.cc",
- "strings/utf_offset_string_conversions_unittest.cc",
- "strings/utf_string_conversions_unittest.cc",
- "substring_set_matcher/string_pattern_unittest.cc",
- "substring_set_matcher/substring_set_matcher_unittest.cc",
- "supports_user_data_unittest.cc",
- "sync_socket_unittest.cc",
- "synchronization/atomic_flag_unittest.cc",
- "synchronization/condition_variable_unittest.cc",
- "synchronization/lock_unittest.cc",
- "synchronization/waitable_event_unittest.cc",
- "synchronization/waitable_event_watcher_unittest.cc",
- "sys_byteorder_unittest.cc",
- "system/sys_info_unittest.cc",
- "system/system_monitor_unittest.cc",
- "task/bind_post_task_unittest.cc",
- "task/cancelable_task_tracker_unittest.cc",
- "task/common/checked_lock_unittest.cc",
- "task/common/operations_controller_unittest.cc",
- "task/common/task_annotator_unittest.cc",
- "task/default_delayed_task_handle_delegate_unittest.cc",
- "task/deferred_sequenced_task_runner_unittest.cc",
- "task/delayed_task_handle_unittest.cc",
- "task/lazy_thread_pool_task_runner_unittest.cc",
- "task/post_job_unittest.cc",
- "task/scoped_set_task_priority_for_current_thread_unittest.cc",
- "task/sequence_manager/atomic_flag_set_unittest.cc",
- "task/sequence_manager/hierarchical_timing_wheel_unittest.cc",
- "task/sequence_manager/lazily_deallocated_deque_unittest.cc",
- "task/sequence_manager/sequence_manager_impl_unittest.cc",
- "task/sequence_manager/task_order_unittest.cc",
- "task/sequence_manager/task_queue_selector_unittest.cc",
- "task/sequence_manager/task_queue_unittest.cc",
- "task/sequence_manager/test/mock_time_message_pump_unittest.cc",
- "task/sequence_manager/thread_controller_power_monitor_unittest.cc",
- "task/sequence_manager/thread_controller_with_message_pump_impl_unittest.cc",
- "task/sequence_manager/timing_wheel_unittest.cc",
- "task/sequence_manager/wake_up_queue_unittest.cc",
- "task/sequence_manager/work_deduplicator_unittest.cc",
- "task/sequence_manager/work_queue_sets_unittest.cc",
- "task/sequence_manager/work_queue_unittest.cc",
- "task/sequenced_task_runner_unittest.cc",
- "task/single_thread_task_executor_unittest.cc",
- "task/single_thread_task_runner_unittest.cc",
- "task/task_runner_unittest.cc",
- "task/task_traits_unittest.cc",
- "task/thread_pool/can_run_policy_test.h",
- "task/thread_pool/delayed_priority_queue_unittest.cc",
- "task/thread_pool/delayed_task_manager_unittest.cc",
- "task/thread_pool/environment_config_unittest.cc",
- "task/thread_pool/job_task_source_unittest.cc",
- "task/thread_pool/pooled_single_thread_task_runner_manager_unittest.cc",
- "task/thread_pool/priority_queue_unittest.cc",
- "task/thread_pool/sequence_unittest.cc",
- "task/thread_pool/service_thread_unittest.cc",
- "task/thread_pool/task_source_sort_key_unittest.cc",
- "task/thread_pool/task_tracker_unittest.cc",
- "task/thread_pool/test_task_factory.cc",
- "task/thread_pool/test_task_factory.h",
- "task/thread_pool/test_utils.cc",
- "task/thread_pool/test_utils.h",
- "task/thread_pool/thread_group_impl_unittest.cc",
- "task/thread_pool/thread_group_unittest.cc",
- "task/thread_pool/thread_pool_impl_unittest.cc",
- "task/thread_pool/tracked_ref_unittest.cc",
- "task/thread_pool/worker_thread_set_unittest.cc",
- "task/thread_pool/worker_thread_unittest.cc",
- "task/thread_pool_unittest.cc",
- "template_util_unittest.cc",
- "test/gmock_callback_support_unittest.cc",
- "test/gmock_move_support_unittest.cc",
- "test/gtest_links_unittest.cc",
- "test/gtest_tags_unittest.cc",
- "test/gtest_xml_unittest_result_printer_unittest.cc",
- "test/launcher/test_launcher_unittest.cc",
- "test/launcher/test_results_tracker_unittest.cc",
- "test/memory/dangling_ptr_instrumentation.cc",
- "test/memory/dangling_ptr_instrumentation.h",
- "test/metrics/histogram_enum_reader_unittest.cc",
- "test/metrics/histogram_tester_unittest.cc",
- "test/metrics/user_action_tester_unittest.cc",
- "test/mock_callback_unittest.cc",
- "test/rectify_callback_unittest.cc",
- "test/repeating_test_future_unittest.cc",
- "test/scoped_feature_list_unittest.cc",
- "test/scoped_logging_settings.h",
- "test/scoped_mock_clock_override_unittest.cc",
- "test/scoped_mock_time_message_loop_task_runner_unittest.cc",
- "test/scoped_run_loop_timeout_unittest.cc",
- "test/task_environment_unittest.cc",
- "test/test_future_unittest.cc",
- "test/test_mock_time_task_runner_unittest.cc",
- "test/test_pending_task_unittest.cc",
- "test/test_waitable_event_unittest.cc",
- "third_party/dynamic_annotations/dynamic_annotations_compiletest.cc",
- "thread_annotations_unittest.cc",
- "threading/hang_watcher_unittest.cc",
- "threading/platform_thread_unittest.cc",
- "threading/post_task_and_reply_impl_unittest.cc",
- "threading/scoped_blocking_call_unittest.cc",
- "threading/scoped_thread_priority_unittest.cc",
- "threading/sequence_bound_unittest.cc",
- "threading/sequence_local_storage_map_unittest.cc",
- "threading/sequence_local_storage_slot_unittest.cc",
- "threading/simple_thread_unittest.cc",
- "threading/thread_checker_unittest.cc",
- "threading/thread_collision_warner_unittest.cc",
- "threading/thread_id_name_manager_unittest.cc",
- "threading/thread_local_storage_unittest.cc",
- "threading/thread_local_unittest.cc",
- "threading/thread_restrictions_unittest.cc",
- "threading/thread_unittest.cc",
- "threading/watchdog_unittest.cc",
- "time/pr_time_unittest.cc",
- "time/time_delta_from_string_unittest.cc",
- "time/time_unittest.cc",
- "timer/elapsed_timer_unittest.cc",
- "timer/hi_res_timer_manager_unittest.cc",
- "timer/lap_timer_unittest.cc",
- "timer/mock_timer_unittest.cc",
- "timer/timer_unittest.cc",
- "timer/wall_clock_timer_unittest.cc",
- "token_unittest.cc",
- "tools_sanity_unittest.cc",
- "traits_bag_unittest.cc",
- "tuple_unittest.cc",
- "types/cxx23_to_underlying_unittest.cc",
- "types/expected_unittest.cc",
- "types/id_type_unittest.cc",
- "types/optional_ref_unittest.cc",
- "types/optional_unittest.cc",
- "types/optional_util_unittest.cc",
- "types/pass_key_unittest.cc",
- "types/strong_alias_unittest.cc",
- "types/supports_ostream_operator_test.cc",
- "types/token_type_unittest.cc",
- "types/variant_util_unittest.cc",
- "unguessable_token_unittest.cc",
- "uuid_unittest.cc",
- "value_iterators_unittest.cc",
- "values_unittest.cc",
- "version_unittest.cc",
- "vlog_unittest.cc",
- ]
-
- if (use_cobalt_customizations) {
- sources -= [
- # Cobalt builds don't include build timestamps.
- "build_time_unittest.cc",
-
- # Since Starboard lacks abstractions for multi-processing, and shared
- # memory is solely used for inter-process communication, we disable
- # shared memory and process code in Cobalt.
- "memory/discardable_memory_backing_field_trial_unittest.cc",
- "memory/discardable_shared_memory_unittest.cc",
- "memory/memory_pressure_listener_unittest.cc",
- "memory/platform_shared_memory_region_unittest.cc",
- "memory/shared_memory_hooks_unittest.cc",
- "memory/shared_memory_mapping_unittest.cc",
- "memory/shared_memory_region_unittest.cc",
- "memory/unsafe_shared_memory_pool_unittest.cc",
-
- # MessagePumpUIStarboard lives on top of an external message pump
- # and behaves differently than normal message pumps.
- "message_loop/message_pump_unittest.cc",
- "process/process_metrics_unittest.cc",
- "process/process_unittest.cc",
- "process/process_util_unittest.cc",
-
- # moduleCache is not implemented in Starboard.
- "profiler/module_cache_unittest.cc",
-
- # TODO: b/327008491 - Not used by Cobalt, but should be tested to get
- # closer to Chrome.
- "feature_list_unittest.cc",
- "immediate_crash_unittest.cc",
- "metrics/field_trial_params_unittest.cc",
- "native_library_unittest.cc",
- "test/launcher/test_launcher_unittest.cc",
- "test/launcher/test_results_tracker_unittest.cc",
- "test/metrics/histogram_enum_reader_unittest.cc",
- "test/scoped_feature_list_unittest.cc",
- "threading/hang_watcher_unittest.cc",
- "test/gtest_links_unittest.cc",
- "test/gtest_tags_unittest.cc",
- "test/gtest_xml_unittest_result_printer_unittest.cc",
-
- # SyncSocket is not implemented in Starboard.
- "sync_socket_unittest.cc",
-
- # WaitableEventWatcher is not implemented by Starboard.
- "synchronization/waitable_event_watcher_unittest.cc",
-
- # Depends on USE_PARTITION_ALLOC.
- "allocator/partition_allocator/pointers/raw_ptr_test_support.h",
- "allocator/partition_allocator/pointers/raw_ptr_unittest.cc",
- "allocator/partition_allocator/pointers/raw_ref_unittest.cc",
-
- # Previously disabled tests.
- "environment_unittest.cc",
- "files/memory_mapped_file_unittest.cc",
- ]
-
- if (is_win && cobalt_pending_clean_up) {
- sources -= [
- "power_monitor/battery_state_sampler_unittest.cc",
- "profiler/stack_sampling_profiler_unittest.cc",
- "ranges/algorithm_unittest.cc",
- "safe_numerics_unittest.cc",
- "strings/string_util_unittest.cc",
- "task/sequence_manager/atomic_flag_set_unittest.cc",
- "test/test_future_unittest.cc",
- "tools_sanity_unittest.cc",
- "types/expected_unittest.cc",
-
- # NiceMock needs to be fixed
- "threading/scoped_blocking_call_unittest.cc",
- ]
- cflags = [ "/wd4172" ]
- }
-
- if (is_clang) {
- cflags_cc = [ "-Wno-trigraphs" ]
- }
- }
-
- if (!is_cronet_build) {
- # location_unittest.cc fails gn check for tracing-shimmed Cronet builds.
- # Cronet buildbot do not run base_unittests, so exclusing this test
- # instead of adding a nogncheck is preferred (crbug.com/1400235).
- sources += [ "location_unittest.cc" ]
- }
-
- if (build_rust_base_conversions) {
- sources += [
- "containers/span_rust_unittest.cc",
- "strings/string_piece_rust_unittest.cc",
- ]
- }
-
- if (use_custom_libcxx && enable_safe_libcxx) {
- sources += [ "libcpp_hardening_test.cc" ]
- }
-
- defines = []
-
- deps = [
- ":arm_bti_testfunctions",
- ":base",
- ":base_stack_sampling_profiler_test_util",
- ":feature_list_buildflags",
- ":i18n",
- ":sanitizer_buildflags",
- "//base/allocator:buildflags",
- "//base/test:native_library_test_utils",
- "//base/test:run_all_unittests",
- "//base/test:test_support",
- "//base/third_party/dynamic_annotations",
- "//build:blink_buildflags",
- "//build:chromecast_buildflags",
- "//build:chromeos_buildflags",
- "//testing/gmock",
- "//testing/gtest",
- "//third_party/icu",
- "//third_party/modp_b64",
- ]
-
- data_deps = [
- ]
-
- if (is_android && enable_chrome_android_internal) {
- data_deps += [ "//clank/build/bot/filters:base_unittests_filters" ]
- }
-
- if (build_rust_base_conversions) {
- deps += [ "//build/rust:cxx_cppdeps" ]
- }
-
- if (is_apple && !is_starboard) {
- public_deps = [ ":base_unittests_bundle_data" ]
-
- deps += [ ":base_unittests_arc" ]
- }
-
- if (is_starboard){
- data_deps += [
- ":base_unittests_bundle_data",
- "//cobalt/network:copy_ssl_certificates",
- ]
- }
-
- if (!is_ios && !is_starboard) {
- sources += [ "allocator/partition_allocator/tagging_unittest.cc" ]
- }
-
- data = [
- "test/data/",
- "//tools/metrics/histograms/enums.xml",
- ]
-
- if (is_win && !is_starboard) {
- deps += [ "//base/win:base_win_buildflags" ]
-
- sources += [
- "debug/gdi_debug_util_win_unittest.cc",
- "file_version_info_win_unittest.cc",
- "process/launch_unittest_win.cc",
- "test/fake_iasync_operation_win_unittest.cc",
- "test/test_file_util_win_unittest.cc",
- "test/test_reg_util_win_unittest.cc",
- "threading/platform_thread_win_unittest.cc",
- "time/time_win_unittest.cc",
- "win/access_control_list_unittest.cc",
- "win/access_token_unittest.cc",
- "win/async_operation_unittest.cc",
- "win/com_init_balancer_unittest.cc",
- "win/com_init_check_hook_unittest.cc",
- "win/com_init_util_unittest.cc",
- "win/dark_mode_support_unittest.cc",
- "win/dispatch_stub.cc",
- "win/dispatch_stub.h",
- "win/dllmain.cc",
- "win/embedded_i18n/language_selector_unittest.cc",
- "win/enum_variant_unittest.cc",
- "win/event_trace_consumer_unittest.cc",
- "win/event_trace_controller_unittest.cc",
- "win/event_trace_provider_unittest.cc",
- "win/hstring_reference_unittest.cc",
- "win/i18n_unittest.cc",
- "win/map_unittest.cc",
- "win/message_window_unittest.cc",
- "win/object_watcher_unittest.cc",
- "win/pe_image_reader_unittest.cc",
- "win/pe_image_unittest.cc",
- "win/post_async_results_unittest.cc",
- "win/reference_unittest.cc",
- "win/registry_unittest.cc",
- "win/scoped_bstr_unittest.cc",
- "win/scoped_handle_unittest.cc",
- "win/scoped_hstring_unittest.cc",
- "win/scoped_localalloc_unittest.cc",
- "win/scoped_process_information_unittest.cc",
- "win/scoped_safearray_unittest.cc",
- "win/scoped_variant_unittest.cc",
- "win/scoped_winrt_initializer_unittest.cc",
- "win/security_descriptor_unittest.cc",
- "win/security_util_unittest.cc",
- "win/shortcut_unittest.cc",
- "win/sid_unittest.cc",
- "win/startup_information_unittest.cc",
- "win/variant_conversions_unittest.cc",
- "win/variant_vector_unittest.cc",
- "win/vector_unittest.cc",
- "win/win_includes_unittest.cc",
- "win/win_util_unittest.cc",
- "win/windows_version_unittest.cc",
- "win/winrt_storage_util_unittest.cc",
- "win/wmi_unittest.cc",
- "win/wrapped_window_proc_unittest.cc",
- ]
-
- if (enable_cet_shadow_stack) {
- sources += [ "win/cet_shadow_stack_unittest.cc" ]
- }
-
- libs = [
- "ntdll.lib",
- "onecore.lib",
- ]
- }
-
- if (!use_cobalt_customizations && (is_linux || is_chromeos)) {
- sources += [
- "debug/proc_maps_linux_unittest.cc",
- "files/scoped_file_linux_unittest.cc",
- ]
-
- if (!!use_cobalt_customizations && !is_nacl) {
- deps += [ ":stack_canary_linux_unittests" ]
- }
- }
-
- if (is_mac && !is_starboard) {
- sources += [
- "allocator/partition_allocator/shim/allocator_interception_mac_unittest.mm",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac_unittest.cc",
- "enterprise_util_mac_unittest.mm",
- "mac/backup_util_unittest.mm",
- "mac/bind_objc_block_unittest.mm",
- "mac/call_with_eh_frame_unittest.mm",
- "mac/dispatch_source_mach_unittest.cc",
- "mac/foundation_util_unittest.mm",
- "mac/mac_util_unittest.mm",
- "mac/mach_port_rendezvous_unittest.cc",
- "mac/scoped_mach_vm_unittest.cc",
- "mac/scoped_nsobject_unittest.mm",
- "mac/scoped_objc_class_swizzler_unittest.mm",
- "mac/scoped_sending_event_unittest.mm",
- "message_loop/message_pump_mac_unittest.mm",
- "power_monitor/thermal_state_observer_mac_unittest.mm",
- "process/memory_unittest_mac.h",
- "process/memory_unittest_mac.mm",
- "strings/sys_string_conversions_mac_unittest.mm",
- ]
- }
-
- if (is_apple && enable_mach_absolute_time_ticks && !is_starboard) {
- sources += [ "time/time_mac_unittest.mm" ]
- }
-
- if (!use_cobalt_customizations && is_posix) {
- sources += [
- "files/dir_reader_posix_unittest.cc",
- "files/file_descriptor_watcher_posix_unittest.cc",
- "memory/madv_free_discardable_memory_allocator_posix_unittest.cc",
- "memory/madv_free_discardable_memory_posix_unittest.cc",
- "message_loop/fd_watch_controller_posix_unittest.cc",
- "posix/file_descriptor_shuffle_unittest.cc",
- "posix/unix_domain_socket_unittest.cc",
- ]
- if (!is_nacl && !is_apple) {
- sources += [
- "profiler/stack_base_address_posix_unittest.cc",
- "profiler/stack_copier_signal_unittest.cc",
- "profiler/thread_delegate_posix_unittest.cc",
- ]
- }
- }
-
- # Allow more direct string conversions on platforms with native utf8
- # strings
- if (is_apple || is_chromeos || is_castos || is_cast_android || is_fuchsia) {
- defines += [ "SYSTEM_NATIVE_UTF8" ]
- }
-
- if (is_android && !use_cobalt_customizations) {
- # Add unwind tables in base_unittests_apk test apk. The unwind tables are
- # generated from debug info in the binary. Removing "default_symbols" and
- # adding symbols config removes the "strip_debug" config that strips the
- # debug info, on base unittests apk.
- if (can_unwind_with_cfi_table || enable_arm_cfi_table) {
- configs -= [ "//build/config/compiler:default_symbols" ]
- if (symbol_level == 2) {
- configs += [ "//build/config/compiler:symbols" ]
- } else {
- configs += [ "//build/config/compiler:minimal_symbols" ]
- }
- add_unwind_tables_in_apk = true
- }
- if (can_unwind_with_cfi_table) {
- sources += [ "trace_event/cfi_backtrace_android_unittest.cc" ]
- }
- if (current_cpu == "arm") {
- sources += [
- "profiler/chrome_unwind_info_android_unittest.cc",
- "profiler/chrome_unwinder_android_unittest.cc",
- ]
- }
- if (current_cpu == "arm64") {
- sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
- }
- if (!exclude_unwind_tables &&
- (current_cpu == "arm" || current_cpu == "arm64")) {
- sources += [
- "profiler/libunwindstack_unwinder_android_unittest.cc",
- "profiler/native_unwinder_android_unittest.cc",
- ]
- deps += [
- ":base_profiler_reparsing_test_support_library",
- ":base_profiler_test_support_java",
- ":base_profiler_test_support_jni_headers",
- ":base_profiler_test_support_library",
- ":native_unwinder_android",
- ]
- }
-
- sources += [
- "android/android_image_reader_compat_unittest.cc",
- "android/application_status_listener_unittest.cc",
- "android/child_process_unittest.cc",
- "android/content_uri_utils_unittest.cc",
- "android/java_handler_thread_unittest.cc",
- "android/jni_android_unittest.cc",
- "android/jni_array_unittest.cc",
- "android/jni_string_unittest.cc",
- "android/library_loader/library_prefetcher_unittest.cc",
- "android/linker/linker_jni.cc",
- "android/linker/linker_jni.h",
- "android/linker/linker_unittest.cc",
- "android/meminfo_dump_provider_unittest.cc",
- "android/path_utils_unittest.cc",
- "android/radio_utils_unittest.cc",
- "android/reached_addresses_bitset_unittest.cc",
- "android/scoped_java_ref_unittest.cc",
- "android/sys_utils_unittest.cc",
- "android/unguessable_token_android_unittest.cc",
- "os_compat_android_unittest.cc",
- ]
-
- # Android does not use test_launcher to run gtests.
- sources -= [
- "process/process_unittest.cc",
- "process/process_util_unittest.cc",
- "test/gtest_links_unittest.cc",
- "test/gtest_tags_unittest.cc",
- "test/gtest_xml_unittest_result_printer_unittest.cc",
- "test/launcher/test_launcher_unittest.cc",
- "test/launcher/test_results_tracker_unittest.cc",
- ]
- deps += [
- ":base_java_unittest_support",
- "//base/test:test_support_java",
- ]
- }
-
- if (build_allocation_stack_trace_recorder) {
- sources += [ "debug/allocation_trace_unittest.cc" ]
- }
-
- if (is_starboard) {
- sources += [ "message_loop/message_pump_io_starboard_unittest.cc" ]
- }
-
- if (is_ios && !is_starboard) {
- sources += [
- "ios/device_util_unittest.mm",
- "ios/scoped_critical_action_unittest.mm",
- ]
-
- if (is_cronet_build) {
- sources += [ "message_loop/message_pump_io_ios_unittest.cc" ]
- } else {
- sources += [ "message_loop/message_pump_kqueue_unittest.cc" ]
- }
-
- # ios does not use test_launcher to run gtests.
- sources -= [
- "files/file_path_watcher_unittest.cc",
- "memory/discardable_shared_memory_unittest.cc",
- "process/memory_unittest.cc",
- "process/process_unittest.cc",
- "process/process_util_unittest.cc",
- "sync_socket_unittest.cc",
- "synchronization/waitable_event_watcher_unittest.cc",
- "test/gtest_links_unittest.cc",
- "test/gtest_tags_unittest.cc",
- "test/gtest_xml_unittest_result_printer_unittest.cc",
- "test/launcher/test_launcher_unittest.cc",
- "test/launcher/test_results_tracker_unittest.cc",
- ]
-
- sources += [
- # Pull in specific Mac files for iOS.
- "mac/backup_util_unittest.mm",
- "mac/bind_objc_block_unittest.mm",
- "mac/foundation_util_unittest.mm",
- "mac/scoped_nsobject_unittest.mm",
- "strings/sys_string_conversions_mac_unittest.mm",
- ]
-
- sources -= [
- # The immediate crash tests require shared libraries, which we don't
- # support loading on iOS.
- "immediate_crash_unittest.cc",
- ]
-
- if (use_allocator_shim) {
- sources += [
- "allocator/partition_allocator/shim/allocator_interception_mac_unittest.mm",
- "allocator/partition_allocator/shim/malloc_zone_functions_mac_unittest.cc",
- ]
- }
-
- if (use_blink) {
- sources += [ "files/file_path_watcher_unittest.cc" ]
- }
- }
-
- if (use_partition_alloc) {
- sources += [
- "allocator/partition_allocator/address_pool_manager_unittest.cc",
- "allocator/partition_allocator/address_space_randomization_unittest.cc",
- "allocator/partition_allocator/compressed_pointer_unittest.cc",
- "allocator/partition_allocator/freeslot_bitmap_unittest.cc",
- "allocator/partition_allocator/hardening_unittest.cc",
- "allocator/partition_allocator/memory_reclaimer_unittest.cc",
- "allocator/partition_allocator/page_allocator_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/bits_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/component_export_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/cpu_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/cxx17_backports_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/logging_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/rand_util_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/scoped_clear_last_error_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/strings/stringprintf_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/thread_annotations_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_unittest.cc",
- "allocator/partition_allocator/partition_lock_unittest.cc",
- "allocator/partition_allocator/reverse_bytes_unittest.cc",
- "allocator/partition_allocator/thread_cache_unittest.cc",
- ]
-
- if (use_starscan) {
- sources += [
- "allocator/partition_allocator/starscan/pcscan_scheduling_unittest.cc",
- "allocator/partition_allocator/starscan/pcscan_unittest.cc",
- "allocator/partition_allocator/starscan/scan_loop_unittest.cc",
- "allocator/partition_allocator/starscan/stack/stack_unittest.cc",
- "allocator/partition_allocator/starscan/state_bitmap_unittest.cc",
- ]
- }
-
- if ((is_android || is_linux) && target_cpu == "arm64") {
- cflags = [
- "-Xclang",
- "-target-feature",
- "-Xclang",
- "+mte",
- ]
- }
-
- if (is_android) {
- sources += [
- "allocator/partition_allocator/partition_alloc_base/files/file_path_pa_unittest.cc",
- "allocator/partition_allocator/partition_alloc_base/native_library_pa_unittest.cc",
- ]
- } else if (is_fuchsia) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/fuchsia/fuchsia_logging_pa_unittest.cc" ]
- }
-
- if (enable_pkeys && is_debug && !is_component_build) {
- # This test requires RELRO, which is not enabled in component builds.
- # Also, require a debug build, since we only disable stack protectors in
- # debug builds in partition alloc (see below why it's needed).
- sources += [ "allocator/partition_allocator/pkey_unittest.cc" ]
-
- # We want to test the pkey code without access to memory that is not
- # pkey-tagged. This will allow us to catch unintended memory accesses
- # that could break our security assumptions. The stack protector reads a
- # value from the TLS which won't be pkey-tagged, hence disabling it for
- # the test.
- configs += [ ":no_stack_protector" ]
- }
-
- deps += [ ":partition_alloc_test_support" ]
- }
-
- if (is_mac && !is_starboard) {
- sources += [ "message_loop/message_pump_kqueue_unittest.cc" ]
- frameworks = [
- "CoreFoundation.framework",
- "Foundation.framework",
- "OpenCL.framework",
- ]
- if (current_cpu == "x64") {
- deps += [ ":base_profiler_test_support_library" ]
- }
- }
-
- if (!use_cobalt_customizations && (is_fuchsia || is_linux || is_chromeos)) {
- sources += [
- "debug/elf_reader_unittest.cc",
- "debug/test_elf_image_builder.cc",
- "debug/test_elf_image_builder.h",
- ]
-
- deps += [ "//base/test:malloc_wrapper" ]
- defines += [
- # This library is used by ElfReaderTest to test reading elf files.
- "MALLOC_WRAPPER_LIB=\"${shlib_prefix}malloc_wrapper${shlib_extension}\"",
- ]
-
- if (!is_component_build) {
- # Set rpath to find libmalloc_wrapper.so even in a non-component build.
- configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
- }
- }
-
- if (is_chromeos_lacros) {
- sources += [ "i18n/icu_mergeable_data_file_unittest.cc" ]
- }
-
- if (!use_cobalt_customizations && (is_linux || is_chromeos_lacros)) {
- sources += [
- "linux_util_unittest.cc",
- "nix/xdg_util_unittest.cc",
- ]
- }
-
- if (!use_glib) {
- sources -= [ "message_loop/message_pump_glib_unittest.cc" ]
- }
-
- if (use_libevent) {
- sources += [ "message_loop/message_pump_libevent_unittest.cc" ]
- deps += [
- ":message_pump_buildflags",
- "//third_party/libevent",
- ]
- }
-
- if (is_fuchsia) {
- sources += [
- "files/dir_reader_posix_unittest.cc",
- "files/file_descriptor_watcher_posix_unittest.cc",
- "fuchsia/fidl_event_handler_unittest.cc",
- "fuchsia/file_utils_unittest.cc",
- "fuchsia/filtered_service_directory_unittest.cc",
- "fuchsia/fuchsia_logging_unittest.cc",
- "fuchsia/intl_profile_watcher_unittest.cc",
- "fuchsia/mem_buffer_util_unittest.cc",
- "fuchsia/scoped_natural_service_binding_unittest.cc",
- "fuchsia/scoped_natural_service_publisher_unittest.cc",
- "fuchsia/scoped_service_binding_unittest.cc",
- "fuchsia/scoped_service_publisher_unittest.cc",
- "fuchsia/system_build_info_unittest.cc",
- "fuchsia/system_product_info_unittest.cc",
- "fuchsia/test_component_context_for_process_unittest.cc",
- "fuchsia/time_zone_data_unittest.cc",
- "message_loop/fd_watch_controller_posix_unittest.cc",
- "posix/file_descriptor_shuffle_unittest.cc",
- ]
-
- # FilePatchWatcherImpl is not implemented. See crbug.com/851641.
- # TODO(crbug.com/1430566): Convert this subtraction to a condition where
- # it is added.
- sources -= [ "files/file_path_watcher_unittest.cc" ]
-
- deps += [
- ":test_interface_impl",
- ":test_interface_natural_impl",
- ":test_log_listener_safe",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.intl:fuchsia.intl_hlcpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
- "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp",
- "//third_party/fuchsia-sdk/sdk/pkg/async",
- "//third_party/fuchsia-sdk/sdk/pkg/async-default",
- "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp",
- "//third_party/fuchsia-sdk/sdk/pkg/fdio",
- "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
- ]
-
- additional_manifest_fragments =
- [ "//build/config/fuchsia/test/logger.shard.test-cml" ]
- }
-
- if (!use_cobalt_customizations && !is_fuchsia && !is_ios) {
- sources += [ "files/file_locking_unittest.cc" ]
- }
-
- if (use_cobalt_customizations) {
- sources -= [ "files/file_path_watcher_unittest.cc" ]
- }
-
- if (is_android && !use_cobalt_customizations) {
- deps += [ "//testing/android/native_test:native_test_native_code" ]
- sources += [
- "debug/elf_reader_unittest.cc",
- "debug/proc_maps_linux_unittest.cc",
- "debug/test_elf_image_builder.cc",
- "debug/test_elf_image_builder.h",
- ]
- }
-
- if (is_win && !is_starboard) {
- deps += [ "//base:scoped_handle_test_dll" ]
- if (current_cpu == "x64" || current_cpu == "arm64") {
- sources += [ "profiler/win32_stack_frame_unwinder_unittest.cc" ]
- deps += [ ":base_profiler_test_support_library" ]
- }
- sources += [ "files/os_validation_win_unittest.cc" ]
-
- if (toolchain_has_rust && win_enable_cfg_guards) {
- deps += [ ":rust_cfg_win_test" ]
- }
- }
- if (is_apple && !is_starboard) {
- sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
- }
- if (is_chromeos && current_cpu == "x64") {
- sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
- deps += [ ":base_profiler_test_support_library" ]
- }
-
- if (use_allocator_shim) {
- sources += [
- "allocator/partition_allocator/shim/allocator_shim_unittest.cc",
- "sampling_heap_profiler/poisson_allocation_sampler_unittest.cc",
- "sampling_heap_profiler/sampling_heap_profiler_unittest.cc",
- ]
-
- if (is_win) {
- sources +=
- [ "allocator/partition_allocator/shim/winheap_stubs_win_unittest.cc" ]
- }
-
- sources += [
- "allocator/partition_alloc_support_unittest.cc",
- "allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc",
- ]
- }
-
- if (enable_base_tracing) {
- sources += [
- "test/trace_event_analyzer_unittest.cc",
- "trace_event/memory_allocator_dump_unittest.cc",
- "trace_event/memory_dump_manager_unittest.cc",
- "trace_event/memory_dump_scheduler_unittest.cc",
- "trace_event/memory_infra_background_allowlist_unittest.cc",
- "trace_event/memory_usage_estimator_unittest.cc",
- "trace_event/process_memory_dump_unittest.cc",
- "trace_event/trace_arguments_unittest.cc",
- "trace_event/trace_category_unittest.cc",
- "trace_event/trace_config_unittest.cc",
- "trace_event/trace_conversion_helper_unittest.cc",
- "trace_event/trace_event_unittest.cc",
- "trace_event/traced_value_support_unittest.cc",
- "trace_event/traced_value_unittest.cc",
- "trace_event/typed_macros_unittest.cc",
- "tracing/perfetto_task_runner_unittest.cc",
- ]
-
- if (cobalt_pending_clean_up) {
- sources -= [
- "trace_event/memory_allocator_dump_unittest.cc",
- "trace_event/process_memory_dump_unittest.cc",
- "trace_event/typed_macros_unittest.cc",
- ]
- }
-
- if (is_android && !is_starboard) {
- sources += [
- "trace_event/cpufreq_monitor_android_unittest.cc",
- "trace_event/java_heap_dump_provider_android_unittest.cc",
- ]
- }
-
- deps += [
- "//third_party/perfetto/include/perfetto/trace_processor:storage",
- "//third_party/perfetto/protos/perfetto/trace:lite",
- "//third_party/perfetto/protos/perfetto/trace/interned_data:lite",
- "//third_party/perfetto/protos/perfetto/trace/track_event:lite",
- ]
- }
-}
-
-# Test that CFG is enabled in Rust code.
-if (is_win && toolchain_has_rust) {
- source_set("rust_cfg_win_test") {
- testonly = true
- deps = [
- ":base",
- "//testing/gtest",
- ]
- data_deps = [ "//build/rust/tests/test_control_flow_guard" ]
- sources = [ "memory/rust_cfg_win_unittest.cc" ]
- }
-}
-
-action("build_date") {
- script = "write_build_date_header.py"
-
- outputs = [ "$target_gen_dir/generated_build_date.h" ]
-
- args = [
- rebase_path("$target_gen_dir/generated_build_date.h", root_build_dir),
- build_timestamp,
- ]
-}
-
-if (enable_nocompile_tests) {
- nocompile_test("base_nocompile_tests") {
- sources = [
- "allocator/partition_allocator/partition_alloc_base/thread_annotations_pa_unittest.nc",
- "allocator/partition_allocator/pointers/raw_ptr_unittest.nc",
- "allocator/partition_allocator/pointers/raw_ref_unittest.nc",
- "callback_list_unittest.nc",
- "containers/buffer_iterator_unittest.nc",
- "containers/checked_iterators_unittest.nc",
- "containers/contains_unittest.nc",
- "containers/enum_set_unittest.nc",
- "containers/span_unittest.nc",
- "debug/crash_logging_unittest.nc",
- "functional/bind_unittest.nc",
- "functional/callback_unittest.nc",
- "functional/function_ref_unittest.nc",
- "functional/overloaded_unittest.nc",
- "memory/ref_counted_unittest.nc",
- "memory/weak_ptr_unittest.nc",
- "metrics/field_trial_params_unittest.nc",
- "metrics/histogram_unittest.nc",
- "no_destructor_unittest.nc",
- "observer_list_unittest.nc",
- "sequence_checker_unittest.nc",
- "strings/string_piece_unittest.nc",
- "task/bind_post_task_unittest.nc",
- "task/task_traits_unittest.nc",
- "thread_annotations_unittest.nc",
- "traits_bag_unittest.nc",
- "types/pass_key_unittest.nc",
- "types/variant_util_unittest.nc",
- "values_unittest.nc",
- ]
-
- deps = [
- ":base",
- "//base/test:run_all_unittests",
- "//testing/gtest",
- ]
-
- # Since the nocompile test is not able to inspect the contents of
- # include_dirs, we need to specify the Abseil include dir manually.
- include_dirs = [ "//third_party/abseil-cpp" ]
- }
-}
-
-if ((is_android || is_robolectric) && !use_cobalt_customizations) {
- generate_jni("base_jni_headers") {
- sources = [
- "android/java/src/org/chromium/base/ApkAssets.java",
- "android/java/src/org/chromium/base/ApplicationStatus.java",
- "android/java/src/org/chromium/base/BaseFeatureList.java",
- "android/java/src/org/chromium/base/BuildInfo.java",
- "android/java/src/org/chromium/base/BundleUtils.java",
- "android/java/src/org/chromium/base/Callback.java",
- "android/java/src/org/chromium/base/CommandLine.java",
- "android/java/src/org/chromium/base/ContentUriUtils.java",
- "android/java/src/org/chromium/base/CpuFeatures.java",
- "android/java/src/org/chromium/base/EarlyTraceEvent.java",
- "android/java/src/org/chromium/base/EventLog.java",
- "android/java/src/org/chromium/base/FeatureList.java",
- "android/java/src/org/chromium/base/Features.java",
- "android/java/src/org/chromium/base/FieldTrialList.java",
- "android/java/src/org/chromium/base/FileUtils.java",
- "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
- "android/java/src/org/chromium/base/IntStringCallback.java",
- "android/java/src/org/chromium/base/JNIUtils.java",
- "android/java/src/org/chromium/base/JavaExceptionReporter.java",
- "android/java/src/org/chromium/base/JavaHandlerThread.java",
- "android/java/src/org/chromium/base/LocaleUtils.java",
- "android/java/src/org/chromium/base/MemoryPressureListener.java",
- "android/java/src/org/chromium/base/PathService.java",
- "android/java/src/org/chromium/base/PathUtils.java",
- "android/java/src/org/chromium/base/PiiElider.java",
- "android/java/src/org/chromium/base/PowerMonitor.java",
- "android/java/src/org/chromium/base/RadioUtils.java",
- "android/java/src/org/chromium/base/SysUtils.java",
- "android/java/src/org/chromium/base/ThreadUtils.java",
- "android/java/src/org/chromium/base/TimezoneUtils.java",
- "android/java/src/org/chromium/base/TraceEvent.java",
- "android/java/src/org/chromium/base/UnguessableToken.java",
- "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
- "android/java/src/org/chromium/base/library_loader/LibraryPrefetcher.java",
- "android/java/src/org/chromium/base/memory/JavaHeapDumpGenerator.java",
- "android/java/src/org/chromium/base/memory/MemoryInfoBridge.java",
- "android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
- "android/java/src/org/chromium/base/metrics/StatisticsRecorderAndroid.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java",
- "android/java/src/org/chromium/base/task/PostTask.java",
- "android/java/src/org/chromium/base/task/TaskRunnerImpl.java",
- ]
-
- public_deps = [
- ":android_runtime_jni_headers",
- ":android_runtime_unchecked_jni_headers",
- ]
- }
-
- generate_jar_jni("android_runtime_jni_headers") {
- classes = [ "java/lang/Runtime.class" ]
- }
-
- generate_jar_jni("android_runtime_unchecked_jni_headers") {
- classes = [ "java/lang/Runnable.class" ]
- unchecked_exceptions = true
- }
-} # is_android || is_robolectric
-
-if (is_android && !use_cobalt_customizations) {
- java_library("jni_java") {
- supports_android = true
- sources = [
- "android/java/src/org/chromium/base/JniException.java",
- "android/java/src/org/chromium/base/JniStaticTestMocker.java",
- "android/java/src/org/chromium/base/NativeLibraryLoadedStatus.java",
- "android/java/src/org/chromium/base/annotations/AccessedByNative.java",
- "android/java/src/org/chromium/base/annotations/CalledByNative.java",
- "android/java/src/org/chromium/base/annotations/CalledByNativeForTesting.java",
- "android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java",
- "android/java/src/org/chromium/base/annotations/JNIAdditionalImport.java",
- "android/java/src/org/chromium/base/annotations/JNINamespace.java",
- "android/java/src/org/chromium/base/annotations/JniIgnoreNatives.java",
- "android/java/src/org/chromium/base/annotations/NativeClassQualifiedName.java",
- "android/java/src/org/chromium/base/annotations/NativeMethods.java",
- ]
-
- # Public because @CheckDiscard is added to generated *Jni.java files.
- public_deps = [ "//build/android:build_java" ]
- }
-
- java_cpp_features("java_features_srcjar") {
- # External code should depend on ":base_java" instead.
- visibility = [ ":*" ]
- sources = [
- "android/base_features.cc",
- "features.cc",
- "task/task_features.cc",
- ]
- template = "android/java/src/org/chromium/base/BaseFeatures.java.tmpl"
- }
-
- java_cpp_strings("java_switches_srcjar") {
- # External code should depend on ":base_java" instead.
- visibility = [ ":*" ]
- sources = [ "base_switches.cc" ]
- template = "android/java/src/org/chromium/base/BaseSwitches.java.tmpl"
- }
-
- android_library("process_launcher_java") {
- srcjar_deps = [ ":process_launcher_aidl" ]
- deps = [
- ":base_java",
- ":jni_java",
- "//build/android:build_java",
- "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
- "//third_party/androidx:androidx_annotation_annotation_experimental_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_collection_collection_java",
- "//third_party/androidx:androidx_core_core_java",
- ]
- sources = [
- "android/java/src/org/chromium/base/process_launcher/BindService.java",
- "android/java/src/org/chromium/base/process_launcher/ChildConnectionAllocator.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessConstants.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessLauncher.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java",
- "android/java/src/org/chromium/base/process_launcher/ChildProcessServiceDelegate.java",
- "android/java/src/org/chromium/base/process_launcher/ChildServiceConnection.java",
- "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionDelegate.java",
- "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionFactory.java",
- "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionImpl.java",
- "android/java/src/org/chromium/base/process_launcher/FileDescriptorInfo.java",
- ]
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- }
-
- android_library("base_java") {
- srcjar_deps = [
- ":base_android_java_enums_srcjar",
- ":java_features_srcjar",
- ":java_switches_srcjar",
- ]
-
- deps = [
- ":jni_java",
- "//build/android:build_java",
- "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
- "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
- "//third_party/androidx:androidx_annotation_annotation_experimental_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_collection_collection_java",
- "//third_party/androidx:androidx_core_core_java",
- ]
-
- sources = [
- "android/java/src/org/chromium/base/ActivityState.java",
- "android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
- "android/java/src/org/chromium/base/ApkAssets.java",
- "android/java/src/org/chromium/base/ApplicationStatus.java",
- "android/java/src/org/chromium/base/BaseFeatureList.java",
- "android/java/src/org/chromium/base/BuildInfo.java",
- "android/java/src/org/chromium/base/BundleUtils.java",
- "android/java/src/org/chromium/base/Callback.java",
- "android/java/src/org/chromium/base/CallbackController.java",
- "android/java/src/org/chromium/base/CollectionUtil.java",
- "android/java/src/org/chromium/base/CommandLine.java",
- "android/java/src/org/chromium/base/CommandLineInitUtil.java",
- "android/java/src/org/chromium/base/ContentUriUtils.java",
- "android/java/src/org/chromium/base/ContextUtils.java",
- "android/java/src/org/chromium/base/CpuFeatures.java",
- "android/java/src/org/chromium/base/DiscardableReferencePool.java",
- "android/java/src/org/chromium/base/EarlyTraceEvent.java",
- "android/java/src/org/chromium/base/EventLog.java",
- "android/java/src/org/chromium/base/FeatureList.java",
- "android/java/src/org/chromium/base/Features.java",
- "android/java/src/org/chromium/base/FieldTrialList.java",
- "android/java/src/org/chromium/base/FileUtils.java",
- "android/java/src/org/chromium/base/Flag.java",
- "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
- "android/java/src/org/chromium/base/IntStringCallback.java",
- "android/java/src/org/chromium/base/JNIUtils.java",
- "android/java/src/org/chromium/base/JavaExceptionReporter.java",
- "android/java/src/org/chromium/base/JavaHandlerThread.java",
- "android/java/src/org/chromium/base/LifetimeAssert.java",
- "android/java/src/org/chromium/base/LocaleUtils.java",
- "android/java/src/org/chromium/base/Log.java",
- "android/java/src/org/chromium/base/MathUtils.java",
- "android/java/src/org/chromium/base/MemoryPressureListener.java",
- "android/java/src/org/chromium/base/ObserverList.java",
- "android/java/src/org/chromium/base/PackageManagerUtils.java",
- "android/java/src/org/chromium/base/PackageUtils.java",
- "android/java/src/org/chromium/base/PathService.java",
- "android/java/src/org/chromium/base/PathUtils.java",
- "android/java/src/org/chromium/base/PiiElider.java",
- "android/java/src/org/chromium/base/PowerMonitor.java",
- "android/java/src/org/chromium/base/PowerMonitorForQ.java",
- "android/java/src/org/chromium/base/Promise.java",
- "android/java/src/org/chromium/base/RadioUtils.java",
- "android/java/src/org/chromium/base/RequiredCallback.java",
- "android/java/src/org/chromium/base/ResettersForTesting.java",
- "android/java/src/org/chromium/base/StreamUtil.java",
- "android/java/src/org/chromium/base/StrictModeContext.java",
- "android/java/src/org/chromium/base/SysUtils.java",
- "android/java/src/org/chromium/base/ThreadUtils.java",
- "android/java/src/org/chromium/base/TimeUtils.java",
- "android/java/src/org/chromium/base/TimezoneUtils.java",
- "android/java/src/org/chromium/base/TraceEvent.java",
- "android/java/src/org/chromium/base/UnguessableToken.java",
- "android/java/src/org/chromium/base/UnownedUserData.java",
- "android/java/src/org/chromium/base/UnownedUserDataHost.java",
- "android/java/src/org/chromium/base/UnownedUserDataKey.java",
- "android/java/src/org/chromium/base/UserData.java",
- "android/java/src/org/chromium/base/UserDataHost.java",
- "android/java/src/org/chromium/base/WrappedClassLoader.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForM.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForN.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForO.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForOMR1.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForP.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForQ.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForR.java",
- "android/java/src/org/chromium/base/compat/ApiHelperForS.java",
- "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
- "android/java/src/org/chromium/base/library_loader/LibraryPrefetcher.java",
- "android/java/src/org/chromium/base/library_loader/Linker.java",
- "android/java/src/org/chromium/base/library_loader/LinkerJni.java",
- "android/java/src/org/chromium/base/library_loader/LoaderErrors.java",
- "android/java/src/org/chromium/base/library_loader/NativeLibraryPreloader.java",
- "android/java/src/org/chromium/base/library_loader/ProcessInitException.java",
- "android/java/src/org/chromium/base/lifetime/DestroyChecker.java",
- "android/java/src/org/chromium/base/lifetime/Destroyable.java",
- "android/java/src/org/chromium/base/memory/JavaHeapDumpGenerator.java",
- "android/java/src/org/chromium/base/memory/MemoryInfoBridge.java",
- "android/java/src/org/chromium/base/memory/MemoryPressureCallback.java",
- "android/java/src/org/chromium/base/memory/MemoryPressureMonitor.java",
- "android/java/src/org/chromium/base/memory/MemoryPressureUma.java",
- "android/java/src/org/chromium/base/memory/MemoryPurgeManager.java",
- "android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java",
- "android/java/src/org/chromium/base/metrics/HistogramBucket.java",
- "android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
- "android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java",
- "android/java/src/org/chromium/base/metrics/RecordHistogram.java",
- "android/java/src/org/chromium/base/metrics/RecordUserAction.java",
- "android/java/src/org/chromium/base/metrics/ScopedSysTraceEvent.java",
- "android/java/src/org/chromium/base/metrics/StatisticsRecorderAndroid.java",
- "android/java/src/org/chromium/base/metrics/TimingMetric.java",
- "android/java/src/org/chromium/base/metrics/UmaRecorder.java",
- "android/java/src/org/chromium/base/metrics/UmaRecorderHolder.java",
- "android/java/src/org/chromium/base/supplier/DestroyableObservableSupplier.java",
- "android/java/src/org/chromium/base/supplier/ObservableSupplier.java",
- "android/java/src/org/chromium/base/supplier/ObservableSupplierImpl.java",
- "android/java/src/org/chromium/base/supplier/OneShotCallback.java",
- "android/java/src/org/chromium/base/supplier/OneshotSupplier.java",
- "android/java/src/org/chromium/base/supplier/OneshotSupplierImpl.java",
- "android/java/src/org/chromium/base/supplier/Supplier.java",
- "android/java/src/org/chromium/base/supplier/UnownedUserDataSupplier.java",
- "android/java/src/org/chromium/base/task/AsyncTask.java",
- "android/java/src/org/chromium/base/task/BackgroundOnlyAsyncTask.java",
- "android/java/src/org/chromium/base/task/ChainedTasks.java",
- "android/java/src/org/chromium/base/task/ChromeThreadPoolExecutor.java",
- "android/java/src/org/chromium/base/task/PostTask.java",
- "android/java/src/org/chromium/base/task/SequencedTaskRunner.java",
- "android/java/src/org/chromium/base/task/SequencedTaskRunnerImpl.java",
- "android/java/src/org/chromium/base/task/SerialExecutor.java",
- "android/java/src/org/chromium/base/task/SingleThreadTaskRunner.java",
- "android/java/src/org/chromium/base/task/SingleThreadTaskRunnerImpl.java",
- "android/java/src/org/chromium/base/task/TaskExecutor.java",
- "android/java/src/org/chromium/base/task/TaskRunner.java",
- "android/java/src/org/chromium/base/task/TaskRunnerImpl.java",
- "android/java/src/org/chromium/base/task/ThreadPoolTaskExecutor.java",
- "android/java/src/org/chromium/base/task/UiThreadTaskExecutor.java",
- ]
-
- if (!is_cronet_build) {
- sources += [ "android/java/src/org/chromium/base/IntentUtils.java" ]
- }
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
-
- resources_package = "org.chromium.base"
-
- proguard_configs = [
- "android/proguard/chromium_apk.flags",
- "android/proguard/chromium_code.flags",
- "android/proguard/remove_logging.flags",
- ]
- }
-
- android_aidl("process_launcher_aidl") {
- import_include = [ "android/java/src" ]
- sources = [
- "android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl",
- "android/java/src/org/chromium/base/process_launcher/IParentProcess.aidl",
- ]
- }
-
- android_library("base_javatests") {
- testonly = true
-
- deps = [
- ":base_java",
- ":base_java_test_support",
- ":base_java_test_support_uncommon",
- "//base:jni_java",
- "//base/test:test_support_java",
- "//build/android:build_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_test_monitor_java",
- "//third_party/androidx:androidx_test_runner_java",
- "//third_party/hamcrest:hamcrest_java",
- "//third_party/junit:junit",
- "//third_party/mockito:mockito_java",
- ]
-
- sources = [
- # AssertsTest doesn't really belong in //base but it's preferable to
- # stick it here than create another target for a single test.
- "android/javatests/src/org/chromium/base/AdvancedMockContextTest.java",
- "android/javatests/src/org/chromium/base/AssertsTest.java",
- "android/javatests/src/org/chromium/base/CommandLineFlagsTest.java",
- "android/javatests/src/org/chromium/base/CommandLineInitUtilTest.java",
- "android/javatests/src/org/chromium/base/CommandLineTest.java",
- "android/javatests/src/org/chromium/base/EarlyTraceEventTest.java",
- "android/javatests/src/org/chromium/base/IntentUtilsTest.java",
- "android/javatests/src/org/chromium/base/LocaleUtilsTest.java",
- "android/javatests/src/org/chromium/base/ObserverListTest.java",
- "android/javatests/src/org/chromium/base/PackageUtilsTest.java",
- "android/javatests/src/org/chromium/base/StrictModeContextTest.java",
- "android/javatests/src/org/chromium/base/UserDataHostTest.java",
- "android/javatests/src/org/chromium/base/library_loader/EarlyNativeTest.java",
- "android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java",
- "android/javatests/src/org/chromium/base/task/AsyncTaskTest.java",
- "android/javatests/src/org/chromium/base/task/PostTaskTest.java",
- "android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java",
- "android/javatests/src/org/chromium/base/task/SingleThreadTaskRunnerImplTest.java",
- "android/javatests/src/org/chromium/base/task/TaskRunnerImplTest.java",
- "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherTestBase.java",
- "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherTransitionToNativeTest.java",
- "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherWithNativeTest.java",
- "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherWithoutNativeTest.java",
- "android/javatests/src/org/chromium/base/util/GarbageCollectionTestUtilsTest.java",
- ]
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- }
-
- source_set("base_javatests_lib") {
- testonly = true
- deps = [
- ":base",
- ":base_javatests_jni_headers",
- ]
- sources = [ "test/library_loader/early_native_test_helper.cc" ]
- }
-
- generate_jni("base_javatests_jni_headers") {
- testonly = true
- sources = [ "android/javatests/src/org/chromium/base/library_loader/EarlyNativeTest.java" ]
- }
-
- android_library("base_java_url_utils_for_test") {
- testonly = true
- sources = [
- "test/android/javatests/src/org/chromium/base/test/util/UrlUtils.java",
- ]
-
- deps = [
- ":base_java",
- "//base:jni_java",
- "//build/android:build_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/junit:junit",
- ]
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- }
-
- android_library("base_java_test_support") {
- testonly = true
-
- deps = [
- ":base_java",
- "//base:jni_java",
- "//build/android:build_java",
- "//third_party/accessibility_test_framework:accessibility_test_framework_java",
- "//third_party/android_deps:espresso_java",
- "//third_party/android_deps:guava_android_java",
- "//third_party/android_sdk:android_test_base_java",
- "//third_party/android_sdk:android_test_mock_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_core_core_java",
- "//third_party/androidx:androidx_multidex_multidex_java",
- "//third_party/androidx:androidx_test_monitor_java",
- "//third_party/androidx:androidx_test_runner_java",
- "//third_party/androidx:androidx_test_uiautomator_uiautomator_java",
- "//third_party/hamcrest:hamcrest_java",
- "//third_party/junit",
- ]
-
- public_deps = [ ":base_java_url_utils_for_test" ]
-
- sources = [
- "test/android/java/src/org/chromium/base/multidex/ChromiumMultiDexInstaller.java",
- "test/android/javatests/src/org/chromium/base/test/BaseActivityTestRule.java",
- "test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java",
- "test/android/javatests/src/org/chromium/base/test/BaseChromiumRunnerCommon.java",
- "test/android/javatests/src/org/chromium/base/test/BaseJUnit4ClassRunner.java",
- "test/android/javatests/src/org/chromium/base/test/BaseJUnit4TestRule.java",
- "test/android/javatests/src/org/chromium/base/test/LoadNative.java",
- "test/android/javatests/src/org/chromium/base/test/MockitoErrorHandler.java",
- "test/android/javatests/src/org/chromium/base/test/ResetCachedFlagValuesTestHook.java",
- "test/android/javatests/src/org/chromium/base/test/ResettersForTestingTestRule.java",
- "test/android/javatests/src/org/chromium/base/test/ScreenshotOnFailureStatement.java",
- "test/android/javatests/src/org/chromium/base/test/TestListInstrumentationRunListener.java",
- "test/android/javatests/src/org/chromium/base/test/TestTraceEvent.java",
- "test/android/javatests/src/org/chromium/base/test/UiThreadStatement.java",
- "test/android/javatests/src/org/chromium/base/test/UiThreadTest.java",
- "test/android/javatests/src/org/chromium/base/test/UnitTestLifetimeAssertRule.java",
- "test/android/javatests/src/org/chromium/base/test/UnitTestNoBrowserProcessHook.java",
- "test/android/javatests/src/org/chromium/base/test/params/BaseJUnit4RunnerDelegate.java",
- "test/android/javatests/src/org/chromium/base/test/params/BlockJUnit4RunnerDelegate.java",
- "test/android/javatests/src/org/chromium/base/test/params/MethodParamAnnotationRule.java",
- "test/android/javatests/src/org/chromium/base/test/params/MethodParamRule.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterAnnotations.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterProvider.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterSet.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedCommandLineFlags.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedFrameworkMethod.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunner.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegate.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegateCommon.java",
- "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegateFactory.java",
- "test/android/javatests/src/org/chromium/base/test/params/SkipCommandLineParameterization.java",
- "test/android/javatests/src/org/chromium/base/test/util/AdvancedMockContext.java",
- "test/android/javatests/src/org/chromium/base/test/util/AndroidSdkLevelSkipCheck.java",
- "test/android/javatests/src/org/chromium/base/test/util/AnnotationProcessingUtils.java",
- "test/android/javatests/src/org/chromium/base/test/util/AnnotationRule.java",
- "test/android/javatests/src/org/chromium/base/test/util/ApplicationContextWrapper.java",
- "test/android/javatests/src/org/chromium/base/test/util/ApplicationTestUtils.java",
- "test/android/javatests/src/org/chromium/base/test/util/Batch.java",
- "test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java",
- "test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java",
- "test/android/javatests/src/org/chromium/base/test/util/Criteria.java",
- "test/android/javatests/src/org/chromium/base/test/util/CriteriaHelper.java",
- "test/android/javatests/src/org/chromium/base/test/util/CriteriaNotSatisfiedException.java",
- "test/android/javatests/src/org/chromium/base/test/util/DisableIf.java",
- "test/android/javatests/src/org/chromium/base/test/util/DisableIfSkipCheck.java",
- "test/android/javatests/src/org/chromium/base/test/util/DisabledTest.java",
- "test/android/javatests/src/org/chromium/base/test/util/DoNotBatch.java",
- "test/android/javatests/src/org/chromium/base/test/util/DoNotRevive.java",
- "test/android/javatests/src/org/chromium/base/test/util/EnormousTest.java",
- "test/android/javatests/src/org/chromium/base/test/util/Feature.java",
- "test/android/javatests/src/org/chromium/base/test/util/Features.java",
- "test/android/javatests/src/org/chromium/base/test/util/FeaturesBase.java",
- "test/android/javatests/src/org/chromium/base/test/util/HistogramWatcher.java",
- "test/android/javatests/src/org/chromium/base/test/util/InMemorySharedPreferences.java",
- "test/android/javatests/src/org/chromium/base/test/util/InMemorySharedPreferencesContext.java",
- "test/android/javatests/src/org/chromium/base/test/util/IntegrationTest.java",
- "test/android/javatests/src/org/chromium/base/test/util/JniMocker.java",
- "test/android/javatests/src/org/chromium/base/test/util/LooperUtils.java",
- "test/android/javatests/src/org/chromium/base/test/util/Manual.java",
- "test/android/javatests/src/org/chromium/base/test/util/MaxAndroidSdkLevel.java",
- "test/android/javatests/src/org/chromium/base/test/util/MinAndroidSdkLevel.java",
- "test/android/javatests/src/org/chromium/base/test/util/PackageManagerWrapper.java",
- "test/android/javatests/src/org/chromium/base/test/util/PayloadCallbackHelper.java",
- "test/android/javatests/src/org/chromium/base/test/util/RequiresRestart.java",
- "test/android/javatests/src/org/chromium/base/test/util/Restriction.java",
- "test/android/javatests/src/org/chromium/base/test/util/RestrictionSkipCheck.java",
- "test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java",
- "test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java",
- "test/android/javatests/src/org/chromium/base/test/util/TestFileUtil.java",
- "test/android/javatests/src/org/chromium/base/test/util/TestThreadUtils.java",
- "test/android/javatests/src/org/chromium/base/test/util/TimeoutScale.java",
- "test/android/javatests/src/org/chromium/base/test/util/TimeoutTimer.java",
- "test/android/javatests/src/org/chromium/base/test/util/UserActionTester.java",
- ]
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- }
-
- android_library("base_java_test_support_uncommon") {
- testonly = true
-
- deps = [
- "//base:base_java",
- "//base:jni_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_test_monitor_java",
- "//third_party/hamcrest:hamcrest_java",
- "//third_party/junit:junit",
- ]
-
- sources = [
- "test/android/javatests/src/org/chromium/base/FakeTimeTestRule.java",
- "test/android/javatests/src/org/chromium/base/test/BundleTestRule.java",
- "test/android/javatests/src/org/chromium/base/test/ReachedCodeProfiler.java",
- "test/android/javatests/src/org/chromium/base/test/SetUpStatement.java",
- "test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java",
- "test/android/javatests/src/org/chromium/base/test/task/SchedulerTestHelpers.java",
- "test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java",
- "test/android/javatests/src/org/chromium/base/test/util/CloseableOnMainThread.java",
- "test/android/javatests/src/org/chromium/base/test/util/InstrumentationUtils.java",
- "test/android/javatests/src/org/chromium/base/test/util/Matchers.java",
- ]
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- }
-
- android_library("base_java_process_launcher_test_support") {
- testonly = true
-
- public_deps = [ ":process_launcher_java" ]
-
- sources = [ "test/android/javatests/src/org/chromium/base/process_launcher/TestChildProcessConnection.java" ]
- }
-
- robolectric_library("base_junit_test_support") {
- sources = [
- "//third_party/robolectric/custom_asynctask/java/src/org/chromium/base/task/test/ShadowAsyncTask.java",
- "//third_party/robolectric/custom_asynctask/java/src/org/chromium/base/task/test/ShadowAsyncTaskBridge.java",
- "test/android/junit/src/org/chromium/base/task/test/BackgroundShadowAsyncTask.java",
- "test/android/junit/src/org/chromium/base/task/test/CustomShadowAsyncTask.java",
- "test/android/junit/src/org/chromium/base/task/test/PausedExecutorTestRule.java",
- "test/android/junit/src/org/chromium/base/task/test/ShadowPostTask.java",
- "test/android/junit/src/org/chromium/base/test/BaseRobolectricTestRunner.java",
- "test/android/junit/src/org/chromium/base/test/ShadowBuildInfo.java",
- "test/android/junit/src/org/chromium/base/test/util/TestRunnerTestRule.java",
- ]
-
- # Make sure robolectric tests have classes filtered out of base_java by
- # jar_excluded_patterns.
- srcjar_deps = [ "//build/android:native_libraries_gen" ]
-
- deps = [
- ":base_java",
- ":base_java_test_support",
- "//testing/android/junit:junit_test_support",
- "//third_party/androidx:androidx_test_core_java",
- "//third_party/androidx:androidx_test_monitor_java",
- "//third_party/hamcrest:hamcrest_java",
- "//third_party/junit:junit",
- ]
- }
-
- robolectric_binary("base_junit_tests") {
- sources = [
- "android/junit/src/org/chromium/base/ApplicationStatusTest.java",
- "android/junit/src/org/chromium/base/BuildInfoTest.java",
- "android/junit/src/org/chromium/base/CallbackControllerTest.java",
- "android/junit/src/org/chromium/base/CollectionUtilTest.java",
- "android/junit/src/org/chromium/base/DiscardableReferencePoolTest.java",
- "android/junit/src/org/chromium/base/FileUtilsTest.java",
- "android/junit/src/org/chromium/base/LifetimeAssertTest.java",
- "android/junit/src/org/chromium/base/LogTest.java",
- "android/junit/src/org/chromium/base/MathUtilsTest.java",
- "android/junit/src/org/chromium/base/PathUtilsTest.java",
- "android/junit/src/org/chromium/base/PiiEliderTest.java",
- "android/junit/src/org/chromium/base/PromiseTest.java",
- "android/junit/src/org/chromium/base/ResettersForTestingTest.java",
- "android/junit/src/org/chromium/base/TimeUtilsTest.java",
- "android/junit/src/org/chromium/base/TraceEventTest.java",
- "android/junit/src/org/chromium/base/UnownedUserDataHostTest.java",
- "android/junit/src/org/chromium/base/UnownedUserDataKeyTest.java",
- "android/junit/src/org/chromium/base/library_loader/LinkerTest.java",
- "android/junit/src/org/chromium/base/memory/MemoryPressureMonitorTest.java",
- "android/junit/src/org/chromium/base/memory/MemoryPurgeManagerTest.java",
- "android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java",
- "android/junit/src/org/chromium/base/process_launcher/ChildConnectionAllocatorTest.java",
- "android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java",
- "android/junit/src/org/chromium/base/supplier/ObservableSupplierImplTest.java",
- "android/junit/src/org/chromium/base/supplier/OneShotCallbackTest.java",
- "android/junit/src/org/chromium/base/supplier/OneshotSupplierImplTest.java",
- "android/junit/src/org/chromium/base/supplier/UnownedUserDataSupplierTest.java",
- "android/junit/src/org/chromium/base/task/AsyncTaskThreadTest.java",
- "android/junit/src/org/chromium/base/task/SequencedTaskRunnerTaskMigrationTest.java",
- "android/junit/src/org/chromium/base/util/GarbageCollectionTestUtilsUnitTest.java",
- "test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java",
- "test/android/junit/src/org/chromium/base/test/TestListInstrumentationRunListenerTest.java",
- "test/android/junit/src/org/chromium/base/test/params/ExampleParameterizedTest.java",
- "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerDelegateCommonTest.java",
- "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerDelegateFactoryTest.java",
- "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerTest.java",
- "test/android/junit/src/org/chromium/base/test/params/ParameterizedTestNameTest.java",
- "test/android/junit/src/org/chromium/base/test/util/AndroidSdkLevelSkipCheckTest.java",
- "test/android/junit/src/org/chromium/base/test/util/AnnotationProcessingUtilsTest.java",
- "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java",
- "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java",
- "test/android/junit/src/org/chromium/base/test/util/DisableIfTest.java",
- "test/android/junit/src/org/chromium/base/test/util/DisabledTestForClassRobolectricTest.java",
- "test/android/junit/src/org/chromium/base/test/util/DisabledTestRobolectricTest.java",
- "test/android/junit/src/org/chromium/base/test/util/RestrictionSkipCheckTest.java",
- "test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java",
- ]
- deps = [
- ":base_java",
- ":base_java_process_launcher_test_support",
- ":base_java_test_support",
- ":base_java_test_support_uncommon",
- ":base_junit_test_support",
- "//base/test:test_support_java",
- "//third_party/androidx:androidx_annotation_annotation_java",
- "//third_party/androidx:androidx_test_core_java",
- "//third_party/androidx:androidx_test_runner_java",
- "//third_party/hamcrest:hamcrest_java",
- ]
- }
-
- java_cpp_enum("base_android_java_enums_srcjar") {
- sources = [
- "android/application_status_listener.h",
- "android/child_process_binding_types.h",
- "android/library_loader/library_loader_hooks.h",
- "android/linker/linker_jni.h",
- "android/task_scheduler/task_runner_android.h",
- "android/task_scheduler/task_traits_android.h",
- "memory/memory_pressure_listener.h",
- "metrics/histogram_base.h",
- "task/task_traits.h",
- ]
- if (enable_base_tracing) {
- sources += [ "trace_event/trace_config.h" ]
- }
- }
-
- generate_jni("base_profiler_test_support_jni_headers") {
- testonly = true
- sources =
- [ "android/javatests/src/org/chromium/base/profiler/TestSupport.java" ]
- }
-
- android_library("base_profiler_test_support_java") {
- testonly = true
- sources =
- [ "android/javatests/src/org/chromium/base/profiler/TestSupport.java" ]
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
-
- deps = [
- "//base:jni_java",
- "//build/android:build_java",
- ]
- }
-
- android_library("base_java_unittest_support") {
- testonly = true
-
- deps = [
- ":base_java",
- "//base:jni_java",
- ]
-
- sources = [
- "test/android/java/src/org/chromium/base/ContentUriTestUtils.java",
- "test/android/java/src/org/chromium/base/JavaHandlerThreadHelpers.java",
- ]
- }
-} # is_android
-
-# Keep the list of fuzzer_tests in alphabetical order.
-fuzzer_test("base64_decode_fuzzer") {
- sources = [ "base64_decode_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("base64_encode_fuzzer") {
- sources = [ "base64_encode_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("base64url_fuzzer") {
- sources = [ "base64url_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("base_json_correctness_fuzzer") {
- sources = [ "json/json_correctness_fuzzer.cc" ]
- deps = [ ":base" ]
- dict = "//testing/libfuzzer/fuzzers/dicts/json.dict"
-}
-
-fuzzer_test("base_json_reader_fuzzer") {
- sources = [ "json/json_reader_fuzzer.cc" ]
- deps = [ "//base" ]
- dict = "//testing/libfuzzer/fuzzers/dicts/json.dict"
-}
-
-fuzzer_test("base_json_string_escape_fuzzer") {
- sources = [ "json/string_escape_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-if (is_mac && !is_starboard) {
- protoc_convert("base_mach_port_rendezvous_convert_corpus") {
- sources = [
- "test/data/mach_port_rendezvous_fuzz/dead_name.textproto",
- "test/data/mach_port_rendezvous_fuzz/send.textproto",
- ]
- inputs = [ "//testing/libfuzzer/fuzzers/mach/mach_message.proto" ]
- output_pattern = "$target_gen_dir/base_mach_port_rendezvous_corpus/{{source_name_part}}.binarypb"
- args = [
- "--encode=mach_fuzzer.MachMessage",
- "-I",
- rebase_path("//"),
- rebase_path(inputs[0]),
- ]
- }
- fuzzer_test("base_mach_port_rendezvous_fuzzer") {
- sources = [ "mac/mach_port_rendezvous_fuzzer.cc" ]
- deps = [
- "//base",
- "//testing/libfuzzer/fuzzers/mach:converter",
- "//third_party/libprotobuf-mutator",
- ]
- seed_corpus = "$target_gen_dir/base_mach_port_rendezvous_corpus"
- seed_corpus_deps = [ ":base_mach_port_rendezvous_convert_corpus" ]
- }
-}
-
-fuzzer_test("command_line_fuzzer") {
- sources = [ "command_line_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("escape_fuzzer") {
- sources = [ "strings/escape_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("file_path_fuzzer") {
- sources = [ "files/file_path_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("string_number_conversions_fuzzer") {
- sources = [ "strings/string_number_conversions_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("string_pattern_fuzzer") {
- sources = [ "strings/pattern_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("string_tokenizer_fuzzer") {
- sources = [ "strings/string_tokenizer_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("substring_set_matcher_fuzzer") {
- sources = [ "substring_set_matcher/substring_set_matcher_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("sys_string_conversions_fuzzer") {
- sources = [ "strings/sys_string_conversions_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("time_delta_from_string_fuzzer") {
- sources = [ "time/time_delta_from_string_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("time_fuzzer") {
- sources = [ "time/time_fuzzer.cc" ]
- deps = [
- "//base",
- "//base/test:test_support",
- ]
-}
-
-fuzzer_test("utf_string_conversions_fuzzer") {
- sources = [ "strings/utf_string_conversions_fuzzer.cc" ]
- deps = [ "//base" ]
-}
-
-fuzzer_test("pickle_fuzzer") {
- sources = [ "pickle_fuzzer.cc" ]
- deps = [
- "//base",
- "//base/test:test_support",
- ]
-}
-
-# TODO(1151236): Temporarily move test_support from
-# //base/allocator/partition_allocator/BUILD.gn to //base/BUILD.gn. After
-# fixing partition_allocator tests issue, we will move test_support to
-# //base/allocator/partition_allocator/BUILD.gn again.
-source_set("partition_alloc_test_support") {
- testonly = true
-
- sources = [
- "allocator/partition_allocator/extended_api.cc",
- "allocator/partition_allocator/extended_api.h",
- "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_for_testing.h",
- "allocator/partition_allocator/partition_alloc_for_testing.h",
- ]
- if (is_posix) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_posix_for_testing.cc" ]
- }
- if (is_fuchsia) {
- sources += [
- "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_fuchsia_for_testing.cc",
- "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_posix_for_testing.cc",
- ]
- }
- if (is_win) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_win_for_testing.cc" ]
- }
- if (is_mac || is_ios) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_mac_for_testing.mm" ]
- }
- if (is_linux || is_chromeos) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_linux_for_testing.cc" ]
- }
- if (is_android) {
- sources += [ "allocator/partition_allocator/partition_alloc_base/threading/platform_thread_android_for_testing.cc" ]
- }
- public_deps = [
- "allocator/partition_allocator:buildflags",
- "//build:branding_buildflags",
- "//build/config/compiler:compiler_buildflags",
- ]
- public_configs = []
- if (is_fuchsia) {
- public_deps += [
- "//third_party/fuchsia-sdk/sdk/pkg/fit",
- "//third_party/fuchsia-sdk/sdk/pkg/sync",
- "//third_party/fuchsia-sdk/sdk/pkg/zx",
- ]
-
- # Needed for users of spinning_mutex.h, which for performance reasons,
- # contains inlined calls to `libsync` inside the header file.
- # It appends an entry to the "libs" section of the dependent target.
- public_configs += [ ":fuchsia_sync_lib" ]
- }
- deps = [ ":base" ]
-
- if (!is_debug) {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_speed" ]
- }
-
- if (is_starboard) {
- sources = []
- }
-}
diff --git a/base/DEPS b/base/DEPS
deleted file mode 100644
index 679f6cc..0000000
--- a/base/DEPS
+++ /dev/null
@@ -1,41 +0,0 @@
-include_rules = [
- "+third_party/ashmem",
- "+third_party/apple_apsl",
- "+third_party/boringssl/src/include",
- "+third_party/ced",
- "+third_party/libevent",
- "+third_party/libunwindstack/src/libunwindstack/include",
- "+third_party/lss",
- "+third_party/modp_b64",
- "+third_party/perfetto/include",
- "+third_party/perfetto/protos/perfetto",
- # Conversions between base and Rust types (e.g. base::span <-> rust::Slice)
- # require the cxx.h header from cxx. This is only used if Rust is enabled
- # in the gn build; see //base/BUILD.gn's conditional dependency on
- # //build/rust:cxx_cppdeps.
- "+third_party/rust/cxx",
- "+third_party/test_fonts",
- # JSON Deserialization.
- "+third_party/rust/serde_json_lenient/v0_1/wrapper",
-
- # These are implicitly brought in from the root, and we don't want them.
- "-ipc",
- "-url",
-
- # ICU dependendencies must be separate from the rest of base.
- "-i18n",
-
- # //base/util can use //base but not vice versa.
- "-util",
-]
-
-specific_include_rules = {
- # Special case
- "process/current_process(|_test)\.h": [
- "+third_party/perfetto/protos/perfetto/trace/track_event/chrome_process_descriptor.pbzero.h",
- ],
- # To evaluate the performance effects of using absl's flat_hash_map.
- "supports_user_data\.h": [
- "+third_party/abseil-cpp/absl/container/flat_hash_map.h",
- ]
-}
diff --git a/base/DIR_METADATA b/base/DIR_METADATA
deleted file mode 100644
index 2aaf8e2..0000000
--- a/base/DIR_METADATA
+++ /dev/null
@@ -1,3 +0,0 @@
-monorail {
- component: "Internals>Core"
-}
diff --git a/base/METADATA b/base/METADATA
deleted file mode 100644
index 3d9342e..0000000
--- a/base/METADATA
+++ /dev/null
@@ -1,24 +0,0 @@
-name: "base"
-description:
- "Subtree at base."
-
-third_party {
- identifier {
- type: "ChromiumVersion"
- value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html
- }
- identifier {
- type: "Git"
- value: "https://chromium.googlesource.com/chromium/src.git"
- version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02"
- }
- identifier {
- type: "UpstreamSubdir"
- value: "base"
- }
- last_upgrade_date {
- year: 2023
- month: 9
- day: 12
- }
-}
diff --git a/base/OWNERS b/base/OWNERS
deleted file mode 100644
index a1b94bc..0000000
--- a/base/OWNERS
+++ /dev/null
@@ -1,51 +0,0 @@
-# See //base/README.md to find qualification for being an owner.
-
-set noparent
-# NOTE: keep this in sync with lsc-owners-override@chromium.org owners
-# by emailing lsc-policy@chromium.org when this list changes.
-altimin@chromium.org
-danakj@chromium.org
-dcheng@chromium.org
-fdoray@chromium.org
-gab@chromium.org
-kylechar@chromium.org
-mark@chromium.org
-thakis@chromium.org
-thestig@chromium.org
-wez@chromium.org
-# NOTE: keep this in sync with lsc-owners-override@chromium.org owners
-# by emailing lsc-policy@chromium.org when this list changes.
-
-# per-file rules:
-# These are for the common case of adding or renaming files. If you're doing
-# structural changes, please get a review from a reviewer in this file.
-per-file BUILD.gn=*
-
-# For Android-specific changes:
-per-file ..._android*=file://base/android/OWNERS
-
-# For Fuchsia-specific changes:
-per-file ..._fuchsia*=file://build/fuchsia/OWNERS
-
-# For Windows-specific changes:
-per-file ..._win*=file://base/win/OWNERS
-
-per-file callback_list*=pkasting@chromium.org
-per-file feature_list*=asvitkine@chromium.org
-per-file feature_list*=isherman@chromium.org
-
-# Logging-related changes:
-per-file check*=olivierli@chromium.org
-per-file check*=pbos@chromium.org
-per-file dcheck*=olivierli@chromium.org
-per-file dcheck*=pbos@chromium.org
-per-file logging*=olivierli@chromium.org
-per-file logging*=pbos@chromium.org
-per-file notreached.h=olivierli@chromium.org
-per-file notreached.h=pbos@chromium.org
-
-# Restricted since rand_util.h also backs the cryptographically secure RNG.
-per-file rand_util*=set noparent
-per-file rand_util*=file://ipc/SECURITY_OWNERS
-
-per-file safe_numerics_unittest.cc=file://base/numerics/OWNERS
diff --git a/base/PRESUBMIT.py b/base/PRESUBMIT.py
deleted file mode 100644
index 13c1706..0000000
--- a/base/PRESUBMIT.py
+++ /dev/null
@@ -1,163 +0,0 @@
-# Copyright 2012 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Chromium presubmit script for src/base.
-
-See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
-for more details on the presubmit API built into depot_tools.
-"""
-
-
-USE_PYTHON3 = True
-
-
-def CheckChangeLintsClean(input_api, output_api):
- """Makes sure that the code is cpplint clean."""
- # lint_filters=[] stops the OFF_BY_DEFAULT_LINT_FILTERS from being disabled,
- # finding many more issues. verbose_level=1 finds a small number of additional
- # issues.
- # The only valid extensions for cpplint are .cc, .h, .cpp, .cu, and .ch.
- # Only process those extensions which are used in Chromium, in directories
- # that currently lint clean.
- CLEAN_CPP_FILES_ONLY = (r'base/win/.*\.(cc|h)$', )
- source_file_filter = lambda x: input_api.FilterSourceFile(
- x,
- files_to_check=CLEAN_CPP_FILES_ONLY,
- files_to_skip=input_api.DEFAULT_FILES_TO_SKIP)
- return input_api.canned_checks.CheckChangeLintsClean(
- input_api, output_api, source_file_filter=source_file_filter,
- lint_filters=[], verbose_level=1)
-
-
-def _CheckNoInterfacesInBase(input_api, output_api):
- """Checks to make sure no files in libbase.a have |@interface|."""
- pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
- files = []
- for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
- if (f.LocalPath().startswith('base/') and
- not "/ios/" in f.LocalPath() and
- not "/test/" in f.LocalPath() and
- not f.LocalPath().endswith('.java') and
- not f.LocalPath().endswith('_unittest.mm') and
- not f.LocalPath().endswith('mac/sdk_forward_declarations.h')):
- contents = input_api.ReadFile(f)
- if pattern.search(contents):
- files.append(f)
-
- if len(files):
- return [ output_api.PresubmitError(
- 'Objective-C interfaces or categories are forbidden in libbase. ' +
- 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
- 'browse_thread/thread/efb28c10435987fd',
- files) ]
- return []
-
-
-def _FindLocations(input_api, search_regexes, files_to_check, files_to_skip):
- """Returns locations matching one of the search_regexes."""
- def FilterFile(affected_file):
- return input_api.FilterSourceFile(
- affected_file,
- files_to_check=files_to_check,
- files_to_skip=files_to_skip)
-
- no_presubmit = r"// no-presubmit-check"
- locations = []
- for f in input_api.AffectedSourceFiles(FilterFile):
- for line_num, line in f.ChangedContents():
- for search_regex in search_regexes:
- if (input_api.re.search(search_regex, line) and
- not input_api.re.search(no_presubmit, line)):
- locations.append(" %s:%d" % (f.LocalPath(), line_num))
- break
- return locations
-
-
-def _CheckNoTraceEventInclude(input_api, output_api):
- """Verify that //base includes base_tracing.h instead of trace event headers.
-
- Checks that files outside trace event implementation include the
- base_tracing.h header instead of specific trace event implementation headers
- to maintain compatibility with the gn flag "enable_base_tracing = false".
- """
- discouraged_includes = [
- r'^#include "base/trace_event/(?!base_tracing\.h|base_tracing_forward\.h)',
- r'^#include "third_party/perfetto/include/',
- ]
-
- files_to_check = [
- r".*\.(h|cc|mm)$",
- ]
- files_to_skip = [
- r".*/test/.*",
- r".*/trace_event/.*",
- r".*/tracing/.*",
- ]
-
- locations = _FindLocations(input_api, discouraged_includes, files_to_check,
- files_to_skip)
- if locations:
- return [ output_api.PresubmitError(
- 'Base code should include "base/trace_event/base_tracing.h" instead\n' +
- 'of trace_event implementation headers. If you need to include an\n' +
- 'implementation header, verify that "gn check" and base_unittests\n' +
- 'still pass with gn arg "enable_base_tracing = false" and add\n' +
- '"// no-presubmit-check" after the include. \n' +
- '\n'.join(locations)) ]
- return []
-
-
-def _WarnPbzeroIncludes(input_api, output_api):
- """Warn to check enable_base_tracing=false when including a pbzero header.
-
- Emits a warning when including a perfetto pbzero header, encouraging the
- user to verify that //base still builds with enable_base_tracing=false.
- """
- warn_includes = [
- r'^#include "third_party/perfetto/protos/',
- r'^#include "base/tracing/protos/',
- ]
-
- files_to_check = [
- r".*\.(h|cc|mm)$",
- ]
- files_to_skip = [
- r".*/test/.*",
- r".*/trace_event/.*",
- r".*/tracing/.*",
- ]
-
- locations = _FindLocations(input_api, warn_includes, files_to_check,
- files_to_skip)
- if locations:
- return [ output_api.PresubmitPromptWarning(
- 'Please verify that "gn check" and base_unittests still pass with\n' +
- 'gn arg "enable_base_tracing = false" when adding typed trace\n' +
- 'events to //base. You can use "#if BUILDFLAG(ENABLE_BASE_TRACING)"\n' +
- 'to exclude pbzero headers and anything not supported by\n' +
- '//base/trace_event/trace_event_stub.h.\n' +
- '\n'.join(locations)) ]
- return []
-
-
-def _CommonChecks(input_api, output_api):
- """Checks common to both upload and commit."""
- results = []
- results.extend(_CheckNoInterfacesInBase(input_api, output_api))
- results.extend(_CheckNoTraceEventInclude(input_api, output_api))
- results.extend(_WarnPbzeroIncludes(input_api, output_api))
- results.extend(CheckChangeLintsClean(input_api, output_api))
- return results
-
-
-def CheckChangeOnUpload(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
-
-
-def CheckChangeOnCommit(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
diff --git a/base/README.md b/base/README.md
deleted file mode 100644
index ef5a259..0000000
--- a/base/README.md
+++ /dev/null
@@ -1,87 +0,0 @@
-# What is this
-Contains a written down set of principles and other information on //base.
-Please add to it!
-
-## About //base:
-
-Chromium is a very mature project. Most things that are generally useful are
-already here and things not here aren't generally useful.
-
-The bar for adding stuff to base is that it must have demonstrated wide
-applicability. Prefer to add things closer to where they're used (i.e. "not
-base"), and pull into base only when needed. In a project our size,
-sometimes even duplication is OK and inevitable.
-
-Adding a new logging macro `DPVELOG_NE` is not more clear than just
-writing the stuff you want to log in a regular logging statement, even
-if it makes your calling code longer. Just add it to your own code.
-
-If the code in question does not need to be used inside base, but will have
-multiple consumers across the codebase, consider placing it in a new directory
-under components/ instead.
-
-base is written for the Chromium project and is not intended to be used
-outside it. Using base outside of src.git is explicitly not supported,
-and base makes no guarantees about API (or even ABI) stability (like all
-other code in Chromium). New code that depends on base/ must be in
-src.git. Code that's not in src.git but pulled in through DEPS (for
-example, v8) cannot use base.
-
-## Qualifications for being in //base OWNERS
- * interest and ability to learn low level/high detail/complex c++ stuff
- * inclination to always ask why and understand everything (including external
- interactions like win32) rather than just hoping the author did it right
- * mentorship/experience
- * demonstrated good judgement (esp with regards to public APIs) over a length
- of time
-
-Owners are added when a contributor has shown the above qualifications and
-when they express interest. There isn't an upper bound on the number of OWNERS.
-
-## Design and naming
- * Be sure to use the base namespace.
- * STL-like constructs should adhere as closely to STL as possible. Functions
- and behaviors not present in STL should only be added when they are related
- to the specific data structure implemented by the container.
- * For STL-like constructs our policy is that they should use STL-like naming
- even when it may conflict with the style guide. So functions and class names
- should be lower case with underscores. Non-STL-like classes and functions
- should use Google naming.
-
-## Performance testing
-
-Since the primitives provided by //base are used very widely, it is important to
-ensure they scale to the necessary workloads and perform well under all
-supported platforms. The `base_perftests` target is a suite of
-synthetic microbenchmarks that measure performance in various scenarios:
-
- * BasicPostTaskPerfTest: Exercises MessageLoopTaskRunner's multi-threaded
- queue in isolation.
- * ConditionVariablePerfTest: Measures thread switching cost of condition
- variables.
- * IntegratedPostTaskPerfTest: Exercises the full MessageLoop/RunLoop
- machinery.
- * JSONPerfTest: Tests JSONWriter and JSONReader performance.
- * MessageLoopPerfTest: Measures the speed of task posting in various
- configurations.
- * ObserverListPerfTest: Exercises adding, removing and signalling observers.
- * PartitionLockPerfTest: Tests the implementation of Lock used in
- PartitionAlloc
- * PthreadEventPerfTest: Establishes the baseline thread switching cost using
- pthreads.
- * RandUtilPerfTest: Measures the time it takes to generate random numbers.
- * ScheduleWorkTest: Measures the overhead of MessagePump::ScheduleWork.
- * SequenceManagerPerfTest: Benchmarks SequenceManager scheduling with various
- underlying task runners.
- * TaskObserverPerfTest: Measures the incremental cost of adding task
- observers.
- * TaskPerfTest: Checks the cost of posting tasks between threads.
- * ThreadLocalStoragePerfTest: Exercises different mechanisms for accessing
- data associated with the current thread (C++ `thread_local`, the
- implementation in //base, the POSIX/WinAPI directly)
- * WaitableEvent{Thread,}PerfTest: Measures waitable events in single and
- multithreaded scenarios.
-
-Regressions in these benchmarks can generally by caused by 1) operating system
-changes, 2) compiler version or flag changes or 3) changes in //base code
-itself.
diff --git a/base/SECURITY_OWNERS b/base/SECURITY_OWNERS
deleted file mode 100644
index 0747cfd..0000000
--- a/base/SECURITY_OWNERS
+++ /dev/null
@@ -1,13 +0,0 @@
-# Changes to code that runs at high privilege and which has a high risk of
-# memory corruption, such as parsers for complex inputs, require a security
-# review to avoid introducing sandbox escapes.
-#
-# Although this file is in base/, it may apply to more than just base, OWNERS
-# files outside of base may also include this file.
-#
-# Security team: If you are uncomfortable reviewing a particular bit of code
-# yourself, don't hesitate to seek help from another security team member!
-# Nobody knows everything, and the only way to learn is from experience.
-dcheng@chromium.org
-rsesek@chromium.org
-tsepez@chromium.org
diff --git a/base/allocator/BUILD.gn b/base/allocator/BUILD.gn
deleted file mode 100644
index d0ab023..0000000
--- a/base/allocator/BUILD.gn
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2013 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//base/allocator/allocator.gni")
-import("//base/allocator/partition_allocator/partition_alloc.gni")
-import("//build/buildflag_header.gni")
-import("//build/config/compiler/compiler.gni")
-import("//build/config/dcheck_always_on.gni")
-
-buildflag_header("buildflags") {
- header = "buildflags.h"
-
- assert(use_allocator_shim || !use_partition_alloc_as_malloc,
- "PartitionAlloc-Everywhere requires the allocator shim")
-
- flags = [
- "USE_ALLOCATOR_SHIM=$use_allocator_shim",
-
- "USE_PARTITION_ALLOC_AS_GWP_ASAN_STORE=$enable_backup_ref_ptr_support",
-
- "USE_ALLOCATION_EVENT_DISPATCHER=$use_allocation_event_dispatcher",
- ]
-}
-
-if (is_apple) {
- source_set("early_zone_registration_mac") {
- sources = [
- "early_zone_registration_mac.cc",
- "early_zone_registration_mac.h",
- ]
-
- deps = [
- ":buildflags",
- "//base/allocator/partition_allocator:buildflags",
- ]
- }
-}
-
-# Used to shim malloc symbols on Android. see //base/allocator/README.md.
-config("wrap_malloc_symbols") {
- ldflags = [
- "-Wl,-wrap,calloc",
- "-Wl,-wrap,free",
- "-Wl,-wrap,malloc",
- "-Wl,-wrap,memalign",
- "-Wl,-wrap,posix_memalign",
- "-Wl,-wrap,pvalloc",
- "-Wl,-wrap,realloc",
- "-Wl,-wrap,valloc",
-
- # Not allocating memory, but part of the API
- "-Wl,-wrap,malloc_usable_size",
-
- # <stdlib.h> functions
- "-Wl,-wrap,realpath",
-
- # <string.h> functions
- "-Wl,-wrap,strdup",
- "-Wl,-wrap,strndup",
-
- # <unistd.h> functions
- "-Wl,-wrap,getcwd",
-
- # <stdio.h> functions
- "-Wl,-wrap,asprintf",
- "-Wl,-wrap,vasprintf",
- ]
-}
-
-config("mac_no_default_new_delete_symbols") {
- if (!is_component_build) {
- # This is already set when we compile libc++, see
- # buildtools/third_party/libc++/BUILD.gn. But it needs to be set here as well,
- # since the shim defines the symbols, to prevent them being exported.
- cflags = [ "-fvisibility-global-new-delete-hidden" ]
- }
-}
diff --git a/base/allocator/DIR_METADATA b/base/allocator/DIR_METADATA
deleted file mode 100644
index 14b5edb..0000000
--- a/base/allocator/DIR_METADATA
+++ /dev/null
@@ -1,3 +0,0 @@
-monorail {
- component: "Internals"
-}
diff --git a/base/allocator/OWNERS b/base/allocator/OWNERS
deleted file mode 100644
index e27d563..0000000
--- a/base/allocator/OWNERS
+++ /dev/null
@@ -1,7 +0,0 @@
-lizeb@chromium.org
-primiano@chromium.org
-wfh@chromium.org
-
-per-file allocator.gni=file://base/allocator/partition_allocator/OWNERS
-per-file partition_alloc*=file://base/allocator/partition_allocator/OWNERS
-per-file BUILD.gn=file://base/allocator/partition_allocator/OWNERS
diff --git a/base/allocator/README.md b/base/allocator/README.md
deleted file mode 100644
index d1562ea..0000000
--- a/base/allocator/README.md
+++ /dev/null
@@ -1,156 +0,0 @@
-This document describes how malloc / new calls are routed in the various Chrome
-platforms.
-
-Bear in mind that the chromium codebase does not always just use `malloc()`.
-Some examples:
- - Large parts of the renderer (Blink) use two home-brewed allocators,
- PartitionAlloc and BlinkGC (Oilpan).
- - Some subsystems, such as the V8 JavaScript engine, handle memory management
- autonomously.
- - Various parts of the codebase use abstractions such as `SharedMemory` or
- `DiscardableMemory` which, similarly to the above, have their own page-level
- memory management.
-
-Background
-----------
-The `allocator` target defines at compile-time the platform-specific choice of
-the allocator and extra-hooks which services calls to malloc/new. The relevant
-build-time flags involved are `use_allocator_shim` and
-`use_partition_alloc_as_malloc`.
-
-By default, these are true on all platforms except iOS (not yet supported) and
-NaCl (no plan to support).
-Furthermore, when building with a sanitizer (e.g. `asan`, `msan`, ...) both the
-allocator and the shim layer are disabled.
-
-
-Layering and build deps
------------------------
-The `allocator` target provides the linker flags required for the Windows shim
-layer. The `base` target is (almost) the only one depending on `allocator`. No
-other targets should depend on it, with the exception of the very few
-executables / dynamic libraries that don't depend, either directly or
-indirectly, on `base` within the scope of a linker unit.
-
-More importantly, **no other place outside of `/base` should depend on the
-specific allocator**.
-If such a functional dependency is required that should be achieved using
-abstractions in `base` (see `/base/allocator/allocator_extension.h` and
-`/base/memory/`)
-
-**Why `base` depends on `allocator`?**
-Because it needs to provide services that depend on the actual allocator
-implementation. In the past `base` used to pretend to be allocator-agnostic
-and get the dependencies injected by other layers. This ended up being an
-inconsistent mess.
-See the [allocator cleanup doc][url-allocator-cleanup] for more context.
-
-Linker unit targets (executables and shared libraries) that depend in some way
-on `base` (most of the targets in the codebase) automatically get the correct
-set of linker flags to pull in the Windows shim-layer (if needed).
-
-
-Source code
------------
-This directory contains just the allocator (i.e. shim) layer that switches
-between the different underlying memory allocation implementations.
-
-
-Unified allocator shim
-----------------------
-On most platforms, Chrome overrides the malloc / operator new symbols (and
-corresponding free / delete and other variants). This is to enforce security
-checks and lately to enable the
-[memory-infra heap profiler][url-memory-infra-heap-profiler].
-Historically each platform had its special logic for defining the allocator
-symbols in different places of the codebase. The unified allocator shim is
-a project aimed to unify the symbol definition and allocator routing logic in
-a central place.
-
- - Full documentation: [Allocator shim design doc][url-allocator-shim].
- - Current state: Available and enabled by default on Android, CrOS, Linux,
- Mac OS and Windows.
- - Tracking bug: [crbug.com/550886](https://crbug.com/550886).
- - Build-time flag: `use_allocator_shim`.
-
-**Overview of the unified allocator shim**
-The allocator shim consists of three stages:
-```
-+-------------------------+ +-----------------------+ +----------------+
-| malloc & friends | -> | shim layer | -> | Routing to |
-| symbols definition | | implementation | | allocator |
-+-------------------------+ +-----------------------+ +----------------+
-| - libc symbols (malloc, | | - Security checks | | - glibc |
-| calloc, free, ...) | | - Chain of dispatchers| | - Android |
-| - C++ symbols (operator | | that can intercept | | bionic |
-| new, delete, ...) | | and override | | - WinHeap |
-| - glibc weak symbols | | allocations | | - Partition |
-| (__libc_malloc, ...) | +-----------------------+ | Alloc |
-+-------------------------+ +----------------+
-```
-
-**1. malloc symbols definition**
-This stage takes care of overriding the symbols `malloc`, `free`,
-`operator new`, `operator delete` and friends and routing those calls inside the
-allocator shim (next point).
-This is taken care of by the headers in `allocator_shim_override_*`.
-
-*On Windows*: Windows' UCRT (Universal C Runtime) exports weak symbols, that we
-can override in `allocator_shim_override_ucr_symbols_win.h`.
-
-*On Linux/CrOS*: the allocator symbols are defined as exported global symbols
-in `allocator_shim_override_libc_symbols.h` (for `malloc`, `free` and friends)
-and in `allocator_shim_override_cpp_symbols.h` (for `operator new`,
-`operator delete` and friends).
-This enables proper interposition of malloc symbols referenced by the main
-executable and any third party libraries. Symbol resolution on Linux is a breadth first search that starts from the root link unit, that is the executable
-(see EXECUTABLE AND LINKABLE FORMAT (ELF) - Portable Formats Specification).
-The Linux/CrOS shim was introduced by
-[crrev.com/1675143004](https://crrev.com/1675143004).
-
-*On Android*: load-time symbol interposition (unlike the Linux/CrOS case) is not
-possible. This is because Android processes are `fork()`-ed from the Android
-zygote, which pre-loads libc.so and only later native code gets loaded via
-`dlopen()` (symbols from `dlopen()`-ed libraries get a different resolution
-scope).
-In this case, the approach instead of wrapping symbol resolution at link time
-(i.e. during the build), via the `--Wl,-wrap,malloc` linker flag.
-The use of this wrapping flag causes:
- - All references to allocator symbols in the Chrome codebase to be rewritten as
- references to `__wrap_malloc` and friends. The `__wrap_malloc` symbols are
- defined in the `allocator_shim_override_linker_wrapped_symbols.h` and
- route allocator calls inside the shim layer.
- - The reference to the original `malloc` symbols (which typically is defined by
- the system's libc.so) are accessible via the special `__real_malloc` and
- friends symbols (which will be relocated, at load time, against `malloc`).
-
-In summary, this approach is transparent to the dynamic loader, which still sees
-undefined symbol references to malloc symbols.
-These symbols will be resolved against libc.so as usual.
-More details in [crrev.com/1719433002](https://crrev.com/1719433002).
-
-**2. Shim layer implementation**
-This stage contains the actual shim implementation. This consists of:
-- A singly linked list of dispatchers (structs with function pointers to `malloc`-like functions). Dispatchers can be dynamically inserted at runtime
-(using the `InsertAllocatorDispatch` API). They can intercept and override
-allocator calls.
-- The security checks (suicide on malloc-failure via `std::new_handler`, etc).
-This happens inside `allocator_shim.cc`
-
-**3. Final allocator routing**
-The final element of the aforementioned dispatcher chain is statically defined
-at build time and ultimately routes the allocator calls to the actual allocator
-(as described in the *Background* section above). This is taken care of by the
-headers in `allocator_shim_default_dispatch_to_*` files.
-
-
-Related links
--------------
-- [Unified allocator shim doc - Feb 2016][url-allocator-shim]
-- [Allocator cleanup doc - Jan 2016][url-allocator-cleanup]
-- [Proposal to use PartitionAlloc as default allocator](https://crbug.com/339604)
-- [Memory-Infra: Tools to profile memory usage in Chrome](/docs/memory-infra/README.md)
-
-[url-allocator-cleanup]: https://docs.google.com/document/d/1V77Kgp_4tfaaWPEZVxNevoD02wXiatnAv7Ssgr0hmjg/edit?usp=sharing
-[url-memory-infra-heap-profiler]: /docs/memory-infra/heap_profiler.md
-[url-allocator-shim]: https://docs.google.com/document/d/1yKlO1AO4XjpDad9rjcBOI15EKdAGsuGO_IeZy0g0kxo/edit?usp=sharing
diff --git a/base/allocator/allocator.gni b/base/allocator/allocator.gni
deleted file mode 100644
index 9ea03a4..0000000
--- a/base/allocator/allocator.gni
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2019 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# 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
-
- # Use the new allocation event dispatcher to distribute events to event observers.
- # If set to false, PoissonAllocationSampler will hook into PartitionAllocator and
- # AllocatorShims directly.
- use_allocation_event_dispatcher = true
-}
-
-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.
-if (!use_partition_alloc_as_malloc) {
- # In theory, BackupRefPtr will work just fine without
- # PartitionAlloc-Everywhere, but its scope would be limited to partitions
- # that are invoked explicitly (not via malloc). These are only Blink
- # partition, where we currently don't even use raw_ptr<T>.
- assert(!enable_backup_ref_ptr_support,
- "Chromium does not use BRP without PA-E")
-
- # Pointer compression works only if all pointers are guaranteed to be
- # allocated by PA (in one of its core pools, to be precise). In theory,
- # this could be useful with partitions that are invoked explicitly. In
- # practice, the pointers we have in mind for compression (scoped_refptr<>,
- # unique_ptr<>) require PA-E.
- assert(!enable_pointer_compression_support,
- "Pointer compressions likely doesn't make sense without PA-E")
-}
diff --git a/base/allocator/allocator_check.cc b/base/allocator/allocator_check.cc
deleted file mode 100644
index 90aa928..0000000
--- a/base/allocator/allocator_check.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2016 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/allocator_check.h"
-
-#include "base/allocator/buildflags.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(IS_WIN)
-#include "base/allocator/partition_allocator/shim/winheap_stubs_win.h"
-#endif
-
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
-#include <malloc.h>
-#endif
-
-#if BUILDFLAG(IS_APPLE)
-#include "base/allocator/partition_allocator/shim/allocator_interception_mac.h"
-#endif
-
-namespace base::allocator {
-
-bool IsAllocatorInitialized() {
-#if BUILDFLAG(IS_WIN) && BUILDFLAG(USE_ALLOCATOR_SHIM)
- // Set by allocator_shim_override_ucrt_symbols_win.h when the
- // shimmed _set_new_mode() is called.
- return allocator_shim::g_is_win_shim_layer_initialized;
-#elif BUILDFLAG(IS_APPLE) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
- !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- // From allocator_interception_mac.mm.
- return allocator_shim::g_replaced_default_zone;
-#else
- return true;
-#endif
-}
-
-} // namespace base::allocator
diff --git a/base/allocator/allocator_check.h b/base/allocator/allocator_check.h
deleted file mode 100644
index 58add8b..0000000
--- a/base/allocator/allocator_check.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2016 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_ALLOCATOR_CHECK_H_
-#define BASE_ALLOCATOR_ALLOCATOR_CHECK_H_
-
-#include "base/base_export.h"
-
-namespace base {
-namespace allocator {
-
-BASE_EXPORT bool IsAllocatorInitialized();
-
-} // namespace allocator
-} // namespace base
-
-#endif // BASE_ALLOCATOR_ALLOCATOR_CHECK_H_
diff --git a/base/allocator/allocator_extension.cc b/base/allocator/allocator_extension.cc
deleted file mode 100644
index 88206df..0000000
--- a/base/allocator/allocator_extension.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2012 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/allocator_extension.h"
-#include "base/allocator/buildflags.h"
-#include "base/check.h"
-
-namespace base {
-namespace allocator {
-
-void ReleaseFreeMemory() {}
-
-} // namespace allocator
-} // namespace base
diff --git a/base/allocator/allocator_extension.h b/base/allocator/allocator_extension.h
deleted file mode 100644
index fbc9d1d..0000000
--- a/base/allocator/allocator_extension.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
-#define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
-
-#include <stddef.h> // for size_t
-
-#include "base/base_export.h"
-#include "build/build_config.h"
-
-namespace base {
-namespace allocator {
-
-// Request that the allocator release any free memory it knows about to the
-// system.
-BASE_EXPORT void ReleaseFreeMemory();
-
-} // namespace allocator
-} // namespace base
-
-#endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
diff --git a/base/allocator/dispatcher/configuration.h b/base/allocator/dispatcher/configuration.h
deleted file mode 100644
index 34c3791..0000000
--- a/base/allocator/dispatcher/configuration.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_CONFIGURATION_H_
-#define BASE_ALLOCATOR_DISPATCHER_CONFIGURATION_H_
-
-#include <cstddef>
-
-namespace base::allocator::dispatcher::configuration {
-
-// The maximum number of optional observers that may be present depending on
-// command line parameters.
-constexpr size_t kMaximumNumberOfOptionalObservers = 4;
-
-// The total number of observers including mandatory and optional observers.
-// Primarily the number of observers affects the performance at allocation time.
-// The current value of 4 doesn't have hard evidence. Keep in mind that
-// also a single observer can severely impact performance.
-constexpr size_t kMaximumNumberOfObservers = 4;
-
-} // namespace base::allocator::dispatcher::configuration
-
-#endif // BASE_ALLOCATOR_DISPATCHER_CONFIGURATION_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/dispatcher.cc b/base/allocator/dispatcher/dispatcher.cc
deleted file mode 100644
index aa0e0ae..0000000
--- a/base/allocator/dispatcher/dispatcher.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/dispatcher.h"
-
-#include "base/allocator/buildflags.h"
-#include "base/allocator/dispatcher/internal/dispatch_data.h"
-#if !defined(COBALT_PENDING_CLEAN_UP)
-#include "base/allocator/partition_allocator/partition_alloc.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#endif
-#include "base/check.h"
-#include "base/dcheck_is_on.h"
-#include "base/no_destructor.h"
-
-#if DCHECK_IS_ON()
-#include <atomic>
-#endif
-
-namespace base::allocator::dispatcher {
-
-// The private implementation of Dispatcher.
-struct Dispatcher::Impl {
- void Initialize(const internal::DispatchData& dispatch_data) {
-#if DCHECK_IS_ON()
- DCHECK(!is_initialized_check_flag_.test_and_set());
-#endif
-
- dispatch_data_ = dispatch_data;
- ConnectToEmitters(dispatch_data_);
- }
-
- void Reset() {
-#if DCHECK_IS_ON()
- DCHECK([&]() {
- auto const was_set = is_initialized_check_flag_.test_and_set();
- is_initialized_check_flag_.clear();
- return was_set;
- }());
-#endif
-
- DisconnectFromEmitters(dispatch_data_);
- dispatch_data_ = {};
- }
-
- private:
- // Connect the hooks to the memory subsystem. In some cases, most notably when
- // we have no observers at all, the hooks will be invalid and must NOT be
- // connected. This way we prevent notifications although no observers are
- // present.
- static void ConnectToEmitters(const internal::DispatchData& dispatch_data) {
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- if (auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch()) {
- allocator_shim::InsertAllocatorDispatch(allocator_dispatch);
- }
-#endif
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- {
- auto* const allocation_hook = dispatch_data.GetAllocationObserverHook();
- auto* const free_hook = dispatch_data.GetFreeObserverHook();
- if (allocation_hook && free_hook) {
- partition_alloc::PartitionAllocHooks::SetObserverHooks(allocation_hook,
- free_hook);
- }
- }
-#endif
- }
-
- static void DisconnectFromEmitters(internal::DispatchData& dispatch_data) {
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- if (auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch()) {
- allocator_shim::RemoveAllocatorDispatchForTesting(
- allocator_dispatch); // IN-TEST
- }
-#endif
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- partition_alloc::PartitionAllocHooks::SetObserverHooks(nullptr, nullptr);
-#endif
- }
-
- // Information on the hooks.
- internal::DispatchData dispatch_data_;
-#if DCHECK_IS_ON()
- // Indicator if the dispatcher has been initialized before.
-#if !defined(__cpp_lib_atomic_value_initialization) || \
- __cpp_lib_atomic_value_initialization < 201911L
- std::atomic_flag is_initialized_check_flag_ = ATOMIC_FLAG_INIT;
-#else
- std::atomic_flag is_initialized_check_flag_;
-#endif
-#endif
-};
-
-Dispatcher::Dispatcher() : impl_(std::make_unique<Impl>()) {}
-
-Dispatcher::~Dispatcher() = default;
-
-Dispatcher& Dispatcher::GetInstance() {
- static base::NoDestructor<Dispatcher> instance;
- return *instance;
-}
-
-void Dispatcher::Initialize(const internal::DispatchData& dispatch_data) {
- impl_->Initialize(dispatch_data);
-}
-
-void Dispatcher::ResetForTesting() {
- impl_->Reset();
-}
-} // namespace base::allocator::dispatcher
diff --git a/base/allocator/dispatcher/dispatcher.h b/base/allocator/dispatcher/dispatcher.h
deleted file mode 100644
index b8fc677..0000000
--- a/base/allocator/dispatcher/dispatcher.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_DISPATCHER_H_
-#define BASE_ALLOCATOR_DISPATCHER_DISPATCHER_H_
-
-#include "base/allocator/dispatcher/internal/dispatcher_internal.h"
-#include "base/base_export.h"
-
-#include <memory>
-
-namespace base::allocator::dispatcher {
-
-namespace internal {
-struct DispatchData;
-}
-
-// Dispatcher serves as the top level instance for managing the dispatch
-// mechanism. The class instance manages connections to the various memory
-// subsystems such as PartitionAlloc. To keep the public interface as lean as
-// possible it uses a pimpl pattern.
-class BASE_EXPORT Dispatcher {
- public:
- static Dispatcher& GetInstance();
-
- Dispatcher();
-
- // Initialize the dispatch mechanism with the given tuple of observers. The
- // observers must be valid (it is only DCHECKed internally at initialization,
- // but not verified further)
- // If Initialize is called multiple times, the first one wins. All later
- // invocations are silently ignored. Initialization is protected from
- // concurrent invocations. In case of concurrent accesses, the first one to
- // get the lock wins.
- // The dispatcher invokes following functions on the observers:
- // void OnAllocation(void* address,
- // size_t size,
- // AllocationSubsystem sub_system,
- // const char* type_name);
- // void OnFree(void* address);
- //
- // Note: The dispatcher mechanism does NOT bring systematic protection against
- // recursive invocations. That is, observers which allocate memory on the
- // heap, i.e. through dynamically allocated containers or by using the
- // CHECK-macro, are responsible to break these recursions!
- template <typename... ObserverTypes>
- void Initialize(const std::tuple<ObserverTypes...>& observers) {
- // Get the hooks for running these observers and pass them to further
- // initialization
- Initialize(internal::GetNotificationHooks(observers));
- }
-
- // The following functions provide an interface to setup and tear down the
- // dispatcher when testing. This must NOT be used from production code since
- // the hooks cannot be removed reliably under all circumstances.
- template <typename ObserverType>
- void InitializeForTesting(ObserverType* observer) {
- Initialize(std::make_tuple(observer));
- }
-
- void ResetForTesting();
-
- private:
- // structure and pointer to the private implementation.
- struct Impl;
- std::unique_ptr<Impl> const impl_;
-
- ~Dispatcher();
-
- void Initialize(const internal::DispatchData& dispatch_data);
-};
-} // namespace base::allocator::dispatcher
-
-#endif // BASE_ALLOCATOR_DISPATCHER_DISPATCHER_H_
diff --git a/base/allocator/dispatcher/dispatcher_unittest.cc b/base/allocator/dispatcher/dispatcher_unittest.cc
deleted file mode 100644
index 559493f..0000000
--- a/base/allocator/dispatcher/dispatcher_unittest.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-#include "base/allocator/buildflags.h"
-#include "base/allocator/dispatcher/configuration.h"
-#include "base/allocator/dispatcher/dispatcher.h"
-#include "base/allocator/dispatcher/testing/dispatcher_test.h"
-#include "base/allocator/dispatcher/testing/tools.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-#include "base/allocator/partition_allocator/partition_alloc_for_testing.h" // nogncheck
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#endif
-
-#include <tuple>
-
-namespace base::allocator::dispatcher {
-namespace {
-using configuration::kMaximumNumberOfObservers;
-using configuration::kMaximumNumberOfOptionalObservers;
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-using partition_alloc::PartitionOptions;
-using partition_alloc::ThreadSafePartitionRoot;
-#endif
-using testing::DispatcherTest;
-
-// A simple observer implementation. Since these tests plug in to Partition
-// Allocator and Allocator Shim, implementing an observer with Google Mock
-// results in endless recursion.
-struct ObserverMock {
- void OnAllocation(void* address,
- size_t size,
- AllocationSubsystem sub_system,
- const char* type_name) {
- ++on_allocation_calls_;
- }
- void OnFree(void* address) { ++on_free_calls_; }
-
- void Reset() {
- on_allocation_calls_ = 0;
- on_free_calls_ = 0;
- }
-
- size_t GetNumberOnAllocationCalls() const { return on_allocation_calls_; }
- size_t GetNumberOnFreeCalls() const { return on_free_calls_; }
-
- private:
- size_t on_allocation_calls_ = 0;
- size_t on_free_calls_ = 0;
-};
-
-struct DispatcherInitializerGuard {
- template <typename... Observers>
- explicit DispatcherInitializerGuard(std::tuple<Observers*...> observers) {
- Dispatcher::GetInstance().Initialize(observers);
- }
-
- ~DispatcherInitializerGuard() { Dispatcher::GetInstance().ResetForTesting(); }
-};
-
-struct BaseAllocatorDispatcherTest : public DispatcherTest {};
-
-template <typename A>
-void DoBasicTest(A& allocator) {
- // All we want to verify is that the Dispatcher correctly hooks into the
- // passed allocator. Therefore, we do not perform an exhaustive test but
- // just check some basics.
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- {
- DispatcherInitializerGuard const g(
- testing::CreateTupleOfPointers(observers));
-
- constexpr size_t size_to_allocate = 1024;
- void* const ptr = allocator.Alloc(size_to_allocate);
- allocator.Free(ptr);
- }
-
- for (const auto& mock : observers) {
- EXPECT_GE(mock.GetNumberOnAllocationCalls(), 1u);
- EXPECT_GE(mock.GetNumberOnFreeCalls(), 1u);
- }
-}
-
-TEST_F(BaseAllocatorDispatcherTest, VerifyInitialization) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- DispatcherInitializerGuard g(testing::CreateTupleOfPointers(observers));
-}
-
-#if BUILDFLAG(USE_PARTITION_ALLOC) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
-// Don't enable this test when MEMORY_TOOL_REPLACES_ALLOCATOR is defined,
-// because it makes PartitionAlloc take a different path that doesn't provide
-// notifications to observer hooks.
-struct PartitionAllocator {
- void* Alloc(size_t size) { return alloc_.AllocWithFlags(0, size, nullptr); }
- void Free(void* data) { alloc_.Free(data); }
- ~PartitionAllocator() {
- // Use |DisallowLeaks| to confirm that there is no memory allocated and
- // not yet freed.
- alloc_.ResetForTesting(::partition_alloc::internal::DisallowLeaks);
- }
-
- private:
- ThreadSafePartitionRoot alloc_{{
- PartitionOptions::AlignedAlloc::kDisallowed,
- PartitionOptions::ThreadCache::kDisabled,
- PartitionOptions::Quarantine::kDisallowed,
- PartitionOptions::Cookie::kAllowed,
- PartitionOptions::BackupRefPtr::kDisabled,
- PartitionOptions::BackupRefPtrZapping::kDisabled,
- PartitionOptions::UseConfigurablePool::kNo,
- }};
-};
-
-TEST_F(BaseAllocatorDispatcherTest, VerifyNotificationUsingPartitionAllocator) {
- PartitionAllocator allocator;
- DoBasicTest(allocator);
-}
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-struct AllocatorShimAllocator {
- void* Alloc(size_t size) { return allocator_shim::UncheckedAlloc(size); }
- void Free(void* data) { allocator_shim::UncheckedFree(data); }
-};
-
-#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-// Disable the test when running on any of Apple's OSs without PartitionAlloc
-// being the default allocator. In this case, all allocations are routed to
-// MallocImpl, which then causes the test to terminate unexpectedly.
-#define MAYBE_VerifyNotificationUsingAllocatorShim \
- DISABLED_VerifyNotificationUsingAllocatorShim
-#else
-#define MAYBE_VerifyNotificationUsingAllocatorShim \
- VerifyNotificationUsingAllocatorShim
-#endif
-
-TEST_F(BaseAllocatorDispatcherTest, MAYBE_VerifyNotificationUsingAllocatorShim) {
- AllocatorShimAllocator allocator;
- DoBasicTest(allocator);
-}
-#endif
-
-} // namespace
-} // namespace base::allocator::dispatcher
diff --git a/base/allocator/dispatcher/initializer.h b/base/allocator/dispatcher/initializer.h
deleted file mode 100644
index 3179134..0000000
--- a/base/allocator/dispatcher/initializer.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_INITIALIZER_H_
-#define BASE_ALLOCATOR_DISPATCHER_INITIALIZER_H_
-
-#include "base/allocator/dispatcher/configuration.h"
-#include "base/allocator/dispatcher/dispatcher.h"
-#include "base/allocator/dispatcher/internal/tools.h"
-
-#include <tuple>
-#include <utility>
-
-namespace base::allocator::dispatcher {
-namespace internal {
-
-// Filter the passed observers and perform initialization of the passed
-// dispatcher.
-template <size_t CurrentIndex,
- typename DispatcherType,
- typename CheckObserverPredicate,
- typename VerifiedObservers,
- typename UnverifiedObservers,
- size_t... IndicesToSelect>
-inline void DoInitialize(DispatcherType& dispatcher,
- CheckObserverPredicate check_observer,
- const VerifiedObservers& verified_observers,
- const UnverifiedObservers& unverified_observers,
- std::index_sequence<IndicesToSelect...> indices) {
- if constexpr (CurrentIndex < std::tuple_size<UnverifiedObservers>::value) {
- // We still have some items left to handle.
- if (check_observer(std::get<CurrentIndex>(unverified_observers))) {
- // The current observer is valid. Hence, append the index of the current
- // item to the set of indices and head on to the next item.
- DoInitialize<CurrentIndex + 1>(
- dispatcher, check_observer, verified_observers, unverified_observers,
- std::index_sequence<IndicesToSelect..., CurrentIndex>{});
- } else {
- // The current observer is not valid. Hence, head on to the next item with
- // an unaltered list of indices.
- DoInitialize<CurrentIndex + 1>(dispatcher, check_observer,
- verified_observers, unverified_observers,
- indices);
- }
- } else if constexpr (CurrentIndex ==
- std::tuple_size<UnverifiedObservers>::value) {
- // So we have met the end of the tuple of observers to verify.
- // Hence, we extract the additional valid observers, append to the tuple of
- // already verified observers and hand over to the dispatcher.
- auto observers = std::tuple_cat(
- verified_observers,
- std::make_tuple(std::get<IndicesToSelect>(unverified_observers)...));
-
- // Do a final check that neither the maximum total number of observers nor
- // the maximum number of optional observers is exceeded.
- static_assert(std::tuple_size<decltype(observers)>::value <=
- configuration::kMaximumNumberOfObservers);
- static_assert(sizeof...(IndicesToSelect) <=
- configuration::kMaximumNumberOfOptionalObservers);
-
- dispatcher.Initialize(std::move(observers));
- }
-}
-
-} // namespace internal
-
-// The result of concatenating two tuple-types.
-template <typename... tuples>
-using TupleCat = decltype(std::tuple_cat(std::declval<tuples>()...));
-
-// Initializer collects mandatory and optional observers and initializes the
-// passed Dispatcher with only the enabled observers.
-//
-// In some situations, presence of observers depends on runtime. i.e. command
-// line parameters or CPU features. With 3 optional observers we already have 8
-// different combinations. Initializer takes the job of dealing with all
-// combinations from the user. It allows users to pass all observers (including
-// nullptr for disabled optional observers) and initializes the Dispatcher with
-// only the enabled observers.
-//
-// Since this process results in a combinatoric explosion, Initializer
-// distinguishes between optional and mandatory observers. Mandatory observers
-// are not included in the filtering process and must always be enabled (not
-// nullptr).
-//
-// To allow the Initializer to track the number and exact type of observers, it
-// is implemented as a templated class which holds information on the types in
-// the std::tuples passed as template parameters. Therefore, whenever any type
-// observer it set, the initializer changes its type to reflect this.
-template <typename MandatoryObservers = std::tuple<>,
- typename OptionalObservers = std::tuple<>>
-struct BASE_EXPORT Initializer {
- Initializer() = default;
- Initializer(MandatoryObservers mandatory_observers,
- OptionalObservers optional_observers)
- : mandatory_observers_(std::move(mandatory_observers)),
- optional_observers_(std::move(optional_observers)) {}
-
- // Set the mandatory observers. The number of observers that can be set is
- // limited by configuration::maximum_number_of_observers.
- template <typename... NewMandatoryObservers,
- std::enable_if_t<
- internal::LessEqual((sizeof...(NewMandatoryObservers) +
- std::tuple_size<OptionalObservers>::value),
- configuration::kMaximumNumberOfObservers),
- bool> = true>
- Initializer<std::tuple<NewMandatoryObservers*...>, OptionalObservers>
- SetMandatoryObservers(NewMandatoryObservers*... mandatory_observers) const {
- return {std::make_tuple(mandatory_observers...), GetOptionalObservers()};
- }
-
- // Add mandatory observers. The number of observers that can be added is
- // limited by the current number of observers, see
- // configuration::maximum_number_of_observers.
- template <typename... AdditionalMandatoryObservers,
- std::enable_if_t<internal::LessEqual(
- std::tuple_size<MandatoryObservers>::value +
- sizeof...(AdditionalMandatoryObservers) +
- std::tuple_size<OptionalObservers>::value,
- configuration::kMaximumNumberOfObservers),
- bool> = true>
- Initializer<TupleCat<MandatoryObservers,
- std::tuple<AdditionalMandatoryObservers*...>>,
- OptionalObservers>
- AddMandatoryObservers(
- AdditionalMandatoryObservers*... additional_mandatory_observers) const {
- return {std::tuple_cat(GetMandatoryObservers(),
- std::make_tuple(additional_mandatory_observers...)),
- GetOptionalObservers()};
- }
-
- // Set the optional observers. The number of observers that can be set is
- // limited by configuration::maximum_number_of_optional_observers as well as
- // configuration::maximum_number_of_observers.
- template <
- typename... NewOptionalObservers,
- std::enable_if_t<
- internal::LessEqual(
- sizeof...(NewOptionalObservers),
- configuration::kMaximumNumberOfOptionalObservers) &&
- internal::LessEqual((sizeof...(NewOptionalObservers) +
- std::tuple_size<MandatoryObservers>::value),
- configuration::kMaximumNumberOfObservers),
- bool> = true>
- Initializer<MandatoryObservers, std::tuple<NewOptionalObservers*...>>
- SetOptionalObservers(NewOptionalObservers*... optional_observers) const {
- return {GetMandatoryObservers(), std::make_tuple(optional_observers...)};
- }
-
- // Add optional observers. The number of observers that can be added is
- // limited by the current number of optional observers,
- // configuration::maximum_number_of_optional_observers as well as
- // configuration::maximum_number_of_observers.
- template <
- typename... AdditionalOptionalObservers,
- std::enable_if_t<
- internal::LessEqual(
- std::tuple_size<OptionalObservers>::value +
- sizeof...(AdditionalOptionalObservers),
- configuration::kMaximumNumberOfOptionalObservers) &&
- internal::LessEqual((std::tuple_size<OptionalObservers>::value +
- sizeof...(AdditionalOptionalObservers) +
- std::tuple_size<MandatoryObservers>::value),
- configuration::kMaximumNumberOfObservers),
- bool> = true>
- Initializer<
- MandatoryObservers,
- TupleCat<OptionalObservers, std::tuple<AdditionalOptionalObservers*...>>>
- AddOptionalObservers(
- AdditionalOptionalObservers*... additional_optional_observers) const {
- return {GetMandatoryObservers(),
- std::tuple_cat(GetOptionalObservers(),
- std::make_tuple(additional_optional_observers...))};
- }
-
- // Perform the actual initialization on the passed dispatcher.
- // The dispatcher is passed as a template only to provide better testability.
- template <typename DispatcherType>
- void DoInitialize(DispatcherType& dispatcher) const {
- internal::DoInitialize<0>(dispatcher, internal::IsValidObserver{},
- GetMandatoryObservers(), GetOptionalObservers(),
- {});
- }
-
- const MandatoryObservers& GetMandatoryObservers() const {
- return mandatory_observers_;
- }
-
- const OptionalObservers& GetOptionalObservers() const {
- return optional_observers_;
- }
-
- private:
- MandatoryObservers mandatory_observers_;
- OptionalObservers optional_observers_;
-};
-
-// Convenience function for creating an empty Initializer.
-inline Initializer<> CreateInitializer() {
- return {};
-}
-
-} // namespace base::allocator::dispatcher
-
-#endif // BASE_ALLOCATOR_DISPATCHER_INITIALIZER_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/initializer_unittest.cc b/base/allocator/dispatcher/initializer_unittest.cc
deleted file mode 100644
index f705830..0000000
--- a/base/allocator/dispatcher/initializer_unittest.cc
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-#include "base/allocator/dispatcher/configuration.h"
-#include "base/allocator/dispatcher/initializer.h"
-#include "base/allocator/dispatcher/testing/observer_mock.h"
-#include "base/allocator/dispatcher/testing/tools.h"
-
-#include <functional>
-#include <map>
-#include <tuple>
-
-namespace base::allocator::dispatcher {
-namespace testing {
-
-// A mock Dispatcher for testing. Since Initializer and Dispatcher rely on
-// templating, we can't employ GoogleMocks for mocking. The mock dispatcher
-// records the number of invocations of Initialize for a given tuple of
-// observers.
-struct Dispatcher {
- Dispatcher() = default;
-
- ~Dispatcher() {
- for (const auto& reset_data : reseter_) {
- reset_data.second();
- }
- }
-
- template <typename... Observers>
- void Initialize(const std::tuple<Observers*...>& observers) {
- ++total_number_of_inits_;
- ++(GetInitCounterForObservers(observers));
- }
-
- size_t GetTotalInitCounter() const { return total_number_of_inits_; }
-
- template <typename... Observers>
- size_t& GetInitCounterForObservers(
- const std::tuple<Observers*...>& observers) {
- static std::map<std::tuple<Observers*...>, size_t>
- observer_init_counter_map;
- reseter_[&observer_init_counter_map] = []() {
- observer_init_counter_map.clear();
- };
- return observer_init_counter_map[observers];
- }
-
- size_t total_number_of_inits_ = 0;
- std::map<void*, std::function<void()>> reseter_;
-};
-} // namespace testing
-
-using testing::ObserverMock;
-
-struct BaseAllocatorDispatcherInitializerTest : public ::testing::Test {};
-
-TEST_F(BaseAllocatorDispatcherInitializerTest, VerifyEmptyInitializer) {
- const auto initializer = CreateInitializer();
-
- EXPECT_EQ(initializer.GetOptionalObservers(), std::make_tuple());
- EXPECT_EQ(initializer.GetMandatoryObservers(), std::make_tuple());
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest, VerifySettingOptionalObservers) {
- ObserverMock<int> optional_observer_1;
- ObserverMock<float> optional_observer_2;
- ObserverMock<size_t> optional_observer_3;
-
- auto initializer_1 = CreateInitializer().SetOptionalObservers(
- &optional_observer_1, &optional_observer_2);
- EXPECT_EQ(initializer_1.GetOptionalObservers(),
- std::make_tuple(&optional_observer_1, &optional_observer_2));
- EXPECT_EQ(initializer_1.GetMandatoryObservers(), std::make_tuple());
-
- auto initializer_2 = initializer_1.SetOptionalObservers(&optional_observer_3);
- EXPECT_EQ(initializer_2.GetOptionalObservers(),
- std::make_tuple(&optional_observer_3));
- EXPECT_EQ(initializer_2.GetMandatoryObservers(), std::make_tuple());
-
- auto initializer_3 = initializer_2.SetOptionalObservers();
- EXPECT_EQ(initializer_3.GetOptionalObservers(), std::make_tuple());
- EXPECT_EQ(initializer_3.GetMandatoryObservers(), std::make_tuple());
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest, VerifyAddingOptionalObservers) {
- ObserverMock<int> optional_observer_1;
- ObserverMock<float> optional_observer_2;
- ObserverMock<size_t> optional_observer_3;
-
- auto initializer_1 = CreateInitializer().AddOptionalObservers(
- &optional_observer_1, &optional_observer_2);
- EXPECT_EQ(initializer_1.GetOptionalObservers(),
- std::make_tuple(&optional_observer_1, &optional_observer_2));
- EXPECT_EQ(initializer_1.GetMandatoryObservers(), std::make_tuple());
-
- auto initializer_2 = initializer_1.AddOptionalObservers(&optional_observer_3);
- EXPECT_EQ(initializer_2.GetOptionalObservers(),
- std::make_tuple(&optional_observer_1, &optional_observer_2,
- &optional_observer_3));
- EXPECT_EQ(initializer_2.GetMandatoryObservers(), std::make_tuple());
-
- auto initializer_3 = initializer_2.AddOptionalObservers();
- EXPECT_EQ(initializer_3.GetOptionalObservers(),
- std::make_tuple(&optional_observer_1, &optional_observer_2,
- &optional_observer_3));
- EXPECT_EQ(initializer_3.GetMandatoryObservers(), std::make_tuple());
-
- auto initializer_4 = initializer_3.SetOptionalObservers();
- EXPECT_EQ(initializer_4.GetOptionalObservers(), std::make_tuple());
- EXPECT_EQ(initializer_4.GetMandatoryObservers(), std::make_tuple());
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest,
- VerifySettingMandatoryObservers) {
- ObserverMock<int> mandatory_observer_1;
- ObserverMock<float> mandatory_observer_2;
- ObserverMock<size_t> mandatory_observer_3;
-
- auto initializer_1 = CreateInitializer().SetMandatoryObservers(
- &mandatory_observer_1, &mandatory_observer_2);
- EXPECT_EQ(initializer_1.GetMandatoryObservers(),
- std::make_tuple(&mandatory_observer_1, &mandatory_observer_2));
- EXPECT_EQ(initializer_1.GetOptionalObservers(), std::make_tuple());
-
- auto initializer_2 =
- initializer_1.SetMandatoryObservers(&mandatory_observer_3);
- EXPECT_EQ(initializer_2.GetMandatoryObservers(),
- std::make_tuple(&mandatory_observer_3));
- EXPECT_EQ(initializer_2.GetOptionalObservers(), std::make_tuple());
-
- auto initializer_3 = initializer_2.SetMandatoryObservers();
- EXPECT_EQ(initializer_3.GetMandatoryObservers(), std::make_tuple());
- EXPECT_EQ(initializer_3.GetOptionalObservers(), std::make_tuple());
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest, VerifyAddingMandatoryObservers) {
- ObserverMock<int> mandatory_observer_1;
- ObserverMock<float> mandatory_observer_2;
- ObserverMock<size_t> mandatory_observer_3;
-
- auto initializer_1 = CreateInitializer().AddMandatoryObservers(
- &mandatory_observer_1, &mandatory_observer_2);
- EXPECT_EQ(initializer_1.GetMandatoryObservers(),
- std::make_tuple(&mandatory_observer_1, &mandatory_observer_2));
- EXPECT_EQ(initializer_1.GetOptionalObservers(), std::make_tuple());
-
- auto initializer_2 =
- initializer_1.AddMandatoryObservers(&mandatory_observer_3);
- EXPECT_EQ(initializer_2.GetMandatoryObservers(),
- std::make_tuple(&mandatory_observer_1, &mandatory_observer_2,
- &mandatory_observer_3));
- EXPECT_EQ(initializer_2.GetOptionalObservers(), std::make_tuple());
-
- auto initializer_3 = initializer_2.AddMandatoryObservers();
- EXPECT_EQ(initializer_3.GetMandatoryObservers(),
- std::make_tuple(&mandatory_observer_1, &mandatory_observer_2,
- &mandatory_observer_3));
- EXPECT_EQ(initializer_3.GetOptionalObservers(), std::make_tuple());
-
- auto initializer_4 = initializer_3.SetMandatoryObservers();
- EXPECT_EQ(initializer_4.GetMandatoryObservers(), std::make_tuple());
- EXPECT_EQ(initializer_4.GetOptionalObservers(), std::make_tuple());
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest, VerifyBasicInitialization) {
- ObserverMock<int> optional_observer_1;
- ObserverMock<float> optional_observer_2;
- ObserverMock<size_t> mandatory_observer_1;
- ObserverMock<double> mandatory_observer_2;
-
- testing::Dispatcher test_dispatcher;
-
- CreateInitializer()
- .SetMandatoryObservers(&mandatory_observer_1, &mandatory_observer_2)
- .SetOptionalObservers(&optional_observer_1, &optional_observer_2)
- .DoInitialize(test_dispatcher);
-
- const auto observer_ptrs =
- std::make_tuple(&mandatory_observer_1, &mandatory_observer_2,
- &optional_observer_1, &optional_observer_2);
-
- EXPECT_EQ(1ul, test_dispatcher.GetInitCounterForObservers(observer_ptrs));
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest,
- VerifyInitializationWithMandatoryNullObservers) {
- ObserverMock<int> optional_observer_1;
- ObserverMock<float> optional_observer_2;
- ObserverMock<size_t> mandatory_observer;
- ObserverMock<double>* mandatory_null_observer = nullptr;
-
- testing::Dispatcher test_dispatcher;
-
- CreateInitializer()
- .SetMandatoryObservers(&mandatory_observer, mandatory_null_observer)
- .SetOptionalObservers(&optional_observer_1, &optional_observer_2)
- .DoInitialize(test_dispatcher);
-
- // For mandatory observers being null we expect them to be passed straight
- // down to the dispatcher, which will then perform a check of ALL observers.
- const auto valid_observer_ptrs =
- std::make_tuple(&mandatory_observer, mandatory_null_observer,
- &optional_observer_1, &optional_observer_2);
-
- EXPECT_EQ(1ul, test_dispatcher.GetTotalInitCounter());
- EXPECT_EQ(1ul,
- test_dispatcher.GetInitCounterForObservers(valid_observer_ptrs));
-}
-
-TEST_F(BaseAllocatorDispatcherInitializerTest,
- VerifyInitializationWithOptionalNullObservers) {
- ObserverMock<int> optional_observer;
- ObserverMock<float>* optional_null_observer = nullptr;
- ObserverMock<size_t> mandatory_observer_1;
- ObserverMock<double> mandatory_observer_2;
-
- testing::Dispatcher test_dispatcher;
-
- CreateInitializer()
- .SetMandatoryObservers(&mandatory_observer_1, &mandatory_observer_2)
- .SetOptionalObservers(&optional_observer, optional_null_observer)
- .DoInitialize(test_dispatcher);
-
- const auto valid_observer_ptrs = std::make_tuple(
- &mandatory_observer_1, &mandatory_observer_2, &optional_observer);
-
- EXPECT_EQ(1ul, test_dispatcher.GetTotalInitCounter());
- EXPECT_EQ(1ul,
- test_dispatcher.GetInitCounterForObservers(valid_observer_ptrs));
-}
-
-} // namespace base::allocator::dispatcher
\ No newline at end of file
diff --git a/base/allocator/dispatcher/internal/dispatch_data.cc b/base/allocator/dispatcher/internal/dispatch_data.cc
deleted file mode 100644
index 2b6b7f5..0000000
--- a/base/allocator/dispatcher/internal/dispatch_data.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/internal/dispatch_data.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-
-namespace base::allocator::dispatcher::internal {
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-
-DispatchData& DispatchData::SetAllocationObserverHooks(
- AllocationObserverHook* allocation_observer_hook,
- FreeObserverHook* free_observer_hook) {
- allocation_observer_hook_ = allocation_observer_hook;
- free_observer_hook_ = free_observer_hook;
-
- return *this;
-}
-
-DispatchData::AllocationObserverHook* DispatchData::GetAllocationObserverHook()
- const {
- return allocation_observer_hook_;
-}
-
-DispatchData::FreeObserverHook* DispatchData::GetFreeObserverHook() const {
- return free_observer_hook_;
-}
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-DispatchData& DispatchData::SetAllocatorDispatch(
- AllocatorDispatch* allocator_dispatch) {
- allocator_dispatch_ = allocator_dispatch;
- return *this;
-}
-
-AllocatorDispatch* DispatchData::GetAllocatorDispatch() const {
- return allocator_dispatch_;
-}
-#endif
-} // namespace base::allocator::dispatcher::internal
diff --git a/base/allocator/dispatcher/internal/dispatch_data.h b/base/allocator/dispatcher/internal/dispatch_data.h
deleted file mode 100644
index 64931e6..0000000
--- a/base/allocator/dispatcher/internal/dispatch_data.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCH_DATA_H_
-#define BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCH_DATA_H_
-
-#include "base/allocator/buildflags.h"
-#if defined(COBALT_PENDING_CLEAN_UP)
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#endif
-#include "base/base_export.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-#include "base/allocator/partition_allocator/partition_alloc.h"
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#endif
-
-namespace base::allocator::dispatcher::internal {
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-using allocator_shim::AllocatorDispatch;
-#endif
-
-// A simple utility class to pass all the information required to properly hook
-// into the memory allocation subsystems from DispatcherImpl to the Dispatcher.
-struct BASE_EXPORT DispatchData {
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- using AllocationObserverHook =
- partition_alloc::PartitionAllocHooks::AllocationObserverHook;
- using FreeObserverHook =
- partition_alloc::PartitionAllocHooks::FreeObserverHook;
-
- DispatchData& SetAllocationObserverHooks(AllocationObserverHook*,
- FreeObserverHook*);
- AllocationObserverHook* GetAllocationObserverHook() const;
- FreeObserverHook* GetFreeObserverHook() const;
-
- private:
- AllocationObserverHook* allocation_observer_hook_ = nullptr;
- FreeObserverHook* free_observer_hook_ = nullptr;
-
- public:
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- DispatchData& SetAllocatorDispatch(AllocatorDispatch* allocator_dispatch);
- AllocatorDispatch* GetAllocatorDispatch() const;
-
- private:
- AllocatorDispatch* allocator_dispatch_ = nullptr;
-#endif
-};
-
-} // namespace base::allocator::dispatcher::internal
-
-#endif
diff --git a/base/allocator/dispatcher/internal/dispatcher_internal.h b/base/allocator/dispatcher/internal/dispatcher_internal.h
deleted file mode 100644
index 7b62fb0..0000000
--- a/base/allocator/dispatcher/internal/dispatcher_internal.h
+++ /dev/null
@@ -1,347 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCHER_INTERNAL_H_
-#define BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCHER_INTERNAL_H_
-
-#include "base/allocator/buildflags.h"
-#include "base/allocator/dispatcher/configuration.h"
-#include "base/allocator/dispatcher/internal/dispatch_data.h"
-#include "base/allocator/dispatcher/internal/tools.h"
-#include "base/allocator/dispatcher/subsystem.h"
-#if !defined(COBALT_PENDING_CLEAN_UP)
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#endif
-#include "base/check.h"
-#include "base/compiler_specific.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-#include "base/allocator/partition_allocator/partition_alloc.h"
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#endif
-
-#include <tuple>
-
-namespace base::allocator::dispatcher::internal {
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-using allocator_shim::AllocatorDispatch;
-#endif
-
-template <typename CheckObserverPredicate,
- typename... ObserverTypes,
- size_t... Indices>
-void inline PerformObserverCheck(const std::tuple<ObserverTypes...>& observers,
- std::index_sequence<Indices...>,
- CheckObserverPredicate check_observer) {
- ([](bool b) { DCHECK(b); }(check_observer(std::get<Indices>(observers))),
- ...);
-}
-
-template <typename... ObserverTypes, size_t... Indices>
-ALWAYS_INLINE void PerformAllocationNotification(
- const std::tuple<ObserverTypes...>& observers,
- std::index_sequence<Indices...>,
- void* address,
- size_t size,
- AllocationSubsystem subSystem,
- const char* type_name) {
- ((std::get<Indices>(observers)->OnAllocation(address, size, subSystem,
- type_name)),
- ...);
-}
-
-template <typename... ObserverTypes, size_t... Indices>
-ALWAYS_INLINE void PerformFreeNotification(
- const std::tuple<ObserverTypes...>& observers,
- std::index_sequence<Indices...>,
- void* address) {
- ((std::get<Indices>(observers)->OnFree(address)), ...);
-}
-
-// DispatcherImpl provides hooks into the various memory subsystems. These hooks
-// are responsible for dispatching any notification to the observers.
-// In order to provide as many information on the exact type of the observer and
-// prevent any conditional jumps in the hot allocation path, observers are
-// stored in a std::tuple. DispatcherImpl performs a CHECK at initialization
-// time to ensure they are valid.
-template <typename... ObserverTypes>
-struct DispatcherImpl {
- using AllObservers = std::index_sequence_for<ObserverTypes...>;
-
- template <std::enable_if_t<
- internal::LessEqual(sizeof...(ObserverTypes),
- configuration::kMaximumNumberOfObservers),
- bool> = true>
- static DispatchData GetNotificationHooks(
- std::tuple<ObserverTypes*...> observers) {
- s_observers = std::move(observers);
-
- PerformObserverCheck(s_observers, AllObservers{}, IsValidObserver{});
-
- return CreateDispatchData();
- }
-
- private:
- static DispatchData CreateDispatchData() {
- return DispatchData()
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- .SetAllocationObserverHooks(&PartitionAllocatorAllocationHook,
- &PartitionAllocatorFreeHook)
-#endif
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- .SetAllocatorDispatch(&allocator_dispatch_)
-#endif
- ;
- }
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- static void PartitionAllocatorAllocationHook(void* address,
- size_t size,
- const char* type_name) {
- DoNotifyAllocation(address, size, AllocationSubsystem::kPartitionAllocator,
- type_name);
- }
-
- static void PartitionAllocatorFreeHook(void* address) {
- DoNotifyFree(address);
- }
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- static void* AllocFn(const AllocatorDispatch* self,
- size_t size,
- void* context) {
- void* const address = self->next->alloc_function(self->next, size, context);
-
- DoNotifyAllocation(address, size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void* AllocUncheckedFn(const AllocatorDispatch* self,
- size_t size,
- void* context) {
- void* const address =
- self->next->alloc_unchecked_function(self->next, size, context);
-
- DoNotifyAllocation(address, size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void* AllocZeroInitializedFn(const AllocatorDispatch* self,
- size_t n,
- size_t size,
- void* context) {
- void* const address = self->next->alloc_zero_initialized_function(
- self->next, n, size, context);
-
- DoNotifyAllocation(address, n * size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void* AllocAlignedFn(const AllocatorDispatch* self,
- size_t alignment,
- size_t size,
- void* context) {
- void* const address = self->next->alloc_aligned_function(
- self->next, alignment, size, context);
-
- DoNotifyAllocation(address, size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void* ReallocFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- void* context) {
- // Note: size == 0 actually performs free.
- DoNotifyFree(address);
- void* const reallocated_address =
- self->next->realloc_function(self->next, address, size, context);
-
- DoNotifyAllocation(reallocated_address, size,
- AllocationSubsystem::kAllocatorShim);
-
- return reallocated_address;
- }
-
- static void FreeFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- // Note: The RecordFree should be called before free_function (here and in
- // other places). That is because observers need to handle the allocation
- // being freed before calling free_function, as once the latter is executed
- // the address becomes available and can be allocated by another thread.
- // That would be racy otherwise.
- DoNotifyFree(address);
- self->next->free_function(self->next, address, context);
- }
-
- static size_t GetSizeEstimateFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- return self->next->get_size_estimate_function(self->next, address, context);
- }
-
- static bool ClaimedAddressFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- return self->next->claimed_address_function(self->next, address, context);
- }
-
- static unsigned BatchMallocFn(const AllocatorDispatch* self,
- size_t size,
- void** results,
- unsigned num_requested,
- void* context) {
- unsigned const num_allocated = self->next->batch_malloc_function(
- self->next, size, results, num_requested, context);
- for (unsigned i = 0; i < num_allocated; ++i) {
- DoNotifyAllocation(results[i], size, AllocationSubsystem::kAllocatorShim);
- }
- return num_allocated;
- }
-
- static void BatchFreeFn(const AllocatorDispatch* self,
- void** to_be_freed,
- unsigned num_to_be_freed,
- void* context) {
- // Note: The code doesn't need to protect from recursions using
- // ReentryGuard, see ReallocFn for details.
- for (unsigned i = 0; i < num_to_be_freed; ++i) {
- DoNotifyFree(to_be_freed[i]);
- }
- self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed,
- context);
- }
-
- static void FreeDefiniteSizeFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- void* context) {
- DoNotifyFree(address);
- self->next->free_definite_size_function(self->next, address, size, context);
- }
-
- static void TryFreeDefaultFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- DoNotifyFree(address);
- self->next->try_free_default_function(self->next, address, context);
- }
-
- static void* AlignedMallocFn(const AllocatorDispatch* self,
- size_t size,
- size_t alignment,
- void* context) {
- void* const address = self->next->aligned_malloc_function(
- self->next, size, alignment, context);
-
- DoNotifyAllocation(address, size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void* AlignedReallocFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- size_t alignment,
- void* context) {
- // Note: size == 0 actually performs free.
- DoNotifyFree(address);
- address = self->next->aligned_realloc_function(self->next, address, size,
- alignment, context);
-
- DoNotifyAllocation(address, size, AllocationSubsystem::kAllocatorShim);
-
- return address;
- }
-
- static void AlignedFreeFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- DoNotifyFree(address);
- self->next->aligned_free_function(self->next, address, context);
- }
-
- static AllocatorDispatch allocator_dispatch_;
-#endif
-
- ALWAYS_INLINE static void DoNotifyAllocation(
- void* address,
- size_t size,
- AllocationSubsystem subSystem,
- const char* type_name = nullptr) {
- PerformAllocationNotification(s_observers, AllObservers{}, address, size,
- subSystem, type_name);
- }
-
- ALWAYS_INLINE static void DoNotifyFree(void* address) {
- PerformFreeNotification(s_observers, AllObservers{}, address);
- }
-
- static std::tuple<ObserverTypes*...> s_observers;
-};
-
-template <typename... ObserverTypes>
-std::tuple<ObserverTypes*...> DispatcherImpl<ObserverTypes...>::s_observers;
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-template <typename... ObserverTypes>
-AllocatorDispatch DispatcherImpl<ObserverTypes...>::allocator_dispatch_ = {
- &AllocFn,
- &AllocUncheckedFn,
- &AllocZeroInitializedFn,
- &AllocAlignedFn,
- &ReallocFn,
- &FreeFn,
- &GetSizeEstimateFn,
- &ClaimedAddressFn,
- &BatchMallocFn,
- &BatchFreeFn,
- &FreeDefiniteSizeFn,
- &TryFreeDefaultFn,
- &AlignedMallocFn,
- &AlignedReallocFn,
- &AlignedFreeFn,
- nullptr};
-#endif
-
-// Specialization of DispatcherImpl in case we have no observers to notify. In
-// this special case we return a set of null pointers as the Dispatcher must not
-// install any hooks at all.
-template <>
-struct DispatcherImpl<> {
- static DispatchData GetNotificationHooks(std::tuple<> /*observers*/) {
- return DispatchData()
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- .SetAllocationObserverHooks(nullptr, nullptr)
-#endif
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- .SetAllocatorDispatch(nullptr)
-#endif
- ;
- }
-};
-
-// A little utility function that helps using DispatcherImpl by providing
-// automated type deduction for templates.
-template <typename... ObserverTypes>
-inline DispatchData GetNotificationHooks(
- std::tuple<ObserverTypes*...> observers) {
- return DispatcherImpl<ObserverTypes...>::GetNotificationHooks(
- std::move(observers));
-}
-
-} // namespace base::allocator::dispatcher::internal
-
-#endif // BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCHER_INTERNAL_H_
diff --git a/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc b/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc
deleted file mode 100644
index 4119b22..0000000
--- a/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc
+++ /dev/null
@@ -1,550 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/internal/dispatcher_internal.h"
-#include "base/allocator/buildflags.h"
-#include "base/allocator/dispatcher/testing/dispatcher_test.h"
-#include "base/allocator/dispatcher/testing/observer_mock.h"
-#include "base/allocator/dispatcher/testing/tools.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/dcheck_is_on.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#include <tuple>
-#include <utility>
-
-using ::base::allocator::dispatcher::configuration::kMaximumNumberOfObservers;
-using ::base::allocator::dispatcher::testing::CreateTupleOfPointers;
-using ::base::allocator::dispatcher::testing::DispatcherTest;
-using ::testing::_;
-using ::testing::InSequence;
-
-namespace base::allocator::dispatcher::internal {
-
-namespace {
-
-struct AllocationEventDispatcherInternalTest : public DispatcherTest {
- static void* GetAllocatedAddress() {
- return reinterpret_cast<void*>(0x12345678);
- }
- static unsigned int GetAllocatedSize() { return 35; }
- static unsigned int GetEstimatedSize() { return 77; }
- static void* GetFreedAddress() {
- return reinterpret_cast<void*>(0x876543210);
- }
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- AllocatorDispatch* GetNextAllocatorDispatch() { return &allocator_dispatch_; }
- static void* alloc_function(const AllocatorDispatch*, size_t, void*) {
- return GetAllocatedAddress();
- }
- static void* alloc_unchecked_function(const AllocatorDispatch*,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
- static void* alloc_zero_initialized_function(const AllocatorDispatch*,
- size_t,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
- static void* alloc_aligned_function(const AllocatorDispatch*,
- size_t,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
- static void* realloc_function(const AllocatorDispatch*,
- void*,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
- static size_t get_size_estimate_function(const AllocatorDispatch*,
- void*,
- void*) {
- return GetEstimatedSize();
- }
- static bool claimed_address_function(const AllocatorDispatch*, void*, void*) {
- return GetEstimatedSize();
- }
- static unsigned batch_malloc_function(const AllocatorDispatch*,
- size_t,
- void**,
- unsigned num_requested,
- void*) {
- return num_requested;
- }
- static void* aligned_malloc_function(const AllocatorDispatch*,
- size_t,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
- static void* aligned_realloc_function(const AllocatorDispatch*,
- void*,
- size_t,
- size_t,
- void*) {
- return GetAllocatedAddress();
- }
-
- AllocatorDispatch allocator_dispatch_ = {
- &alloc_function,
- &alloc_unchecked_function,
- &alloc_zero_initialized_function,
- &alloc_aligned_function,
- &realloc_function,
- [](const AllocatorDispatch*, void*, void*) {},
- &get_size_estimate_function,
- &claimed_address_function,
- &batch_malloc_function,
- [](const AllocatorDispatch*, void**, unsigned, void*) {},
- [](const AllocatorDispatch*, void*, size_t, void*) {},
- [](const AllocatorDispatch*, void*, void*) {},
- &aligned_malloc_function,
- &aligned_realloc_function,
- [](const AllocatorDispatch*, void*, void*) {}};
-#endif
-};
-
-} // namespace
-
-using ::testing::NaggyMock;
-using ::testing::StrictMock;
-
-using ObserverMock = StrictMock<testing::ObserverMock<>>;
-
-#if defined(GTEST_HAS_DEATH_TEST) && GTEST_HAS_DEATH_TEST && DCHECK_IS_ON()
-TEST(AllocationEventDispatcherInternalDeathTest,
- VerifyDeathWhenObserverIsNull) {
- testing::ObserverMock<int> observer_1;
- testing::ObserverMock<float> observer_2;
- testing::ObserverMock<size_t>* null_observer = nullptr;
- testing::ObserverMock<double> observer_3;
-
- const auto observer_ptrs =
- std::make_tuple(&observer_1, &observer_2, null_observer, &observer_3);
-
- EXPECT_DEATH({ GetNotificationHooks(observer_ptrs); }, "");
-}
-#endif // defined(GTEST_HAS_DEATH_TEST) && GTEST_HAS_DEATH_TEST &&
- // DCHECK_IS_ON()
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyPartitionAllocatorHooksAreSet) {
- std::array<ObserverMock, 1> observers;
-
- const auto dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- EXPECT_NE(nullptr, dispatch_data.GetAllocationObserverHook());
- EXPECT_NE(nullptr, dispatch_data.GetFreeObserverHook());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyPartitionAllocatorHooksAreNullWhenNoObservers) {
- const auto dispatch_data = GetNotificationHooks(std::make_tuple());
-
- EXPECT_EQ(nullptr, dispatch_data.GetAllocationObserverHook());
- EXPECT_EQ(nullptr, dispatch_data.GetFreeObserverHook());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyPartitionAllocatorAllocationHooksTriggerCorrectly) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnAllocation(this, sizeof(*this), _, _)).Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- const auto dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- dispatch_data.GetAllocationObserverHook()(this, sizeof(*this), nullptr);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyPartitionAllocatorFreeHooksTriggerCorrectly) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- EXPECT_CALL(mock, OnFree(this)).Times(1);
- }
-
- const auto dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- dispatch_data.GetFreeObserverHook()(this);
-}
-#endif
-
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-TEST_F(AllocationEventDispatcherInternalTest, VerifyAllocatorShimDataIsSet) {
- std::array<ObserverMock, 1> observers;
-
- const auto dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
- const auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- EXPECT_NE(nullptr, allocator_dispatch);
- EXPECT_NE(nullptr, allocator_dispatch->alloc_function);
- EXPECT_NE(nullptr, allocator_dispatch->alloc_unchecked_function);
- EXPECT_NE(nullptr, allocator_dispatch->alloc_zero_initialized_function);
- EXPECT_NE(nullptr, allocator_dispatch->alloc_aligned_function);
- EXPECT_NE(nullptr, allocator_dispatch->realloc_function);
- EXPECT_NE(nullptr, allocator_dispatch->free_function);
- EXPECT_NE(nullptr, allocator_dispatch->get_size_estimate_function);
- EXPECT_NE(nullptr, allocator_dispatch->claimed_address_function);
- EXPECT_NE(nullptr, allocator_dispatch->batch_malloc_function);
- EXPECT_NE(nullptr, allocator_dispatch->batch_free_function);
- EXPECT_NE(nullptr, allocator_dispatch->free_definite_size_function);
- EXPECT_NE(nullptr, allocator_dispatch->try_free_default_function);
- EXPECT_NE(nullptr, allocator_dispatch->aligned_malloc_function);
- EXPECT_NE(nullptr, allocator_dispatch->aligned_realloc_function);
- EXPECT_NE(nullptr, allocator_dispatch->aligned_free_function);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimDataIsNullWhenNoObservers) {
- const auto dispatch_data = GetNotificationHooks(std::make_tuple());
-
- EXPECT_EQ(nullptr, dispatch_data.GetAllocatorDispatch());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_alloc_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->alloc_function(
- allocator_dispatch, GetAllocatedSize(), nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_alloc_unchecked_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->alloc_unchecked_function(
- allocator_dispatch, GetAllocatedSize(), nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(
- AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_alloc_zero_initialized_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
- constexpr int n = 8;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock,
- OnAllocation(GetAllocatedAddress(), n * GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address =
- allocator_dispatch->alloc_zero_initialized_function(
- allocator_dispatch, n, GetAllocatedSize(), nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_alloc_aligned_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->alloc_aligned_function(
- allocator_dispatch, 2048, GetAllocatedSize(), nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_realloc_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- InSequence execution_order;
-
- EXPECT_CALL(mock, OnFree(GetFreedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->realloc_function(
- allocator_dispatch, GetFreedAddress(), GetAllocatedSize(), nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_free_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(GetFreedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- allocator_dispatch->free_function(allocator_dispatch, GetFreedAddress(),
- nullptr);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_get_size_estimate_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto const estimated_size = allocator_dispatch->get_size_estimate_function(
- allocator_dispatch, GetAllocatedAddress(), nullptr);
-
- EXPECT_EQ(estimated_size, GetEstimatedSize());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_batch_malloc_function) {
- constexpr size_t allocation_batch_size = 10;
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
- std::array<void*, allocation_batch_size> allocation_batch = {nullptr};
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- EXPECT_CALL(mock, OnAllocation(nullptr, GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(allocation_batch_size);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- EXPECT_NE(allocator_dispatch->batch_malloc_function, nullptr);
-
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto const number_allocated = allocator_dispatch->batch_malloc_function(
- allocator_dispatch, GetAllocatedSize(), allocation_batch.data(),
- allocation_batch_size, nullptr);
-
- EXPECT_EQ(number_allocated, allocation_batch_size);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_batch_free_function) {
- constexpr size_t allocation_batch_size = 10;
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
- std::array<void*, allocation_batch_size> allocation_batch;
- allocation_batch.fill(GetFreedAddress());
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(GetFreedAddress())).Times(allocation_batch_size);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- EXPECT_NE(allocator_dispatch->batch_free_function, nullptr);
-
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- allocator_dispatch->batch_free_function(allocator_dispatch,
- allocation_batch.data(),
- allocation_batch_size, nullptr);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_free_definite_size_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(GetAllocatedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- DispatchData const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- EXPECT_NE(allocator_dispatch->free_definite_size_function, nullptr);
-
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- allocator_dispatch->free_definite_size_function(
- allocator_dispatch, GetAllocatedAddress(), GetAllocatedSize(), nullptr);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_try_free_default_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(GetAllocatedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- DispatchData const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- EXPECT_NE(allocator_dispatch->try_free_default_function, nullptr);
-
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- allocator_dispatch->try_free_default_function(allocator_dispatch,
- GetAllocatedAddress(), nullptr);
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_aligned_malloc_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- EXPECT_CALL(mock, OnFree(_)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->aligned_malloc_function(
- allocator_dispatch, GetAllocatedSize(), 2048, nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_aligned_realloc_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- InSequence execution_order;
-
- EXPECT_CALL(mock, OnFree(GetFreedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(GetAllocatedAddress(), GetAllocatedSize(),
- AllocationSubsystem::kAllocatorShim, _))
- .Times(1);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- auto* const allocated_address = allocator_dispatch->aligned_realloc_function(
- allocator_dispatch, GetFreedAddress(), GetAllocatedSize(), 2048, nullptr);
-
- EXPECT_EQ(allocated_address, GetAllocatedAddress());
-}
-
-TEST_F(AllocationEventDispatcherInternalTest,
- VerifyAllocatorShimHooksTriggerCorrectly_aligned_free_function) {
- std::array<ObserverMock, kMaximumNumberOfObservers> observers;
-
- for (auto& mock : observers) {
- EXPECT_CALL(mock, OnFree(GetFreedAddress())).Times(1);
- EXPECT_CALL(mock, OnAllocation(_, _, _, _)).Times(0);
- }
-
- auto const dispatch_data =
- GetNotificationHooks(CreateTupleOfPointers(observers));
-
- auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch();
- allocator_dispatch->next = GetNextAllocatorDispatch();
-
- allocator_dispatch->aligned_free_function(allocator_dispatch,
- GetFreedAddress(), nullptr);
-}
-
-#endif
-} // namespace base::allocator::dispatcher::internal
diff --git a/base/allocator/dispatcher/internal/tools.h b/base/allocator/dispatcher/internal/tools.h
deleted file mode 100644
index e270f48..0000000
--- a/base/allocator/dispatcher/internal/tools.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_INTERNAL_TOOLS_H_
-#define BASE_ALLOCATOR_DISPATCHER_INTERNAL_TOOLS_H_
-
-#include <cstddef>
-
-namespace base::allocator::dispatcher::internal {
-
-constexpr bool LessEqual(size_t lhs, size_t rhs) {
- return lhs <= rhs;
-}
-
-constexpr bool Equal(size_t lhs, size_t rhs) {
- return lhs == rhs;
-}
-
-struct IsValidObserver {
- template <typename T>
- constexpr bool operator()(T const* ptr) const noexcept {
- return ptr != nullptr;
- }
-};
-
-} // namespace base::allocator::dispatcher::internal
-
-#endif // BASE_ALLOCATOR_DISPATCHER_INTERNAL_DISPATCHER_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/reentry_guard.cc b/base/allocator/dispatcher/reentry_guard.cc
deleted file mode 100644
index 92a526a..0000000
--- a/base/allocator/dispatcher/reentry_guard.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/reentry_guard.h"
-
-#include "base/check.h"
-#include "base/compiler_specific.h"
-#include "base/debug/crash_logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
-#include <pthread.h>
-#endif
-
-namespace base::allocator::dispatcher {
-
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
-// pthread_key_t has different signedness on Mac and Android. Store the null
-// value in a strongly-typed constant to avoid "comparison of integers of
-// different signs" warnings when comparing with 0.
-constexpr pthread_key_t kNullKey = 0;
-
-pthread_key_t ReentryGuard::entered_key_ = kNullKey;
-
-void ReentryGuard::InitTLSSlot() {
- if (entered_key_ == kNullKey) {
- int error = pthread_key_create(&entered_key_, nullptr);
- CHECK(!error);
- // Touch the TLS slot immediately to force any allocations.
- // TODO(https://crbug.com/1411454): Use this technique to avoid allocations
- // in PoissonAllocationSampler::ScopedMuteThreadSamples, which will make
- // ReentryGuard redundant.
- pthread_setspecific(entered_key_, nullptr);
- }
-
- DCHECK_NE(entered_key_, kNullKey);
-}
-
-#else
-
-void ReentryGuard::InitTLSSlot() {}
-
-#endif
-
-void ReentryGuard::RecordTLSSlotToCrashKey() {
- // Record the key in crash dumps to detect when it's higher than 32
- // (PTHREAD_KEY_2NDLEVEL_SIZE).
- // TODO(crbug.com/1411454): Remove this after diagnosing reentry crashes.
- static auto* const crash_key = base::debug::AllocateCrashKeyString(
- "reentry_guard_tls_slot", base::debug::CrashKeySize::Size32);
-
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
- base::debug::SetCrashKeyString(crash_key, base::NumberToString(entered_key_));
-#else
- base::debug::SetCrashKeyString(crash_key, "unused");
-#endif
-}
-
-} // namespace base::allocator::dispatcher
diff --git a/base/allocator/dispatcher/reentry_guard.h b/base/allocator/dispatcher/reentry_guard.h
deleted file mode 100644
index 986cfd2..0000000
--- a/base/allocator/dispatcher/reentry_guard.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_REENTRY_GUARD_H_
-#define BASE_ALLOCATOR_DISPATCHER_REENTRY_GUARD_H_
-
-#include "base/base_export.h"
-#include "base/check.h"
-#include "base/compiler_specific.h"
-#include "build/build_config.h"
-
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
-#include <pthread.h>
-#endif
-
-namespace base::allocator::dispatcher {
-
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
-
-// The macOS implementation of libmalloc sometimes calls malloc recursively,
-// delegating allocations between zones. That causes our hooks being called
-// twice. The scoped guard allows us to detect that.
-//
-// Besides that the implementations of thread_local on macOS and Android
-// seem to allocate memory lazily on the first access to thread_local variables
-// (and on Android at least thread_local is implemented on top of pthread so is
-// strictly worse for performance). Make use of pthread TLS instead of C++
-// thread_local there.
-struct BASE_EXPORT ReentryGuard {
- ALWAYS_INLINE ReentryGuard() : allowed_(!pthread_getspecific(entered_key_)) {
- pthread_setspecific(entered_key_, reinterpret_cast<void*>(true));
- }
-
- ALWAYS_INLINE ~ReentryGuard() {
- if (LIKELY(allowed_))
- pthread_setspecific(entered_key_, nullptr);
- }
-
- explicit operator bool() const noexcept { return allowed_; }
-
- // This function must be called before installing any allocator hooks because
- // some TLS implementations may allocate (eg. glibc will require a malloc call
- // to allocate storage for a higher slot number (>= PTHREAD_KEY_2NDLEVEL_SIZE
- // == 32). This touches the thread-local storage so that any malloc happens
- // before installing the hooks.
- static void InitTLSSlot();
-
- // InitTLSSlot() is called before crash keys are available. At some point
- // after SetCrashKeyImplementation() is called, this function should be
- // called to record `entered_key_` to a crash key for debugging. This may
- // allocate so it must not be called from inside an allocator hook.
- static void RecordTLSSlotToCrashKey();
-
- private:
- static pthread_key_t entered_key_;
- const bool allowed_;
-};
-
-#else
-
-// Use [[maybe_unused]] as this lightweight stand-in for the more heavyweight
-// ReentryGuard above will otherwise trigger the "unused code" warnings.
-struct [[maybe_unused]] BASE_EXPORT ReentryGuard {
- constexpr explicit operator bool() const noexcept { return true; }
-
- static void InitTLSSlot();
- static void RecordTLSSlotToCrashKey();
-};
-
-#endif
-
-} // namespace base::allocator::dispatcher
-
-#endif // BASE_ALLOCATOR_DISPATCHER_REENTRY_GUARD_H_
diff --git a/base/allocator/dispatcher/standard_hooks.cc b/base/allocator/dispatcher/standard_hooks.cc
deleted file mode 100644
index 2d29d08..0000000
--- a/base/allocator/dispatcher/standard_hooks.cc
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/standard_hooks.h"
-
-#include "base/allocator/buildflags.h"
-#include "base/allocator/partition_allocator/partition_alloc.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#include "base/sampling_heap_profiler/poisson_allocation_sampler.h"
-
-#if !BUILDFLAG(USE_ALLOCATION_EVENT_DISPATCHER)
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
-namespace base::allocator::dispatcher::allocator_shim_details {
-namespace {
-
-using allocator_shim::AllocatorDispatch;
-
-void* AllocFn(const AllocatorDispatch* self, size_t size, void* context) {
- void* address = self->next->alloc_function(self->next, size, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-void* AllocUncheckedFn(const AllocatorDispatch* self,
- size_t size,
- void* context) {
- void* address =
- self->next->alloc_unchecked_function(self->next, size, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-void* AllocZeroInitializedFn(const AllocatorDispatch* self,
- size_t n,
- size_t size,
- void* context) {
- void* address =
- self->next->alloc_zero_initialized_function(self->next, n, size, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, n * size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-void* AllocAlignedFn(const AllocatorDispatch* self,
- size_t alignment,
- size_t size,
- void* context) {
- void* address =
- self->next->alloc_aligned_function(self->next, alignment, size, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-void* ReallocFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- void* context) {
- // Note: size == 0 actually performs free.
- PoissonAllocationSampler::RecordFree(address);
- address = self->next->realloc_function(self->next, address, size, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-void FreeFn(const AllocatorDispatch* self, void* address, void* context) {
- // Note: The RecordFree should be called before free_function
- // (here and in other places).
- // That is because we need to remove the recorded allocation sample before
- // free_function, as once the latter is executed the address becomes available
- // and can be allocated by another thread. That would be racy otherwise.
- PoissonAllocationSampler::RecordFree(address);
- self->next->free_function(self->next, address, context);
-}
-
-size_t GetSizeEstimateFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- return self->next->get_size_estimate_function(self->next, address, context);
-}
-
-bool ClaimedAddressFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- return self->next->claimed_address_function(self->next, address, context);
-}
-
-unsigned BatchMallocFn(const AllocatorDispatch* self,
- size_t size,
- void** results,
- unsigned num_requested,
- void* context) {
- unsigned num_allocated = self->next->batch_malloc_function(
- self->next, size, results, num_requested, context);
-
- for (unsigned i = 0; i < num_allocated; ++i) {
- PoissonAllocationSampler::RecordAlloc(
- results[i], size, AllocationSubsystem::kAllocatorShim, nullptr);
- }
-
- return num_allocated;
-}
-
-void BatchFreeFn(const AllocatorDispatch* self,
- void** to_be_freed,
- unsigned num_to_be_freed,
- void* context) {
- for (unsigned i = 0; i < num_to_be_freed; ++i) {
- PoissonAllocationSampler::RecordFree(to_be_freed[i]);
- }
-
- self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed,
- context);
-}
-
-void FreeDefiniteSizeFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- void* context) {
- PoissonAllocationSampler::RecordFree(address);
- self->next->free_definite_size_function(self->next, address, size, context);
-}
-
-void TryFreeDefaultFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- PoissonAllocationSampler::RecordFree(address);
- self->next->try_free_default_function(self->next, address, context);
-}
-
-static void* AlignedMallocFn(const AllocatorDispatch* self,
- size_t size,
- size_t alignment,
- void* context) {
- void* address =
- self->next->aligned_malloc_function(self->next, size, alignment, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-static void* AlignedReallocFn(const AllocatorDispatch* self,
- void* address,
- size_t size,
- size_t alignment,
- void* context) {
- // Note: size == 0 actually performs free.
- PoissonAllocationSampler::RecordFree(address);
- address = self->next->aligned_realloc_function(self->next, address, size,
- alignment, context);
-
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kAllocatorShim, nullptr);
-
- return address;
-}
-
-static void AlignedFreeFn(const AllocatorDispatch* self,
- void* address,
- void* context) {
- PoissonAllocationSampler::RecordFree(address);
- self->next->aligned_free_function(self->next, address, context);
-}
-
-AllocatorDispatch g_allocator_dispatch = {&AllocFn,
- &AllocUncheckedFn,
- &AllocZeroInitializedFn,
- &AllocAlignedFn,
- &ReallocFn,
- &FreeFn,
- &GetSizeEstimateFn,
- &ClaimedAddressFn,
- &BatchMallocFn,
- &BatchFreeFn,
- &FreeDefiniteSizeFn,
- &TryFreeDefaultFn,
- &AlignedMallocFn,
- &AlignedReallocFn,
- &AlignedFreeFn,
- nullptr};
-
-} // namespace
-} // namespace base::allocator::dispatcher::allocator_shim_details
-#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
-namespace base::allocator::dispatcher::partition_allocator_details {
-namespace {
-
-void PartitionAllocHook(void* address, size_t size, const char* type) {
- PoissonAllocationSampler::RecordAlloc(
- address, size, AllocationSubsystem::kPartitionAllocator, type);
-}
-
-void PartitionFreeHook(void* address) {
- PoissonAllocationSampler::RecordFree(address);
-}
-
-} // namespace
-} // namespace base::allocator::dispatcher::partition_allocator_details
-#endif // BUILDFLAG(USE_PARTITION_ALLOC)
-#endif // !BUILDFLAG(USE_ALLOCATION_EVENT_DISPATCHER)
-
-namespace base::allocator::dispatcher {
-
-#if !BUILDFLAG(USE_ALLOCATION_EVENT_DISPATCHER)
-void InstallStandardAllocatorHooks() {
-#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- allocator_shim::InsertAllocatorDispatch(
- &allocator_shim_details::g_allocator_dispatch);
-#else
- // If the allocator shim isn't available, then we don't install any hooks.
- // There's no point in printing an error message, since this can regularly
- // happen for tests.
-#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC)
- partition_alloc::PartitionAllocHooks::SetObserverHooks(
- &partition_allocator_details::PartitionAllocHook,
- &partition_allocator_details::PartitionFreeHook);
-#endif // BUILDFLAG(USE_PARTITION_ALLOC)
-}
-#endif // !BUILDFLAG(USE_ALLOCATION_EVENT_DISPATCHER)
-
-} // namespace base::allocator::dispatcher
diff --git a/base/allocator/dispatcher/standard_hooks.h b/base/allocator/dispatcher/standard_hooks.h
deleted file mode 100644
index a933fa4..0000000
--- a/base/allocator/dispatcher/standard_hooks.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_STANDARD_HOOKS_H_
-#define BASE_ALLOCATOR_DISPATCHER_STANDARD_HOOKS_H_
-
-// This file and its cc file contain the standard allocation hooks and auxiliary
-// functions. These are intended to be replaced by the new dispatcher mechanism
-// in /base/allocator/dispatcher.
-
-#include "base/allocator/buildflags.h"
-#include "base/base_export.h"
-
-namespace base::allocator::dispatcher {
-
-#if !BUILDFLAG(USE_ALLOCATION_EVENT_DISPATCHER)
-// Install the standard allocation hooks which forward allocation events to the
-// PoissonAllocationSampler.
-void BASE_EXPORT InstallStandardAllocatorHooks();
-#endif
-
-} // namespace base::allocator::dispatcher
-
-#endif // BASE_ALLOCATOR_DISPATCHER_STANDARD_HOOKS_H_
diff --git a/base/allocator/dispatcher/subsystem.h b/base/allocator/dispatcher/subsystem.h
deleted file mode 100644
index 163961e..0000000
--- a/base/allocator/dispatcher/subsystem.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_SUBSYSTEM_H_
-#define BASE_ALLOCATOR_DISPATCHER_SUBSYSTEM_H_
-
-namespace base::allocator::dispatcher {
-
-// Identifiers for the memory subsystem handling the allocation. Some observers
-// require more detailed information on who is performing the allocation, i.e.
-// SamplingHeapProfiler.
-enum class AllocationSubsystem {
- // Allocation is handled by PartitionAllocator.
- kPartitionAllocator = 1,
- // Allocation is handled by AllocatorShims.
- kAllocatorShim = 2,
- // Represents a simulated allocation event during testing and is used to
- // filter out these allocations from real ones.
- //
- // Included for backward compatibility, this value becomes obsolete once the
- // old allocation hooks are removed from PoissonAllocationSampler.
- kManualForTesting = 3,
-};
-} // namespace base::allocator::dispatcher
-
-#endif // BASE_ALLOCATOR_DISPATCHER_SUBSYSTEM_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/testing/dispatcher_test.cc b/base/allocator/dispatcher/testing/dispatcher_test.cc
deleted file mode 100644
index 9efa5c5..0000000
--- a/base/allocator/dispatcher/testing/dispatcher_test.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/testing/dispatcher_test.h"
-#include "base/allocator/dispatcher/reentry_guard.h"
-
-namespace base::allocator::dispatcher::testing {
-
-DispatcherTest::DispatcherTest() {
- base::allocator::dispatcher::ReentryGuard::InitTLSSlot();
-}
-
-DispatcherTest::~DispatcherTest() = default;
-
-} // namespace base::allocator::dispatcher::testing
\ No newline at end of file
diff --git a/base/allocator/dispatcher/testing/dispatcher_test.h b/base/allocator/dispatcher/testing/dispatcher_test.h
deleted file mode 100644
index 21fbd1a..0000000
--- a/base/allocator/dispatcher/testing/dispatcher_test.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_TESTING_DISPATCHER_TEST_H_
-#define BASE_ALLOCATOR_DISPATCHER_TESTING_DISPATCHER_TEST_H_
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace base::allocator::dispatcher::testing {
-
-// DispatcherTest provides some common initialization which most of the
-// unittests of the dispatcher require. DispatcherTest should not be used
-// directly. Instead, derive your test fixture from it.
-struct DispatcherTest : public ::testing::Test {
- // Perform some commonly required initialization, at them moment
- // - Initialize the TLS slot for the ReentryGuard
- DispatcherTest();
-
- protected:
- // Protected d'tor only to prevent direct usage of this class.
- ~DispatcherTest() override;
-};
-
-} // namespace base::allocator::dispatcher::testing
-
-#endif // BASE_ALLOCATOR_DISPATCHER_TESTING_DISPATCHER_TEST_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/testing/observer_mock.h b/base/allocator/dispatcher/testing/observer_mock.h
deleted file mode 100644
index b016aed..0000000
--- a/base/allocator/dispatcher/testing/observer_mock.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_
-#define BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_
-
-#include "base/allocator/dispatcher/subsystem.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-#include <cstddef>
-
-namespace base::allocator::dispatcher::testing {
-
-// ObserverMock is a small mock class based on GoogleMock.
-// It complies to the interface enforced by the dispatcher. The template
-// parameter serves only to create distinct types of observers if required.
-template <typename T = void>
-struct ObserverMock {
- MOCK_METHOD(void,
- OnAllocation,
- (void* address,
- size_t size,
- AllocationSubsystem sub_system,
- const char* type_name),
- ());
- MOCK_METHOD(void, OnFree, (void* address), ());
-};
-
-} // namespace base::allocator::dispatcher::testing
-
-#endif // BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_
\ No newline at end of file
diff --git a/base/allocator/dispatcher/testing/tools.h b/base/allocator/dispatcher/testing/tools.h
deleted file mode 100644
index 4eb6fcd..0000000
--- a/base/allocator/dispatcher/testing/tools.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_TESTING_TOOLS_H_
-#define BASE_ALLOCATOR_DISPATCHER_TESTING_TOOLS_H_
-
-#include <array>
-#include <tuple>
-#include <utility>
-
-namespace base::allocator::dispatcher::testing {
-
-namespace internal {
-template <size_t Size, typename Type, typename... AppendedTypes>
-struct DefineTupleFromSingleType {
- using type = typename DefineTupleFromSingleType<Size - 1,
- Type,
- AppendedTypes...,
- Type>::type;
-};
-
-template <typename Type, typename... AppendedTypes>
-struct DefineTupleFromSingleType<0, Type, AppendedTypes...> {
- using type = std::tuple<AppendedTypes...>;
-};
-
-} // namespace internal
-
-template <size_t Size, typename Type>
-struct DefineTupleFromSingleType {
- using type = typename internal::DefineTupleFromSingleType<Size, Type>::type;
-};
-
-template <typename Type, size_t Size, size_t... Indices>
-typename internal::DefineTupleFromSingleType<Size, Type*>::type
-CreateTupleOfPointers(std::array<Type, Size>& items,
- std::index_sequence<Indices...>) {
- return std::make_tuple((&items[Indices])...);
-}
-
-template <typename Type, size_t Size>
-typename internal::DefineTupleFromSingleType<Size, Type*>::type
-CreateTupleOfPointers(std::array<Type, Size>& items) {
- return CreateTupleOfPointers(items, std::make_index_sequence<Size>{});
-}
-
-} // namespace base::allocator::dispatcher::testing
-
-#endif
diff --git a/base/allocator/dispatcher/tls.cc b/base/allocator/dispatcher/tls.cc
deleted file mode 100644
index 6524810..0000000
--- a/base/allocator/dispatcher/tls.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/tls.h"
-
-#if USE_LOCAL_TLS_EMULATION()
-
-#include "base/check.h"
-#include "base/dcheck_is_on.h"
-#include "base/immediate_crash.h"
-#include "build/build_config.h"
-
-#include <sys/mman.h>
-
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX)
-#include <sys/prctl.h>
-#endif
-
-namespace base::allocator::dispatcher::internal {
-
-void* MMapAllocator::AllocateMemory(size_t size_in_bytes) {
- void* const mmap_res = mmap(nullptr, size_in_bytes, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX)
-#if defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
- if (mmap_res != MAP_FAILED) {
- // Allow the anonymous memory region allocated by mmap(MAP_ANONYMOUS) to
- // be identified in /proc/$PID/smaps. This helps improve visibility into
- // Chromium's memory usage on Android.
- prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, mmap_res, size_in_bytes,
- "tls-mmap-allocator");
- }
-#endif
-#endif
-
- return (mmap_res != MAP_FAILED) ? mmap_res : nullptr;
-}
-
-bool MMapAllocator::FreeMemoryForTesting(void* pointer_to_allocated,
- size_t size_in_bytes) {
- auto const munmap_res = munmap(pointer_to_allocated, size_in_bytes);
- return (munmap_res == 0);
-}
-
-bool PThreadTLSSystem::Setup(
- OnThreadTerminationFunction thread_termination_function) {
-#if DCHECK_IS_ON()
- // Initialize must happen outside of the allocation path. Therefore, it is
- // secure to verify with DCHECK.
- DCHECK(!initialized_.exchange(true, std::memory_order_acq_rel));
-#endif
-
- auto const key_create_res =
- pthread_key_create(&data_access_key_, thread_termination_function);
-
- // On some platforms creating a new pthread-key requires an allocation when a
- // given number of keys has been created. I.e. in glibc this limit is denoted
- // by PTHREAD_KEY_2NDLEVEL_SIZE. However, this value is neither present on all
- // systems nor accessible from here. Hence, we do not do any checks here.
- // However, we strongly recommend to setup the TLS system as early as possible
- // to avoid exceeding this limit.
-
- return (0 == key_create_res);
-}
-
-bool PThreadTLSSystem::TearDownForTesting() {
-#if DCHECK_IS_ON()
- // TearDownForTesting must happen outside of the allocation path. Therefore,
- // it is secure to verify with DCHECK.
- DCHECK(initialized_.exchange(false, std::memory_order_acq_rel));
-#endif
-
- auto const key_delete_res = pthread_key_delete(data_access_key_);
- return (0 == key_delete_res);
-}
-
-void* PThreadTLSSystem::GetThreadSpecificData() {
-#if DCHECK_IS_ON()
- if (!initialized_.load(std::memory_order_acquire)) {
- return nullptr;
- }
-#endif
-
- return pthread_getspecific(data_access_key_);
-}
-
-bool PThreadTLSSystem::SetThreadSpecificData(void* data) {
-#if DCHECK_IS_ON()
- if (!initialized_.load(std::memory_order_acquire)) {
- return false;
- }
-#endif
-
- return (0 == pthread_setspecific(data_access_key_, data));
-}
-
-} // namespace base::allocator::dispatcher::internal
-
-#endif // USE_LOCAL_TLS_EMULATION()
diff --git a/base/allocator/dispatcher/tls.h b/base/allocator/dispatcher/tls.h
deleted file mode 100644
index 9d49187..0000000
--- a/base/allocator/dispatcher/tls.h
+++ /dev/null
@@ -1,432 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_DISPATCHER_TLS_H_
-#define BASE_ALLOCATOR_DISPATCHER_TLS_H_
-
-#include "build/build_config.h"
-
-#if BUILDFLAG(IS_POSIX) // the current allocation mechanism (mmap) and TLS
- // support (pthread) are both defined by POSIX
-#define USE_LOCAL_TLS_EMULATION() true
-#else
-#define USE_LOCAL_TLS_EMULATION() false
-#endif
-
-#if USE_LOCAL_TLS_EMULATION()
-#include <algorithm>
-#include <atomic>
-#include <memory>
-#include <mutex>
-
-#include "base/allocator/partition_allocator/partition_alloc_constants.h"
-#include "base/base_export.h"
-#include "base/check.h"
-#include "base/compiler_specific.h"
-
-#include <pthread.h>
-
-#if HAS_FEATURE(thread_sanitizer)
-#define DISABLE_TSAN_INSTRUMENTATION __attribute__((no_sanitize("thread")))
-#else
-#define DISABLE_TSAN_INSTRUMENTATION
-#endif
-
-namespace base::allocator::dispatcher {
-namespace internal {
-
-// Allocate memory using POSIX' mmap and unmap functionality. The allocator
-// implements the allocator interface required by ThreadLocalStorage.
-struct BASE_EXPORT MMapAllocator {
-// The minimum size of a memory chunk when allocating. Even for chunks with
-// fewer bytes, at least AllocationChunkSize bytes are allocated. For mmap, this
-// is usually the page size of the system.
-// For various OS-CPU combinations, partition_alloc::PartitionPageSize() is not
-// constexpr. Hence, we can not use this value but define it locally.
-#if defined(PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR) && \
- PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR
- constexpr static size_t AllocationChunkSize =
- partition_alloc::PartitionPageSize();
-#elif BUILDFLAG(IS_APPLE)
- constexpr static size_t AllocationChunkSize = 16384;
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- constexpr static size_t AllocationChunkSize = 16384;
-#else
- constexpr static size_t AllocationChunkSize = 4096;
-#endif
-
- // Allocate size_in_bytes bytes of raw memory. Return nullptr if allocation
- // fails.
- void* AllocateMemory(size_t size_in_bytes);
- // Free the raw memory pointed to by pointer_to_allocated. Returns a boolean
- // value indicating if the free was successful.
- bool FreeMemoryForTesting(void* pointer_to_allocated, size_t size_in_bytes);
-};
-
-// The allocator used by default for the thread local storage.
-using DefaultAllocator = MMapAllocator;
-
-using OnThreadTerminationFunction = void (*)(void*);
-
-// The TLS system used by default for the thread local storage. It stores and
-// retrieves thread specific data pointers.
-struct BASE_EXPORT PThreadTLSSystem {
- // Initialize the TLS system to store a data set for different threads.
- // @param thread_termination_function An optional function which will be
- // invoked upon termination of a thread.
- bool Setup(OnThreadTerminationFunction thread_termination_function);
- // Tear down the TLS system. After completing tear down, the thread
- // termination function passed to Setup will not be invoked anymore.
- bool TearDownForTesting();
-
- // Get the pointer to the data associated to the current thread. Returns
- // nullptr if the TLS system is not initialized or no data was set before.
- void* GetThreadSpecificData();
- // Set the pointer to the data associated to the current thread. Return true
- // if stored successfully, false otherwise.
- bool SetThreadSpecificData(void* data);
-
- private:
- pthread_key_t data_access_key_ = 0;
-#if DCHECK_IS_ON()
- // From POSIX standard at https://www.open-std.org/jtc1/sc22/open/n4217.pdf:
- // The effect of calling pthread_getspecific() or pthread_setspecific() with a
- // key value not obtained from pthread_key_create() or after key has been
- // deleted with pthread_key_delete() is undefined.
- //
- // Unfortunately, POSIX doesn't define a special value of pthread_key_t
- // indicating an invalid key which would allow us to detect accesses outside
- // of initialized state. Hence, to prevent us from drifting into the evil
- // realm of undefined behaviour we store whether we're somewhere between Setup
- // and Teardown.
- std::atomic_bool initialized_{false};
-#endif
-};
-
-using DefaultTLSSystem = PThreadTLSSystem;
-
-// In some scenarios, most notably when testing, the allocator and TLS system
-// passed to |ThreadLocalStorage| are not copyable and have to be wrapped, i.e.
-// using std::reference_wrapper. |dereference| is a small helper to retrieve the
-// underlying value.
-template <typename T>
-T& dereference(T& ref) {
- return ref;
-}
-
-template <typename T>
-T& dereference(std::reference_wrapper<T>& ref) {
- // std::reference_wrapper requires a valid reference for construction,
- // therefore, no need in checking here.
- return ref.get();
-}
-
-// Store thread local data. The data is organized in chunks, where each chunk
-// holds |ItemsPerChunk|. Each item may be free or used.
-//
-// When a thread requests data, the chunks are searched for a free data item,
-// which is registered for this thread and marked as |used|. Further requests by
-// this thread will then always return the same item. When a thread terminates,
-// the item will be reset and return to the pool of free items.
-//
-// Upon construction, the first chunk is created. If a thread requests data and
-// there is no free item available, another chunk is created. Upon destruction,
-// all memory is freed. Pointers to data items become invalid!
-//
-// Constructor and destructor are not thread safe.
-//
-// @tparam PayloadType The item type to be stored.
-// @tparam AllocatorType The allocator being used. An allocator must provide
-// the following interface:
-// void* AllocateMemory(size_t size_in_bytes); // Allocate size_in_bytes bytes
-// of raw memory.
-// void FreeMemory(void* pointer_to_allocated, size_t size_in_bytes); // Free
-// the raw memory pointed to by pointer_to_allocated.
-// Any failure in allocation or free must terminate the process.
-// @tparam TLSSystemType The TLS system being used. A TLS system must provide
-// the following interface:
-// bool Setup(OnThreadTerminationFunction thread_termination_function);
-// bool Destroy();
-// void* GetThreadSpecificData();
-// bool SetThreadSpecificData(void* data);
-// @tparam AllocationChunkSize The minimum size of a memory chunk that the
-// allocator can handle. We try to size the chunks so that each chunk uses this
-// size to the maximum.
-// @tparam IsDestructibleForTesting For testing purposes we allow the destructor
-// to perform clean up upon destruction. Otherwise, using the destructor will
-// result in a compilation failure.
-template <typename PayloadType,
- typename AllocatorType,
- typename TLSSystemType,
- size_t AllocationChunkSize,
- bool IsDestructibleForTesting>
-struct ThreadLocalStorage {
- ThreadLocalStorage() : root_(AllocateAndInitializeChunk()) { Initialize(); }
-
- // Create a new instance of |ThreadLocalStorage| using the passed allocator
- // and TLS system. This initializes the underlying TLS system and creates the
- // first chunk of data.
- ThreadLocalStorage(AllocatorType allocator, TLSSystemType tlsSystem)
- : allocator_(std::move(allocator)),
- tls_system_(std::move(tlsSystem)),
- root_(AllocateAndInitializeChunk()) {
- Initialize();
- }
-
- // Deletes an instance of |ThreadLocalStorage| and delete all the data chunks
- // created.
- ~ThreadLocalStorage() {
- if constexpr (IsDestructibleForTesting) {
- TearDownForTesting();
- } else if constexpr (!IsDestructibleForTesting) {
- static_assert(
- IsDestructibleForTesting,
- "ThreadLocalStorage cannot be destructed outside of test code.");
- }
- }
-
- // Explicitly prevent all forms of Copy/Move construction/assignment. For an
- // exact copy of ThreadLocalStorage we would need to copy the mapping of
- // thread to item, which we can't do at the moment. On the other side, our
- // atomic members do not support moving out of the box.
- ThreadLocalStorage(const ThreadLocalStorage&) = delete;
- ThreadLocalStorage(ThreadLocalStorage&& other) = delete;
- ThreadLocalStorage& operator=(const ThreadLocalStorage&) = delete;
- ThreadLocalStorage& operator=(ThreadLocalStorage&&) = delete;
-
- // Get the data item for the current thread. If no data is registered so far,
- // find a free item in the chunks and register it for the current thread.
- PayloadType* GetThreadLocalData() {
- auto& tls_system = dereference(tls_system_);
-
- auto* slot = static_cast<SingleSlot*>(tls_system.GetThreadSpecificData());
-
- if (UNLIKELY(slot == nullptr)) {
- slot = FindAndAllocateFreeSlot(root_.load(std::memory_order_relaxed));
-
- // We might be called in the course of handling a memory allocation. We do
- // not use CHECK since they might allocate and cause a recursion.
- RAW_CHECK(tls_system.SetThreadSpecificData(slot));
-
- // Reset the content to wipe out any previous data.
- Reset(slot->item);
- }
-
- return &(slot->item);
- }
-
- private:
- // Encapsulate the payload item and some administrative data.
- struct SingleSlot {
- PayloadType item;
-#if !defined(__cpp_lib_atomic_value_initialization) || \
- __cpp_lib_atomic_value_initialization < 201911L
- std::atomic_flag is_used = ATOMIC_FLAG_INIT;
-#else
- std::atomic_flag is_used;
-#endif
- };
-
- template <size_t NumberOfItems>
- struct ChunkT {
- SingleSlot slots[NumberOfItems];
- // Pointer to the next chunk.
- std::atomic<ChunkT*> next_chunk = nullptr;
- // Helper flag to ensure we create the next chunk only once in a multi
- // threaded environment.
- std::once_flag create_next_chunk_flag;
- };
-
- template <size_t LowerNumberOfItems,
- size_t UpperNumberOfItems,
- size_t NumberOfBytes>
- static constexpr size_t CalculateEffectiveNumberOfItemsBinSearch() {
- if constexpr (LowerNumberOfItems == UpperNumberOfItems) {
- return LowerNumberOfItems;
- }
-
- constexpr size_t CurrentNumberOfItems =
- (UpperNumberOfItems - LowerNumberOfItems) / 2 + LowerNumberOfItems;
-
- if constexpr (sizeof(ChunkT<CurrentNumberOfItems>) > NumberOfBytes) {
- return CalculateEffectiveNumberOfItemsBinSearch<
- LowerNumberOfItems, CurrentNumberOfItems, NumberOfBytes>();
- }
-
- if constexpr (sizeof(ChunkT<CurrentNumberOfItems + 1>) < NumberOfBytes) {
- return CalculateEffectiveNumberOfItemsBinSearch<
- CurrentNumberOfItems + 1, UpperNumberOfItems, NumberOfBytes>();
- }
-
- return CurrentNumberOfItems;
- }
-
- // Calculate the maximum number of items we can store in one chunk without the
- // size of the chunk exceeding NumberOfBytes. To avoid things like alignment
- // and packing tampering with the calculation, instead of calculating the
- // correct number of items we use sizeof-operator against ChunkT to search for
- // the correct size. Unfortunately, the number of recursions is limited by the
- // compiler. Therefore, we use a binary search instead of a simple linear
- // search.
- template <size_t MinimumNumberOfItems, size_t NumberOfBytes>
- static constexpr size_t CalculateEffectiveNumberOfItems() {
- if constexpr (sizeof(ChunkT<MinimumNumberOfItems>) < NumberOfBytes) {
- constexpr size_t LowerNumberOfItems = MinimumNumberOfItems;
- constexpr size_t UpperNumberOfItems =
- NumberOfBytes / sizeof(PayloadType) + 1;
- return CalculateEffectiveNumberOfItemsBinSearch<
- LowerNumberOfItems, UpperNumberOfItems, NumberOfBytes>();
- }
-
- return MinimumNumberOfItems;
- }
-
- public:
- // The minimum number of items per chunk. It should be high enough to
- // accommodate most items in the root chunk whilst not wasting to much space
- // on unnecessary items.
- static constexpr size_t MinimumNumberOfItemsPerChunk = 75;
- // The effective number of items per chunk. We use the AllocationChunkSize as
- // a hint to calculate to effective number of items so we occupy one of these
- // memory chunks to the maximum extent possible.
- static constexpr size_t ItemsPerChunk =
- CalculateEffectiveNumberOfItems<MinimumNumberOfItemsPerChunk,
- AllocationChunkSize>();
-
- private:
- using Chunk = ChunkT<ItemsPerChunk>;
-
- static_assert(ItemsPerChunk >= MinimumNumberOfItemsPerChunk);
-
- // Mark an item's slot ready for reuse. This function is used as thread
- // termination function in the TLS system. We do not destroy anything at this
- // point but simply mark the slot as unused.
- static void MarkSlotAsFree(void* data) {
- // We always store SingleSlots in the TLS system. Therefore, we cast to
- // SingleSlot and reset the is_used flag.
- auto* const slot = static_cast<SingleSlot*>(data);
-
- // We might be called in the course of handling a memory allocation. We do
- // not use CHECK since they might allocate and cause a recursion.
- RAW_CHECK(slot && slot->is_used.test_and_set());
-
- slot->is_used.clear(std::memory_order_relaxed);
- }
-
- // Perform common initialization during construction of an instance.
- void Initialize() {
- // The constructor must be called outside of the allocation path. Therefore,
- // it is secure to verify with CHECK.
-
- // Passing MarkSlotAsFree as thread_termination_function we ensure the
- // slot/item assigned to the finished thread will be returned to the pool of
- // unused items.
- CHECK(dereference(tls_system_).Setup(&MarkSlotAsFree));
- }
-
- Chunk* AllocateAndInitializeChunk() {
- void* const uninitialized_memory =
- dereference(allocator_).AllocateMemory(sizeof(Chunk));
-
- // We might be called in the course of handling a memory allocation. We do
- // not use CHECK since they might allocate and cause a recursion.
- RAW_CHECK(uninitialized_memory != nullptr);
-
- return new (uninitialized_memory) Chunk{};
- }
-
- void FreeAndDeallocateChunkForTesting(Chunk* chunk_to_erase) {
- chunk_to_erase->~Chunk();
-
- // FreeAndDeallocateChunkForTesting must be called outside of the allocation
- // path. Therefore, it is secure to verify with CHECK.
- CHECK(dereference(allocator_)
- .FreeMemoryForTesting(chunk_to_erase, sizeof(Chunk)));
- }
-
- // Find a free slot in the passed chunk, reserve it and return it to the
- // caller. If no free slot can be found, head on to the next chunk. If the
- // next chunk doesn't exist, create it.
- SingleSlot* FindAndAllocateFreeSlot(Chunk* const chunk) {
- SingleSlot* const slot = std::find_if_not(
- std::begin(chunk->slots), std::end(chunk->slots),
- [](SingleSlot& candidate_slot) {
- return candidate_slot.is_used.test_and_set(std::memory_order_relaxed);
- });
-
- // So we found a slot. Happily return it to the caller.
- if (slot != std::end(chunk->slots)) {
- return slot;
- }
-
- // Ok, there are no more free slots in this chunk. First, ensure the next
- // chunk is valid and create one if necessary.
- std::call_once(chunk->create_next_chunk_flag, [&] {
- // From https://eel.is/c++draft/thread.once.callonce#3
- //
- // Synchronization: For any given once_flag: all active executions occur
- // in a total order; completion of an active execution synchronizes with
- // the start of the next one in this total order; and the returning
- // execution synchronizes with the return from all passive executions.
- //
- // Therefore, we do only a relaxed store here, call_once synchronizes with
- // other threads.
- chunk->next_chunk.store(AllocateAndInitializeChunk(),
- std::memory_order_relaxed);
- });
-
- return FindAndAllocateFreeSlot(chunk->next_chunk);
- }
-
- template <bool IsDestructibleForTestingP = IsDestructibleForTesting>
- typename std::enable_if<IsDestructibleForTestingP>::type
- TearDownForTesting() {
- // The destructor must be called outside of the allocation path. Therefore,
- // it is secure to verify with CHECK.
-
- // All accessing threads must be terminated by now. For additional security
- // we tear down the TLS system first. This way we ensure that
- // MarkSlotAsFree is not called anymore and we have no accesses from the
- // TLS system's side.
- CHECK(dereference(tls_system_).TearDownForTesting());
-
- // Delete all data chunks.
- for (auto* chunk = root_.load(); chunk != nullptr;) {
- auto* next_chunk = chunk->next_chunk.load();
- FreeAndDeallocateChunkForTesting(chunk);
- chunk = next_chunk;
- }
- }
-
- // Reset a single item to its default value.
- // Since items are re-used, they may be accessed from different threads,
- // causing TSan to trigger. Therefore, the reset is exempt from TSan
- // instrumentation.
- DISABLE_TSAN_INSTRUMENTATION void Reset(PayloadType& item) { item = {}; }
-
- AllocatorType allocator_;
- TLSSystemType tls_system_;
- std::atomic<Chunk*> const root_;
-};
-
-} // namespace internal
-
-// The ThreadLocalStorage visible to the user. This uses the internal default
-// allocator and TLS system.
-template <typename StorageType,
- typename AllocatorType = internal::DefaultAllocator,
- typename TLSSystemType = internal::DefaultTLSSystem,
- size_t AllocationChunkSize = AllocatorType::AllocationChunkSize,
- bool IsDestructibleForTesting = false>
-using ThreadLocalStorage =
- internal::ThreadLocalStorage<StorageType,
- AllocatorType,
- TLSSystemType,
- AllocationChunkSize,
- IsDestructibleForTesting>;
-
-} // namespace base::allocator::dispatcher
-
-#endif // USE_LOCAL_TLS_EMULATION()
-#endif // BASE_ALLOCATOR_DISPATCHER_TLS_H_
diff --git a/base/allocator/dispatcher/tls_unittest.cc b/base/allocator/dispatcher/tls_unittest.cc
deleted file mode 100644
index ccbe08a..0000000
--- a/base/allocator/dispatcher/tls_unittest.cc
+++ /dev/null
@@ -1,588 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/dispatcher/tls.h"
-
-#if USE_LOCAL_TLS_EMULATION()
-#include <algorithm>
-#include <array>
-#include <cstddef>
-#include <functional>
-#include <mutex>
-#include <thread>
-#include <unordered_set>
-#include <utility>
-
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using ::testing::_;
-using ::testing::InSequence;
-using ::testing::NiceMock;
-using ::testing::NotNull;
-using ::testing::Return;
-using ::testing::ReturnNull;
-
-namespace base::allocator::dispatcher {
-namespace {
-struct DataToStore {
- int data_int = 0;
- float data_float = 0.0;
- size_t data_size_t = 0;
- double data_double = 0.0;
-};
-
-struct AllocatorMockBase {
- AllocatorMockBase() {
- ON_CALL(*this, AllocateMemory(_)).WillByDefault([](size_t size_in_bytes) {
- return malloc(size_in_bytes);
- });
- ON_CALL(*this, FreeMemoryForTesting(_, _))
- .WillByDefault([](void* pointer_to_allocated, size_t size_in_bytes) {
- free(pointer_to_allocated);
- return true;
- });
- }
-
- MOCK_METHOD(void*, AllocateMemory, (size_t size_in_bytes), ());
- MOCK_METHOD(bool,
- FreeMemoryForTesting,
- (void* pointer_to_allocated, size_t size_in_bytes),
- ());
-};
-
-struct TLSSystemMockBase {
- TLSSystemMockBase() {
- ON_CALL(*this, Setup(_)).WillByDefault(Return(true));
- ON_CALL(*this, TearDownForTesting()).WillByDefault(Return(true));
- ON_CALL(*this, SetThreadSpecificData(_)).WillByDefault(Return(true));
- }
-
- MOCK_METHOD(
- bool,
- Setup,
- (internal::OnThreadTerminationFunction thread_termination_function),
- ());
- MOCK_METHOD(bool, TearDownForTesting, (), ());
- MOCK_METHOD(void*, GetThreadSpecificData, (), ());
- MOCK_METHOD(bool, SetThreadSpecificData, (void* data), ());
-};
-
-using AllocatorMock = NiceMock<AllocatorMockBase>;
-using TLSSystemMock = NiceMock<TLSSystemMockBase>;
-
-template <typename T, typename Allocator, typename TLSSystem>
-ThreadLocalStorage<T,
- std::reference_wrapper<Allocator>,
- std::reference_wrapper<TLSSystem>,
- 0,
- true>
-CreateThreadLocalStorage(Allocator& allocator, TLSSystem& tlsSystem) {
- return {std::ref(allocator), std::ref(tlsSystem)};
-}
-
-template <typename T>
-ThreadLocalStorage<T,
- internal::DefaultAllocator,
- internal::DefaultTLSSystem,
- 0,
- true>
-CreateThreadLocalStorage() {
- return {};
-}
-
-} // namespace
-
-struct BaseThreadLocalStorageTest : public ::testing::Test {};
-
-TEST_F(BaseThreadLocalStorageTest,
- VerifyDataIsIndependentBetweenDifferentSUTs) {
- auto sut_1 = CreateThreadLocalStorage<DataToStore>();
- auto sut_2 = CreateThreadLocalStorage<DataToStore>();
-
- EXPECT_NE(sut_1.GetThreadLocalData(), sut_2.GetThreadLocalData());
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyDistinctEntriesForEachThread) {
- auto sut = CreateThreadLocalStorage<DataToStore>();
- using TLSType = decltype(sut);
-
- std::array<std::thread, 2 * TLSType::ItemsPerChunk> threads;
- std::mutex thread_worker_mutex;
- std::condition_variable thread_counter_cv;
- std::atomic_uint32_t thread_counter{0};
- std::unordered_set<void*> stored_object_addresses;
-
- std::mutex threads_can_finish_mutex;
- std::condition_variable threads_can_finish_cv;
- std::atomic_bool threads_can_finish{false};
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- {
- std::lock_guard<std::mutex> lock(thread_worker_mutex);
- stored_object_addresses.insert(sut.GetThreadLocalData());
- ++thread_counter;
- thread_counter_cv.notify_one();
- }
-
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish_cv.wait(lock,
- [&] { return threads_can_finish.load(); });
- }
- }};
- }
-
- {
- std::unique_lock<std::mutex> lock(thread_worker_mutex);
- thread_counter_cv.wait(
- lock, [&] { return thread_counter.load() == threads.size(); });
- }
-
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish = true;
- threads_can_finish_cv.notify_all();
- }
-
- for (auto& t : threads) {
- t.join();
- }
-
- EXPECT_EQ(stored_object_addresses.size(), threads.size());
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyEntriesAreReusedForNewThreads) {
- auto sut = CreateThreadLocalStorage<DataToStore>();
- using TLSType = decltype(sut);
-
- std::unordered_set<void*> stored_object_addresses;
-
- for (size_t thread_count = 0; thread_count < (2 * TLSType::ItemsPerChunk);
- ++thread_count) {
- auto thread = std::thread{
- [&] { stored_object_addresses.insert(sut.GetThreadLocalData()); }};
-
- thread.join();
- }
-
- EXPECT_EQ(stored_object_addresses.size(), 1ul);
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyDataIsSameWithinEachThread) {
- auto sut = CreateThreadLocalStorage<DataToStore>();
- using TLSType = decltype(sut);
-
- std::array<std::thread, 2 * TLSType::ItemsPerChunk> threads;
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- EXPECT_EQ(sut.GetThreadLocalData(), sut.GetThreadLocalData());
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- // Check once again to verify the data doesn't change in the course of a
- // thread's lifetime.
- EXPECT_EQ(sut.GetThreadLocalData(), sut.GetThreadLocalData());
- }};
- }
-
- for (auto& t : threads) {
- t.join();
- }
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifySetupTeardownSequence) {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- InSequence execution_sequence;
-
- EXPECT_CALL(allocator_mock, AllocateMemory(_))
- .WillOnce([](size_t size_in_bytes) { return malloc(size_in_bytes); });
- EXPECT_CALL(tlsSystem_mock, Setup(NotNull())).WillOnce(Return(true));
- EXPECT_CALL(tlsSystem_mock, TearDownForTesting()).WillOnce(Return(true));
- EXPECT_CALL(allocator_mock, FreeMemoryForTesting(_, _))
- .WillOnce([](void* pointer_to_allocated, size_t size_in_bytes) {
- free(pointer_to_allocated);
- return true;
- });
-
- auto sut =
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyAllocatorIsUsed) {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- EXPECT_CALL(allocator_mock, AllocateMemory(_))
- .WillOnce([](size_t size_in_bytes) { return malloc(size_in_bytes); });
-
- EXPECT_CALL(allocator_mock, FreeMemoryForTesting(_, _))
- .WillOnce([](void* pointer_to_allocated, size_t size_in_bytes) {
- free(pointer_to_allocated);
- return true;
- });
-
- auto sut =
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyAllocatorIsUsedForMultipleChunks) {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- constexpr auto number_of_chunks = 3;
-
- EXPECT_CALL(allocator_mock, AllocateMemory(_))
- .Times(number_of_chunks)
- .WillRepeatedly(
- [](size_t size_in_bytes) { return malloc(size_in_bytes); });
-
- EXPECT_CALL(allocator_mock, FreeMemoryForTesting(_, _))
- .Times(number_of_chunks)
- .WillRepeatedly([](void* pointer_to_allocated, size_t size_in_bytes) {
- free(pointer_to_allocated);
- return true;
- });
-
- auto sut =
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
-
- std::array<std::thread,
- (number_of_chunks - 1) * decltype(sut)::ItemsPerChunk + 1>
- threads;
- std::mutex thread_worker_mutex;
- std::condition_variable thread_counter_cv;
- std::atomic_uint32_t thread_counter{0};
- std::unordered_set<void*> stored_object_addresses;
-
- std::mutex threads_can_finish_mutex;
- std::condition_variable threads_can_finish_cv;
- std::atomic_bool threads_can_finish{false};
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- sut.GetThreadLocalData();
-
- {
- std::lock_guard<std::mutex> lock(thread_worker_mutex);
- ++thread_counter;
- thread_counter_cv.notify_one();
- }
-
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish_cv.wait(lock,
- [&] { return threads_can_finish.load(); });
- }
- }};
- }
-
- {
- std::unique_lock<std::mutex> lock(thread_worker_mutex);
- thread_counter_cv.wait(
- lock, [&] { return thread_counter.load() == threads.size(); });
- }
-
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish = true;
- threads_can_finish_cv.notify_all();
- }
-
- for (auto& t : threads) {
- t.join();
- }
-}
-
-TEST_F(BaseThreadLocalStorageTest, VerifyTLSSystemIsUsed) {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- InSequence execution_sequence;
-
- EXPECT_CALL(tlsSystem_mock, Setup(NotNull())).WillOnce(Return(true));
- EXPECT_CALL(tlsSystem_mock, GetThreadSpecificData())
- .WillOnce(Return(nullptr));
- EXPECT_CALL(tlsSystem_mock, SetThreadSpecificData(NotNull()));
- EXPECT_CALL(tlsSystem_mock, TearDownForTesting())
- .Times(1)
- .WillOnce(Return(true));
-
- auto sut =
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
-
- sut.GetThreadLocalData();
-}
-
-#if defined(GTEST_HAS_DEATH_TEST)
-struct BaseThreadLocalStorageDeathTest : public ::testing::Test {};
-
-TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfAllocationFails) {
- auto f = [] {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- // Setup all expectations here. If we're setting them up in the parent
- // process, they will fail because the parent doesn't execute any test.
- EXPECT_CALL(allocator_mock, AllocateMemory(_)).WillOnce(ReturnNull());
-
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
- };
-
- EXPECT_DEATH(f(), "");
-}
-
-TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfFreeFails) {
- auto f = [] {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- // Setup all expectations here. If we're setting them up in the parent
- // process, they will fail because the parent doesn't execute any test.
- EXPECT_CALL(allocator_mock, FreeMemoryForTesting(_, _))
- .WillOnce([](void* allocated_memory, size_t size_in_bytes) {
- free(allocated_memory);
- return false;
- });
-
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
- };
-
- EXPECT_DEATH(f(), "");
-}
-
-TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfTLSSetupFails) {
- auto f = [] {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- // Setup all expectations here. If we're setting them up in the parent
- // process, they will fail because the parent doesn't execute any test.
- EXPECT_CALL(tlsSystem_mock, Setup(_)).WillOnce(Return(false));
- EXPECT_CALL(tlsSystem_mock, GetThreadSpecificData()).Times(0);
- EXPECT_CALL(tlsSystem_mock, SetThreadSpecificData(_)).Times(0);
- EXPECT_CALL(tlsSystem_mock, TearDownForTesting()).Times(0);
-
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
- };
-
- EXPECT_DEATH(f(), "");
-}
-
-TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfStoringTLSDataFails) {
- auto f = [] {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- // Setup all expectations here. If we're setting them up in the parent
- // process, they will fail because the parent doesn't execute any test.
- EXPECT_CALL(tlsSystem_mock, SetThreadSpecificData(_))
- .Times(1)
- .WillOnce(Return(false));
- EXPECT_CALL(tlsSystem_mock, TearDownForTesting()).Times(0);
-
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock)
- .GetThreadLocalData();
- };
-
- EXPECT_DEATH(f(), "");
-}
-
-TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfTLSTeardownFails) {
- auto f = [] {
- AllocatorMock allocator_mock;
- TLSSystemMock tlsSystem_mock;
-
- // Setup all expectations here. If we're setting them up in the parent
- // process, they will fail because the parent doesn't execute any test.
- EXPECT_CALL(tlsSystem_mock, Setup(_)).WillOnce(Return(true));
- EXPECT_CALL(tlsSystem_mock, TearDownForTesting()).WillOnce(Return(false));
-
- CreateThreadLocalStorage<DataToStore>(allocator_mock, tlsSystem_mock);
- };
-
- EXPECT_DEATH(f(), "");
-}
-#endif // GTEST_HAS_DEATH_TEST
-
-struct BasePThreadTLSSystemTest : public ::testing::Test {
- void SetUp() override { thread_termination_counter = 0; }
-
- protected:
- static void ThreadTerminationFunction(void*) { ++thread_termination_counter; }
-
- static std::atomic<size_t> thread_termination_counter;
-};
-
-std::atomic<size_t> BasePThreadTLSSystemTest::thread_termination_counter{0};
-
-TEST_F(BasePThreadTLSSystemTest, VerifySetupNTeardownSequence) {
- internal::PThreadTLSSystem sut;
-
- for (size_t idx = 0; idx < 5; ++idx) {
- EXPECT_TRUE(sut.Setup(nullptr));
- EXPECT_TRUE(sut.TearDownForTesting());
- }
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyThreadTerminationFunctionIsCalled) {
- std::array<std::thread, 10> threads;
-
- internal::PThreadTLSSystem sut;
- sut.Setup(&ThreadTerminationFunction);
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- int x = 0;
- ASSERT_TRUE(sut.SetThreadSpecificData(&x));
- }};
- }
-
- for (auto& t : threads) {
- t.join();
- }
-
- sut.TearDownForTesting();
-
- EXPECT_EQ(threads.size(), thread_termination_counter);
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyGetWithoutSetReturnsNull) {
- internal::PThreadTLSSystem sut;
- sut.Setup(nullptr);
-
- EXPECT_EQ(nullptr, sut.GetThreadSpecificData());
-
- sut.TearDownForTesting();
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyGetAfterTeardownReturnsNull) {
- internal::PThreadTLSSystem sut;
- sut.Setup(nullptr);
- sut.SetThreadSpecificData(this);
- sut.TearDownForTesting();
-
- EXPECT_EQ(sut.GetThreadSpecificData(), nullptr);
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyGetAfterTeardownReturnsNullThreaded) {
- std::array<std::thread, 50> threads;
-
- std::mutex thread_worker_mutex;
- std::condition_variable thread_counter_cv;
- std::atomic_uint32_t thread_counter{0};
-
- std::mutex threads_can_finish_mutex;
- std::condition_variable threads_can_finish_cv;
- std::atomic_bool threads_can_finish{false};
-
- internal::PThreadTLSSystem sut;
- ASSERT_TRUE(sut.Setup(nullptr));
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- // Set some thread specific data. At this stage retrieving the data must
- // return the pointer that was originally set.
- int x = 0;
- ASSERT_TRUE(sut.SetThreadSpecificData(&x));
- ASSERT_EQ(sut.GetThreadSpecificData(), &x);
-
- // Notify the main thread that one more test thread has started.
- {
- std::lock_guard<std::mutex> lock(thread_worker_mutex);
- ++thread_counter;
- thread_counter_cv.notify_one();
- }
-
- // Wait for the main thread to notify about teardown of the sut.
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish_cv.wait(lock,
- [&] { return threads_can_finish.load(); });
- }
-
- // After teardown, thread local data must be nullptr for all threads.
- EXPECT_EQ(sut.GetThreadSpecificData(), nullptr);
- }};
- }
-
- // Wait for notification from threads that they started and passed the initial
- // check.
- {
- std::unique_lock<std::mutex> lock(thread_worker_mutex);
- thread_counter_cv.wait(
- lock, [&] { return thread_counter.load() == threads.size(); });
- }
-
- ASSERT_TRUE(sut.TearDownForTesting());
-
- // Notify all threads that the subject under test was torn down and they can
- // proceed.
- {
- std::unique_lock<std::mutex> lock(threads_can_finish_mutex);
- threads_can_finish = true;
- threads_can_finish_cv.notify_all();
- }
-
- for (auto& t : threads) {
- t.join();
- }
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyGetSetSequence) {
- std::array<std::thread, 50> threads;
-
- internal::PThreadTLSSystem sut;
- sut.Setup(nullptr);
-
- for (auto& t : threads) {
- t = std::thread{[&] {
- int x = 0;
- EXPECT_TRUE(sut.SetThreadSpecificData(&x));
- EXPECT_EQ(&x, sut.GetThreadSpecificData());
- }};
- }
-
- for (auto& t : threads) {
- t.join();
- }
-
- sut.TearDownForTesting();
-}
-
-#if DCHECK_IS_ON()
-TEST_F(BasePThreadTLSSystemTest, VerifyGetWithoutSetupReturnsNull) {
- internal::PThreadTLSSystem sut;
-
- EXPECT_EQ(sut.GetThreadSpecificData(), nullptr);
-}
-
-TEST_F(BasePThreadTLSSystemTest, VerifyStoreWithoutSetupFails) {
- internal::PThreadTLSSystem sut;
-
- EXPECT_FALSE(sut.SetThreadSpecificData(this));
-}
-#endif
-
-#if defined(GTEST_HAS_DEATH_TEST) && DCHECK_IS_ON()
-struct BasePThreadTLSSystemDeathTest : public ::testing::Test {};
-
-TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfSetupTwice) {
- internal::PThreadTLSSystem sut;
-
- EXPECT_TRUE(sut.Setup(nullptr));
- EXPECT_DEATH(sut.Setup(nullptr), "");
-}
-
-TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfTearDownWithoutSetup) {
- internal::PThreadTLSSystem sut;
-
- EXPECT_DEATH(sut.TearDownForTesting(), "");
-}
-#endif
-} // namespace base::allocator::dispatcher
-
-#endif // USE_LOCAL_TLS_EMULATION()
\ No newline at end of file
diff --git a/base/allocator/early_zone_registration_mac.cc b/base/allocator/early_zone_registration_mac.cc
deleted file mode 100644
index a4eb1a2..0000000
--- a/base/allocator/early_zone_registration_mac.cc
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/early_zone_registration_mac.h"
-
-#include <mach/mach.h>
-#include <malloc/malloc.h>
-
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-
-// BASE_EXPORT tends to be defined as soon as anything from //base is included.
-#if defined(BASE_EXPORT)
-#error "This file cannot depend on //base"
-#endif
-
-namespace partition_alloc {
-
-#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-void EarlyMallocZoneRegistration() {}
-void AllowDoublePartitionAllocZoneRegistration() {}
-
-#else
-
-extern "C" {
-// abort_report_np() records the message in a special section that both the
-// system CrashReporter and Crashpad collect in crash reports. See also in
-// chrome_exe_main_mac.cc.
-void abort_report_np(const char* fmt, ...);
-}
-
-namespace {
-
-malloc_zone_t* GetDefaultMallocZone() {
- // malloc_default_zone() does not return... the default zone, but the
- // initial one. The default one is the first element of the default zone
- // array.
- unsigned int zone_count = 0;
- vm_address_t* zones = nullptr;
- kern_return_t result =
- malloc_get_all_zones(mach_task_self(), nullptr, &zones, &zone_count);
- if (result != KERN_SUCCESS)
- abort_report_np("Cannot enumerate malloc() zones");
- return reinterpret_cast<malloc_zone_t*>(zones[0]);
-}
-
-} // namespace
-
-void EarlyMallocZoneRegistration() {
- // Must have static storage duration, as raw pointers are passed to
- // libsystem_malloc.
- static malloc_zone_t g_delegating_zone;
- static malloc_introspection_t g_delegating_zone_introspect;
- static malloc_zone_t* g_default_zone;
-
- // Make sure that the default zone is instantiated.
- malloc_zone_t* purgeable_zone = malloc_default_purgeable_zone();
-
- g_default_zone = GetDefaultMallocZone();
-
- // The delegating zone:
- // - Forwards all allocations to the existing default zone
- // - Does *not* claim to own any memory, meaning that it will always be
- // skipped in free() in libsystem_malloc.dylib.
- //
- // This is a temporary zone, until it gets replaced by PartitionAlloc, inside
- // the main library. Since the main library depends on many external
- // libraries, we cannot install PartitionAlloc as the default zone without
- // concurrency issues.
- //
- // Instead, what we do is here, while the process is single-threaded:
- // - Register the delegating zone as the default one.
- // - Set the original (libsystem_malloc's) one as the second zone
- //
- // Later, when PartitionAlloc initializes, we replace the default (delegating)
- // zone with ours. The end state is:
- // 1. PartitionAlloc zone
- // 2. libsystem_malloc zone
-
- // Set up of the delegating zone. Note that it doesn't just forward calls to
- // the default zone. This is because the system zone's malloc_zone_t pointer
- // actually points to a larger struct, containing allocator metadata. So if we
- // pass as the first parameter the "simple" delegating zone pointer, then we
- // immediately crash inside the system zone functions. So we need to replace
- // the zone pointer as well.
- //
- // Calls fall into 4 categories:
- // - Allocation calls: forwarded to the real system zone
- // - "Is this pointer yours" calls: always answer no
- // - free(): Should never be called, but is in practice, see comments below.
- // - Diagnostics and debugging: these are typically called for every
- // zone. They are no-ops for us, as we don't want to double-count, or lock
- // the data structures of the real zone twice.
-
- // Allocation: Forward to the real zone.
- g_delegating_zone.malloc = [](malloc_zone_t* zone, size_t size) {
- return g_default_zone->malloc(g_default_zone, size);
- };
- g_delegating_zone.calloc = [](malloc_zone_t* zone, size_t num_items,
- size_t size) {
- return g_default_zone->calloc(g_default_zone, num_items, size);
- };
- g_delegating_zone.valloc = [](malloc_zone_t* zone, size_t size) {
- return g_default_zone->valloc(g_default_zone, size);
- };
- g_delegating_zone.realloc = [](malloc_zone_t* zone, void* ptr, size_t size) {
- return g_default_zone->realloc(g_default_zone, ptr, size);
- };
- g_delegating_zone.batch_malloc = [](malloc_zone_t* zone, size_t size,
- void** results, unsigned num_requested) {
- return g_default_zone->batch_malloc(g_default_zone, size, results,
- num_requested);
- };
- g_delegating_zone.memalign = [](malloc_zone_t* zone, size_t alignment,
- size_t size) {
- return g_default_zone->memalign(g_default_zone, alignment, size);
- };
-
- // Does ptr belong to this zone? Return value is != 0 if so.
- g_delegating_zone.size = [](malloc_zone_t* zone, const void* ptr) -> size_t {
- return 0;
- };
-
- // Free functions.
- // The normal path for freeing memory is:
- // 1. Try all zones in order, call zone->size(ptr)
- // 2. If zone->size(ptr) != 0, call zone->free(ptr) (or free_definite_size)
- // 3. If no zone matches, crash.
- //
- // Since this zone always returns 0 in size() (see above), then zone->free()
- // should never be called. Unfortunately, this is not the case, as some places
- // in CoreFoundation call malloc_zone_free(zone, ptr) directly. So rather than
- // crashing, forward the call. It's the caller's responsibility to use the
- // same zone for free() as for the allocation (this is in the contract of
- // malloc_zone_free()).
- //
- // However, note that the sequence of calls size() -> free() is not possible
- // for this zone, as size() always returns 0.
- g_delegating_zone.free = [](malloc_zone_t* zone, void* ptr) {
- return g_default_zone->free(g_default_zone, ptr);
- };
- g_delegating_zone.free_definite_size = [](malloc_zone_t* zone, void* ptr,
- size_t size) {
- return g_default_zone->free_definite_size(g_default_zone, ptr, size);
- };
- g_delegating_zone.batch_free = [](malloc_zone_t* zone, void** to_be_freed,
- unsigned num_to_be_freed) {
- return g_default_zone->batch_free(g_default_zone, to_be_freed,
- num_to_be_freed);
- };
-#if PA_TRY_FREE_DEFAULT_IS_AVAILABLE
- g_delegating_zone.try_free_default = [](malloc_zone_t* zone, void* ptr) {
- return g_default_zone->try_free_default(g_default_zone, ptr);
- };
-#endif
-
- // Diagnostics and debugging.
- //
- // Do nothing to reduce memory footprint, the real
- // zone will do it.
- g_delegating_zone.pressure_relief = [](malloc_zone_t* zone,
- size_t goal) -> size_t { return 0; };
-
- // Introspection calls are not all optional, for instance locking and
- // unlocking before/after fork() is not optional.
- //
- // Nothing to enumerate.
- g_delegating_zone_introspect.enumerator =
- [](task_t task, void*, unsigned type_mask, vm_address_t zone_address,
- memory_reader_t reader,
- vm_range_recorder_t recorder) -> kern_return_t {
- return KERN_SUCCESS;
- };
- // Need to provide a real implementation, it is used for e.g. array sizing.
- g_delegating_zone_introspect.good_size = [](malloc_zone_t* zone,
- size_t size) {
- return g_default_zone->introspect->good_size(g_default_zone, size);
- };
- // Nothing to do.
- g_delegating_zone_introspect.check = [](malloc_zone_t* zone) -> boolean_t {
- return true;
- };
- g_delegating_zone_introspect.print = [](malloc_zone_t* zone,
- boolean_t verbose) {};
- g_delegating_zone_introspect.log = [](malloc_zone_t*, void*) {};
- // Do not forward the lock / unlock calls. Since the default zone is still
- // there, we should not lock here, as it would lock the zone twice (all
- // zones are locked before fork().). Rather, do nothing, since this fake
- // zone does not need any locking.
- g_delegating_zone_introspect.force_lock = [](malloc_zone_t* zone) {};
- g_delegating_zone_introspect.force_unlock = [](malloc_zone_t* zone) {};
- g_delegating_zone_introspect.reinit_lock = [](malloc_zone_t* zone) {};
- // No stats.
- g_delegating_zone_introspect.statistics = [](malloc_zone_t* zone,
- malloc_statistics_t* stats) {};
- // We are not locked.
- g_delegating_zone_introspect.zone_locked =
- [](malloc_zone_t* zone) -> boolean_t { return false; };
- // Don't support discharge checking.
- g_delegating_zone_introspect.enable_discharge_checking =
- [](malloc_zone_t* zone) -> boolean_t { return false; };
- g_delegating_zone_introspect.disable_discharge_checking =
- [](malloc_zone_t* zone) {};
- g_delegating_zone_introspect.discharge = [](malloc_zone_t* zone,
- void* memory) {};
-
- // Could use something lower to support fewer functions, but this is
- // consistent with the real zone installed by PartitionAlloc.
- g_delegating_zone.version = kZoneVersion;
- g_delegating_zone.introspect = &g_delegating_zone_introspect;
- // This name is used in PartitionAlloc's initialization to determine whether
- // it should replace the delegating zone.
- g_delegating_zone.zone_name = kDelegatingZoneName;
-
- // Register puts the new zone at the end, unregister swaps the new zone with
- // the last one.
- // The zone array is, after these lines, in order:
- // 1. |g_default_zone|...|g_delegating_zone|
- // 2. |g_delegating_zone|...| (no more default)
- // 3. |g_delegating_zone|...|g_default_zone|
- malloc_zone_register(&g_delegating_zone);
- malloc_zone_unregister(g_default_zone);
- malloc_zone_register(g_default_zone);
-
- // Make sure that the purgeable zone is after the default one.
- // Will make g_default_zone take the purgeable zone spot
- malloc_zone_unregister(purgeable_zone);
- // Add back the purgeable zone as the last one.
- malloc_zone_register(purgeable_zone);
-
- // Final configuration:
- // |g_delegating_zone|...|g_default_zone|purgeable_zone|
-
- // Sanity check.
- if (GetDefaultMallocZone() != &g_delegating_zone)
- abort_report_np("Failed to install the delegating zone as default.");
-}
-
-void AllowDoublePartitionAllocZoneRegistration() {
- unsigned int zone_count = 0;
- vm_address_t* zones = nullptr;
- kern_return_t result =
- malloc_get_all_zones(mach_task_self(), nullptr, &zones, &zone_count);
- if (result != KERN_SUCCESS)
- abort_report_np("Cannot enumerate malloc() zones");
-
- // If PartitionAlloc is one of the zones, *change* its name so that
- // registration can happen multiple times. This works because zone
- // registration only keeps a pointer to the struct, it does not copy the data.
- for (unsigned int i = 0; i < zone_count; i++) {
- malloc_zone_t* zone = reinterpret_cast<malloc_zone_t*>(zones[i]);
- if (zone->zone_name &&
- strcmp(zone->zone_name, kPartitionAllocZoneName) == 0) {
- zone->zone_name = "RenamedPartitionAlloc";
- break;
- }
- }
-}
-
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-} // namespace partition_alloc
diff --git a/base/allocator/early_zone_registration_mac.h b/base/allocator/early_zone_registration_mac.h
deleted file mode 100644
index c8eeb86..0000000
--- a/base/allocator/early_zone_registration_mac.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_MAC_H_
-#define BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_MAC_H_
-
-// This is an Apple-only file, used to register PartitionAlloc's zone *before*
-// the process becomes multi-threaded.
-
-namespace partition_alloc {
-
-static constexpr char kDelegatingZoneName[] =
- "DelegatingDefaultZoneForPartitionAlloc";
-static constexpr char kPartitionAllocZoneName[] = "PartitionAlloc";
-
-// Zone version. Determines which callbacks are set in the various malloc_zone_t
-// structs.
-#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) || \
- (__IPHONE_OS_VERSION_MAX_ALLOWED >= 160100)
-#define PA_TRY_FREE_DEFAULT_IS_AVAILABLE 1
-#endif
-#if PA_TRY_FREE_DEFAULT_IS_AVAILABLE
-constexpr int kZoneVersion = 13;
-#else
-constexpr int kZoneVersion = 9;
-#endif
-
-// Must be called *once*, *before* the process becomes multi-threaded.
-void EarlyMallocZoneRegistration();
-
-// Tricks the registration code to believe that PartitionAlloc was not already
-// registered. This allows a future library load to register PartitionAlloc's
-// zone as well, rather than bailing out.
-//
-// This is mutually exclusive with EarlyMallocZoneRegistation(), and should
-// ideally be removed. Indeed, by allowing two zones to be registered, we still
-// end up with a split heap, and more memory usage.
-//
-// This is a hack for crbug.com/1274236.
-void AllowDoublePartitionAllocZoneRegistration();
-
-} // namespace partition_alloc
-
-#endif // BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_H_
diff --git a/base/allocator/partition_alloc_features.cc b/base/allocator/partition_alloc_features.cc
deleted file mode 100644
index 425f428..0000000
--- a/base/allocator/partition_alloc_features.cc
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2020 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/partition_alloc_features.h"
-
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/base_export.h"
-#include "base/feature_list.h"
-#include "build/build_config.h"
-
-namespace base {
-namespace features {
-
-BASE_FEATURE(kPartitionAllocUnretainedDanglingPtr,
- "PartitionAllocUnretainedDanglingPtr",
- FEATURE_DISABLED_BY_DEFAULT);
-
-constexpr FeatureParam<UnretainedDanglingPtrMode>::Option
- kUnretainedDanglingPtrModeOption[] = {
- {UnretainedDanglingPtrMode::kCrash, "crash"},
- {UnretainedDanglingPtrMode::kDumpWithoutCrashing,
- "dump_without_crashing"},
-};
-const base::FeatureParam<UnretainedDanglingPtrMode>
- kUnretainedDanglingPtrModeParam = {
- &kPartitionAllocUnretainedDanglingPtr,
- "mode",
- UnretainedDanglingPtrMode::kDumpWithoutCrashing,
- &kUnretainedDanglingPtrModeOption,
-};
-
-BASE_FEATURE(kPartitionAllocDanglingPtr,
- "PartitionAllocDanglingPtr",
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG)
- FEATURE_ENABLED_BY_DEFAULT
-#else
- FEATURE_DISABLED_BY_DEFAULT
-#endif
-);
-
-constexpr FeatureParam<DanglingPtrMode>::Option kDanglingPtrModeOption[] = {
- {DanglingPtrMode::kCrash, "crash"},
- {DanglingPtrMode::kLogOnly, "log_only"},
-};
-const base::FeatureParam<DanglingPtrMode> kDanglingPtrModeParam{
- &kPartitionAllocDanglingPtr,
- "mode",
- DanglingPtrMode::kCrash,
- &kDanglingPtrModeOption,
-};
-constexpr FeatureParam<DanglingPtrType>::Option kDanglingPtrTypeOption[] = {
- {DanglingPtrType::kAll, "all"},
- {DanglingPtrType::kCrossTask, "cross_task"},
-};
-const base::FeatureParam<DanglingPtrType> kDanglingPtrTypeParam{
- &kPartitionAllocDanglingPtr,
- "type",
- DanglingPtrType::kAll,
- &kDanglingPtrTypeOption,
-};
-
-#if BUILDFLAG(USE_STARSCAN)
-// If enabled, PCScan is turned on by default for all partitions that don't
-// disable it explicitly.
-BASE_FEATURE(kPartitionAllocPCScan,
- "PartitionAllocPCScan",
- FEATURE_DISABLED_BY_DEFAULT);
-#endif // BUILDFLAG(USE_STARSCAN)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-// If enabled, PCScan is turned on only for the browser's malloc partition.
-BASE_FEATURE(kPartitionAllocPCScanBrowserOnly,
- "PartitionAllocPCScanBrowserOnly",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// If enabled, PCScan is turned on only for the renderer's malloc partition.
-BASE_FEATURE(kPartitionAllocPCScanRendererOnly,
- "PartitionAllocPCScanRendererOnly",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// If enabled, this instance belongs to the Control group of the BackupRefPtr
-// binary experiment.
-BASE_FEATURE(kPartitionAllocBackupRefPtrControl,
- "PartitionAllocBackupRefPtrControl",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// Use a larger maximum thread cache cacheable bucket size.
-BASE_FEATURE(kPartitionAllocLargeThreadCacheSize,
- "PartitionAllocLargeThreadCacheSize",
-#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
- // Not unconditionally enabled on 32 bit Android, since it is a
- // more memory-constrained platform.
- FEATURE_DISABLED_BY_DEFAULT
-#else
- FEATURE_ENABLED_BY_DEFAULT
-#endif
-);
-
-BASE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing,
- "PartitionAllocLargeEmptySlotSpanRing",
- FEATURE_DISABLED_BY_DEFAULT);
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-BASE_FEATURE(kPartitionAllocBackupRefPtr,
- "PartitionAllocBackupRefPtr",
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || \
- BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG) || \
- (BUILDFLAG(USE_ASAN_BACKUP_REF_PTR) && BUILDFLAG(IS_LINUX))
- FEATURE_ENABLED_BY_DEFAULT
-#else
- FEATURE_DISABLED_BY_DEFAULT
-#endif
-);
-
-constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option
- kBackupRefPtrEnabledProcessesOptions[] = {
- {BackupRefPtrEnabledProcesses::kBrowserOnly, "browser-only"},
- {BackupRefPtrEnabledProcesses::kBrowserAndRenderer,
- "browser-and-renderer"},
- {BackupRefPtrEnabledProcesses::kNonRenderer, "non-renderer"},
- {BackupRefPtrEnabledProcesses::kAllProcesses, "all-processes"}};
-
-const base::FeatureParam<BackupRefPtrEnabledProcesses>
- kBackupRefPtrEnabledProcessesParam {
- &kPartitionAllocBackupRefPtr, "enabled-processes",
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || \
- BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG) || \
- (BUILDFLAG(USE_ASAN_BACKUP_REF_PTR) && BUILDFLAG(IS_LINUX))
- BackupRefPtrEnabledProcesses::kNonRenderer,
-#else
- BackupRefPtrEnabledProcesses::kBrowserOnly,
-#endif
- &kBackupRefPtrEnabledProcessesOptions
-};
-
-constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = {
- {BackupRefPtrMode::kDisabled, "disabled"},
- {BackupRefPtrMode::kEnabled, "enabled"},
- {BackupRefPtrMode::kEnabledWithoutZapping, "enabled-without-zapping"},
- {BackupRefPtrMode::kEnabledWithMemoryReclaimer,
- "enabled-with-memory-reclaimer"},
- {BackupRefPtrMode::kDisabledButSplitPartitions2Way,
- "disabled-but-2-way-split"},
- {BackupRefPtrMode::kDisabledButSplitPartitions2WayWithMemoryReclaimer,
- "disabled-but-2-way-split-with-memory-reclaimer"},
- {BackupRefPtrMode::kDisabledButSplitPartitions3Way,
- "disabled-but-3-way-split"},
- {BackupRefPtrMode::kDisabledButAddDummyRefCount,
- "disabled-but-add-dummy-ref-count"},
-};
-
-const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{
- &kPartitionAllocBackupRefPtr, "brp-mode", BackupRefPtrMode::kEnabled,
- &kBackupRefPtrModeOptions};
-
-const base::FeatureParam<bool> kBackupRefPtrAsanEnableDereferenceCheckParam{
- &kPartitionAllocBackupRefPtr, "asan-enable-dereference-check", true};
-const base::FeatureParam<bool> kBackupRefPtrAsanEnableExtractionCheckParam{
- &kPartitionAllocBackupRefPtr, "asan-enable-extraction-check",
- false}; // Not much noise at the moment to enable by default.
-const base::FeatureParam<bool> kBackupRefPtrAsanEnableInstantiationCheckParam{
- &kPartitionAllocBackupRefPtr, "asan-enable-instantiation-check", true};
-
-// If enabled, switches the bucket distribution to an alternate one.
-//
-// We enable this by default everywhere except for 32-bit Android, since we saw
-// regressions there.
-BASE_FEATURE(kPartitionAllocUseAlternateDistribution,
- "PartitionAllocUseAlternateDistribution",
-#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
- FEATURE_DISABLED_BY_DEFAULT
-#else
- FEATURE_ENABLED_BY_DEFAULT
-#endif // BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
-);
-const base::FeatureParam<AlternateBucketDistributionMode>::Option
- kPartitionAllocAlternateDistributionOption[] = {
- {AlternateBucketDistributionMode::kDefault, "default"},
- {AlternateBucketDistributionMode::kDenser, "denser"},
-};
-const base::FeatureParam<AlternateBucketDistributionMode>
- kPartitionAllocAlternateBucketDistributionParam{
- &kPartitionAllocUseAlternateDistribution, "mode",
- AlternateBucketDistributionMode::kDefault,
- &kPartitionAllocAlternateDistributionOption};
-
-// Configures whether we set a lower limit for renderers that do not have a main
-// frame, similar to the limit that is already done for backgrounded renderers.
-BASE_FEATURE(kLowerPAMemoryLimitForNonMainRenderers,
- "LowerPAMemoryLimitForNonMainRenderers",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// If enabled, switches PCScan scheduling to a mutator-aware scheduler. Does not
-// affect whether PCScan is enabled itself.
-BASE_FEATURE(kPartitionAllocPCScanMUAwareScheduler,
- "PartitionAllocPCScanMUAwareScheduler",
- FEATURE_ENABLED_BY_DEFAULT);
-
-// If enabled, PCScan frees unconditionally all quarantined objects.
-// This is a performance testing feature.
-BASE_FEATURE(kPartitionAllocPCScanImmediateFreeing,
- "PartitionAllocPCScanImmediateFreeing",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// If enabled, PCScan clears eagerly (synchronously) on free().
-BASE_FEATURE(kPartitionAllocPCScanEagerClearing,
- "PartitionAllocPCScanEagerClearing",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// In addition to heap, scan also the stack of the current mutator.
-BASE_FEATURE(kPartitionAllocPCScanStackScanning,
- "PartitionAllocPCScanStackScanning",
-#if BUILDFLAG(PCSCAN_STACK_SUPPORTED)
- FEATURE_ENABLED_BY_DEFAULT
-#else
- FEATURE_DISABLED_BY_DEFAULT
-#endif // BUILDFLAG(PCSCAN_STACK_SUPPORTED)
-);
-
-BASE_FEATURE(kPartitionAllocDCScan,
- "PartitionAllocDCScan",
- FEATURE_DISABLED_BY_DEFAULT);
-
-// Whether to sort the active slot spans in PurgeMemory().
-BASE_FEATURE(kPartitionAllocSortActiveSlotSpans,
- "PartitionAllocSortActiveSlotSpans",
- FEATURE_DISABLED_BY_DEFAULT);
-
-#if BUILDFLAG(IS_WIN)
-// Whether to retry allocations when commit fails.
-BASE_FEATURE(kPageAllocatorRetryOnCommitFailure,
- "PageAllocatorRetryOnCommitFailure",
- FEATURE_DISABLED_BY_DEFAULT);
-#endif
-
-} // namespace features
-} // namespace base
diff --git a/base/allocator/partition_alloc_features.h b/base/allocator/partition_alloc_features.h
deleted file mode 100644
index 7398916..0000000
--- a/base/allocator/partition_alloc_features.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2020 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
-#define BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
-
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/base_export.h"
-#include "base/compiler_specific.h"
-#include "base/feature_list.h"
-#include "base/metrics/field_trial_params.h"
-#include "build/build_config.h"
-
-namespace base {
-namespace features {
-
-extern const BASE_EXPORT Feature kPartitionAllocUnretainedDanglingPtr;
-enum class UnretainedDanglingPtrMode {
- kCrash,
- kDumpWithoutCrashing,
-};
-extern const BASE_EXPORT base::FeatureParam<UnretainedDanglingPtrMode>
- kUnretainedDanglingPtrModeParam;
-
-// See /docs/dangling_ptr.md
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDanglingPtr);
-enum class DanglingPtrMode {
- // Crash immediately after detecting a dangling raw_ptr.
- kCrash, // (default)
-
- // Log the signature of every occurrences without crashing. It is used by
- // bots.
- // Format "[DanglingSignature]\t<1>\t<2>\t<3>\t<4>"
- // 1. The function which freed the memory while it was still referenced.
- // 2. The task in which the memory was freed.
- // 3. The function which released the raw_ptr reference.
- // 4. The task in which the raw_ptr was released.
- kLogOnly,
-
- // Note: This will be extended with a single shot DumpWithoutCrashing.
-};
-extern const BASE_EXPORT base::FeatureParam<DanglingPtrMode>
- kDanglingPtrModeParam;
-enum class DanglingPtrType {
- // Act on any dangling raw_ptr released after being freed.
- kAll, // (default)
-
- // Detect when freeing memory and releasing the dangling raw_ptr happens in
- // a different task. Those are more likely to cause use after free.
- kCrossTask,
-
- // Note: This will be extended with LongLived
-};
-extern const BASE_EXPORT base::FeatureParam<DanglingPtrType>
- kDanglingPtrTypeParam;
-
-#if BUILDFLAG(USE_STARSCAN)
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScan);
-#endif
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanBrowserOnly);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanRendererOnly);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtrControl);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeThreadCacheSize);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing);
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-enum class BackupRefPtrEnabledProcesses {
- // BRP enabled only in the browser process.
- kBrowserOnly,
- // BRP enabled only in the browser and renderer processes.
- kBrowserAndRenderer,
- // BRP enabled in all processes, except renderer.
- kNonRenderer,
- // BRP enabled in all processes.
- kAllProcesses,
-};
-
-enum class BackupRefPtrMode {
- // BRP is disabled across all partitions. Equivalent to the Finch flag being
- // disabled.
- kDisabled,
-
- // BRP is enabled in the main partition, as well as certain Renderer-only
- // partitions (if enabled in Renderer at all).
- // This entails splitting the main partition.
- kEnabled,
-
- // Same as kEnabled but without zapping quarantined objects.
- kEnabledWithoutZapping,
-
- // Same as kEnabled but registers the main partition to memory reclaimer.
- kEnabledWithMemoryReclaimer,
-
- // BRP is disabled, but the main partition is split out, as if BRP was enabled
- // in the "previous slot" mode.
- kDisabledButSplitPartitions2Way,
-
- // Same as kDisabledButSplitPartitions2Way but registers the main partition to
- // memory reclaimer.
- kDisabledButSplitPartitions2WayWithMemoryReclaimer,
-
- // BRP is disabled, but the main partition *and* aligned partition are split
- // out, as if BRP was enabled in the "before allocation" mode.
- kDisabledButSplitPartitions3Way,
-
- // BRP is disabled, but add dummy ref count to each allocation. This will
- // increase allocation size but not change any of the logic. If an issue
- // reproduce in this mode, it means the increase in size is causing it.
- kDisabledButAddDummyRefCount,
-};
-
-enum class AlternateBucketDistributionMode : uint8_t {
- kDefault,
- kDenser,
-};
-
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtr);
-extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
- kBackupRefPtrEnabledProcessesParam;
-extern const BASE_EXPORT base::FeatureParam<BackupRefPtrMode>
- kBackupRefPtrModeParam;
-extern const BASE_EXPORT base::FeatureParam<bool>
- kBackupRefPtrAsanEnableDereferenceCheckParam;
-extern const BASE_EXPORT base::FeatureParam<bool>
- kBackupRefPtrAsanEnableExtractionCheckParam;
-extern const BASE_EXPORT base::FeatureParam<bool>
- kBackupRefPtrAsanEnableInstantiationCheckParam;
-extern const BASE_EXPORT base::FeatureParam<AlternateBucketDistributionMode>
- kPartitionAllocAlternateBucketDistributionParam;
-
-BASE_EXPORT BASE_DECLARE_FEATURE(kLowerPAMemoryLimitForNonMainRenderers);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanMUAwareScheduler);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanStackScanning);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDCScan);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanImmediateFreeing);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanEagerClearing);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocSortActiveSlotSpans);
-BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocUseAlternateDistribution);
-#if BUILDFLAG(IS_WIN)
-BASE_EXPORT BASE_DECLARE_FEATURE(kPageAllocatorRetryOnCommitFailure);
-#endif
-
-} // namespace features
-} // namespace base
-
-#endif // BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc
deleted file mode 100644
index d2d56a9..0000000
--- a/base/allocator/partition_alloc_support.cc
+++ /dev/null
@@ -1,1316 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/partition_alloc_support.h"
-
-#include <array>
-#include <cinttypes>
-#include <cstdint>
-#include <map>
-#include <string>
-
-#include "base/allocator/partition_alloc_features.h"
-#include "base/allocator/partition_allocator/allocation_guard.h"
-#include "base/allocator/partition_allocator/dangling_raw_ptr_checks.h"
-#include "base/allocator/partition_allocator/memory_reclaimer.h"
-#include "base/allocator/partition_allocator/page_allocator.h"
-#include "base/allocator/partition_allocator/partition_alloc_base/debug/alias.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/allocator/partition_allocator/partition_alloc_check.h"
-#include "base/allocator/partition_allocator/partition_alloc_config.h"
-#include "base/allocator/partition_allocator/partition_lock.h"
-#include "base/allocator/partition_allocator/shim/allocator_shim.h"
-#include "base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
-#include "base/allocator/partition_allocator/thread_cache.h"
-#include "base/check.h"
-#include "base/debug/dump_without_crashing.h"
-#include "base/debug/stack_trace.h"
-#include "base/debug/task_trace.h"
-#include "base/feature_list.h"
-#include "base/functional/bind.h"
-#include "base/functional/callback.h"
-#include "base/immediate_crash.h"
-#include "base/location.h"
-#include "base/memory/raw_ptr_asan_service.h"
-#include "base/metrics/histogram_functions.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/no_destructor.h"
-#include "base/strings/string_piece.h"
-#include "base/strings/string_split.h"
-#include "base/strings/stringprintf.h"
-#include "base/system/sys_info.h"
-#include "base/task/single_thread_task_runner.h"
-#include "base/thread_annotations.h"
-#include "base/threading/platform_thread.h"
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "base/trace_event/base_tracing.h"
-#include "build/build_config.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
-
-#if BUILDFLAG(USE_STARSCAN)
-#include "base/allocator/partition_allocator/starscan/pcscan.h"
-#include "base/allocator/partition_allocator/starscan/pcscan_scheduling.h"
-#include "base/allocator/partition_allocator/starscan/stack/stack.h"
-#include "base/allocator/partition_allocator/starscan/stats_collector.h"
-#include "base/allocator/partition_allocator/starscan/stats_reporter.h"
-#include "base/memory/nonscannable_memory.h"
-#endif // BUILDFLAG(USE_STARSCAN)
-
-#if BUILDFLAG(IS_ANDROID)
-#include "base/system/sys_info.h"
-#endif
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-#include "base/allocator/partition_allocator/memory_reclaimer.h"
-#endif
-
-namespace base::allocator {
-
-namespace {
-
-// This is defined in content/public/common/content_switches.h, which is not
-// accessible in ::base. They must be kept in sync.
-namespace switches {
-[[maybe_unused]] constexpr char kRendererProcess[] = "renderer";
-constexpr char kZygoteProcess[] = "zygote";
-#if BUILDFLAG(USE_STARSCAN)
-constexpr char kGpuProcess[] = "gpu-process";
-constexpr char kUtilityProcess[] = "utility";
-#endif
-} // namespace switches
-
-#if BUILDFLAG(USE_STARSCAN)
-
-#if BUILDFLAG(ENABLE_BASE_TRACING)
-constexpr const char* ScannerIdToTracingString(
- partition_alloc::internal::StatsCollector::ScannerId id) {
- switch (id) {
- case partition_alloc::internal::StatsCollector::ScannerId::kClear:
- return "PCScan.Scanner.Clear";
- case partition_alloc::internal::StatsCollector::ScannerId::kScan:
- return "PCScan.Scanner.Scan";
- case partition_alloc::internal::StatsCollector::ScannerId::kSweep:
- return "PCScan.Scanner.Sweep";
- case partition_alloc::internal::StatsCollector::ScannerId::kOverall:
- return "PCScan.Scanner";
- case partition_alloc::internal::StatsCollector::ScannerId::kNumIds:
- __builtin_unreachable();
- }
-}
-
-constexpr const char* MutatorIdToTracingString(
- partition_alloc::internal::StatsCollector::MutatorId id) {
- switch (id) {
- case partition_alloc::internal::StatsCollector::MutatorId::kClear:
- return "PCScan.Mutator.Clear";
- case partition_alloc::internal::StatsCollector::MutatorId::kScanStack:
- return "PCScan.Mutator.ScanStack";
- case partition_alloc::internal::StatsCollector::MutatorId::kScan:
- return "PCScan.Mutator.Scan";
- case partition_alloc::internal::StatsCollector::MutatorId::kOverall:
- return "PCScan.Mutator";
- case partition_alloc::internal::StatsCollector::MutatorId::kNumIds:
- __builtin_unreachable();
- }
-}
-#endif // BUILDFLAG(ENABLE_BASE_TRACING)
-
-// Inject TRACE_EVENT_BEGIN/END, TRACE_COUNTER1, and UmaHistogramTimes.
-class StatsReporterImpl final : public partition_alloc::StatsReporter {
- public:
- void ReportTraceEvent(
- partition_alloc::internal::StatsCollector::ScannerId id,
- [[maybe_unused]] partition_alloc::internal::base::PlatformThreadId tid,
- int64_t start_time_ticks_internal_value,
- int64_t end_time_ticks_internal_value) override {
-#if BUILDFLAG(ENABLE_BASE_TRACING)
- // TRACE_EVENT_* macros below drop most parameters when tracing is
- // disabled at compile time.
- const char* tracing_id = ScannerIdToTracingString(id);
- const TimeTicks start_time =
- TimeTicks::FromInternalValue(start_time_ticks_internal_value);
- const TimeTicks end_time =
- TimeTicks::FromInternalValue(end_time_ticks_internal_value);
- TRACE_EVENT_BEGIN(kTraceCategory, perfetto::StaticString(tracing_id),
- perfetto::ThreadTrack::ForThread(tid), start_time);
- TRACE_EVENT_END(kTraceCategory, perfetto::ThreadTrack::ForThread(tid),
- end_time);
-#endif // BUILDFLAG(ENABLE_BASE_TRACING)
- }
-
- void ReportTraceEvent(
- partition_alloc::internal::StatsCollector::MutatorId id,
- [[maybe_unused]] partition_alloc::internal::base::PlatformThreadId tid,
- int64_t start_time_ticks_internal_value,
- int64_t end_time_ticks_internal_value) override {
-#if BUILDFLAG(ENABLE_BASE_TRACING)
- // TRACE_EVENT_* macros below drop most parameters when tracing is
- // disabled at compile time.
- const char* tracing_id = MutatorIdToTracingString(id);
- const TimeTicks start_time =
- TimeTicks::FromInternalValue(start_time_ticks_internal_value);
- const TimeTicks end_time =
- TimeTicks::FromInternalValue(end_time_ticks_internal_value);
- TRACE_EVENT_BEGIN(kTraceCategory, perfetto::StaticString(tracing_id),
- perfetto::ThreadTrack::ForThread(tid), start_time);
- TRACE_EVENT_END(kTraceCategory, perfetto::ThreadTrack::ForThread(tid),
- end_time);
-#endif // BUILDFLAG(ENABLE_BASE_TRACING)
- }
-
- void ReportSurvivedQuarantineSize(size_t survived_size) override {
- TRACE_COUNTER1(kTraceCategory, "PCScan.SurvivedQuarantineSize",
- survived_size);
- }
-
- void ReportSurvivedQuarantinePercent(double survived_rate) override {
- // Multiply by 1000 since TRACE_COUNTER1 expects integer. In catapult,
- // divide back.
- // TODO(bikineev): Remove after switching to perfetto.
- TRACE_COUNTER1(kTraceCategory, "PCScan.SurvivedQuarantinePercent",
- 1000 * survived_rate);
- }
-
- void ReportStats(const char* stats_name, int64_t sample_in_usec) override {
- TimeDelta sample = Microseconds(sample_in_usec);
- UmaHistogramTimes(stats_name, sample);
- }
-
- private:
- static constexpr char kTraceCategory[] = "partition_alloc";
-};
-
-#endif // BUILDFLAG(USE_STARSCAN)
-
-} // namespace
-
-#if BUILDFLAG(USE_STARSCAN)
-void RegisterPCScanStatsReporter() {
- static StatsReporterImpl s_reporter;
- static bool registered = false;
-
- DCHECK(!registered);
-
- partition_alloc::internal::PCScan::RegisterStatsReporter(&s_reporter);
- registered = true;
-}
-#endif // BUILDFLAG(USE_STARSCAN)
-
-namespace {
-
-void RunThreadCachePeriodicPurge() {
- // Micros, since periodic purge should typically take at most a few ms.
- SCOPED_UMA_HISTOGRAM_TIMER_MICROS("Memory.PartitionAlloc.PeriodicPurge");
- TRACE_EVENT0("memory", "PeriodicPurge");
- auto& instance = ::partition_alloc::ThreadCacheRegistry::Instance();
- instance.RunPeriodicPurge();
- TimeDelta delay =
- Microseconds(instance.GetPeriodicPurgeNextIntervalInMicroseconds());
- SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
- FROM_HERE, BindOnce(RunThreadCachePeriodicPurge), delay);
-}
-
-void RunMemoryReclaimer(scoped_refptr<SequencedTaskRunner> task_runner) {
- TRACE_EVENT0("base", "partition_alloc::MemoryReclaimer::Reclaim()");
- auto* instance = ::partition_alloc::MemoryReclaimer::Instance();
-
- {
- // Micros, since memory reclaiming should typically take at most a few ms.
- SCOPED_UMA_HISTOGRAM_TIMER_MICROS("Memory.PartitionAlloc.MemoryReclaim");
- instance->ReclaimNormal();
- }
-
- TimeDelta delay =
- Microseconds(instance->GetRecommendedReclaimIntervalInMicroseconds());
- task_runner->PostDelayedTask(
- FROM_HERE, BindOnce(RunMemoryReclaimer, task_runner), delay);
-}
-
-} // namespace
-
-void StartThreadCachePeriodicPurge() {
- auto& instance = ::partition_alloc::ThreadCacheRegistry::Instance();
- TimeDelta delay =
- Microseconds(instance.GetPeriodicPurgeNextIntervalInMicroseconds());
- SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
- FROM_HERE, BindOnce(RunThreadCachePeriodicPurge), delay);
-}
-
-void StartMemoryReclaimer(scoped_refptr<SequencedTaskRunner> task_runner) {
- // Can be called several times.
- static bool is_memory_reclaimer_running = false;
- if (is_memory_reclaimer_running) {
- return;
- }
- is_memory_reclaimer_running = true;
-
- // The caller of the API fully controls where running the reclaim.
- // However there are a few reasons to recommend that the caller runs
- // it on the main thread:
- // - Most of PartitionAlloc's usage is on the main thread, hence PA's metadata
- // is more likely in cache when executing on the main thread.
- // - Memory reclaim takes the partition lock for each partition. As a
- // consequence, while reclaim is running, the main thread is unlikely to be
- // able to make progress, as it would be waiting on the lock.
- // - Finally, this runs in idle time only, so there should be no visible
- // impact.
- //
- // From local testing, time to reclaim is 100us-1ms, and reclaiming every few
- // seconds is useful. Since this is meant to run during idle time only, it is
- // a reasonable starting point balancing effectivenes vs cost. See
- // crbug.com/942512 for details and experimental results.
- auto* instance = ::partition_alloc::MemoryReclaimer::Instance();
- TimeDelta delay =
- Microseconds(instance->GetRecommendedReclaimIntervalInMicroseconds());
- task_runner->PostDelayedTask(
- FROM_HERE, BindOnce(RunMemoryReclaimer, task_runner), delay);
-}
-
-std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
- std::map<std::string, std::string> trials;
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- // BackupRefPtr_Effective and PCScan_Effective record whether or not
- // BackupRefPtr and/or PCScan are enabled. The experiments aren't independent,
- // so having a synthetic Finch will help look only at cases where one isn't
- // affected by the other.
-
- // Whether PartitionAllocBackupRefPtr is enabled (as determined by
- // FeatureList::IsEnabled).
- [[maybe_unused]] bool brp_finch_enabled = false;
- // Whether PartitionAllocBackupRefPtr is set up for the default behavior. The
- // default behavior is when either the Finch flag is disabled, or is enabled
- // in brp-mode=disabled (these two options are equivalent).
- [[maybe_unused]] bool brp_nondefault_behavior = false;
- // Whether PartitionAllocBackupRefPtr is set up to enable BRP protection. It
- // requires the Finch flag to be enabled and brp-mode!=disabled*. Some modes,
- // e.g. disabled-but-3-way-split, do something (hence can't be considered the
- // default behavior), but don't enable BRP protection.
- [[maybe_unused]] bool brp_truly_enabled = false;
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- if (FeatureList::IsEnabled(features::kPartitionAllocBackupRefPtr)) {
- brp_finch_enabled = true;
- }
- if (brp_finch_enabled && features::kBackupRefPtrModeParam.Get() !=
- features::BackupRefPtrMode::kDisabled) {
- brp_nondefault_behavior = true;
- }
- if (brp_finch_enabled && features::kBackupRefPtrModeParam.Get() ==
- features::BackupRefPtrMode::kEnabled) {
- brp_truly_enabled = true;
- }
-#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- [[maybe_unused]] bool pcscan_enabled =
-#if BUILDFLAG(USE_STARSCAN)
- FeatureList::IsEnabled(features::kPartitionAllocPCScanBrowserOnly);
-#else
- false;
-#endif
-
- std::string brp_group_name = "Unavailable";
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- if (pcscan_enabled) {
- // If PCScan is enabled, just ignore the population.
- brp_group_name = "Ignore_PCScanIsOn";
- } else if (!brp_finch_enabled) {
- // The control group is actually disguised as "enabled", but in fact it's
- // disabled using a param. This is to differentiate the population that
- // participates in the control group, from the population that isn't in any
- // group.
- brp_group_name = "Ignore_NoGroup";
- } else {
- switch (features::kBackupRefPtrModeParam.Get()) {
- case features::BackupRefPtrMode::kDisabled:
- brp_group_name = "Disabled";
- break;
- case features::BackupRefPtrMode::kEnabled:
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- brp_group_name = "EnabledPrevSlot";
-#else
- brp_group_name = "EnabledBeforeAlloc";
-#endif
- break;
- case features::BackupRefPtrMode::kEnabledWithoutZapping:
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- brp_group_name = "EnabledPrevSlotWithoutZapping";
-#else
- brp_group_name = "EnabledBeforeAllocWithoutZapping";
-#endif
- break;
- case features::BackupRefPtrMode::kEnabledWithMemoryReclaimer:
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- brp_group_name = "EnabledPrevSlotWithMemoryReclaimer";
-#else
- brp_group_name = "EnabledBeforeAllocWithMemoryReclaimer";
-#endif
- break;
- case features::BackupRefPtrMode::kDisabledButSplitPartitions2Way:
- brp_group_name = "DisabledBut2WaySplit";
- break;
- case features::BackupRefPtrMode::
- kDisabledButSplitPartitions2WayWithMemoryReclaimer:
- brp_group_name = "DisabledBut2WaySplitWithMemoryReclaimer";
- break;
- case features::BackupRefPtrMode::kDisabledButSplitPartitions3Way:
- brp_group_name = "DisabledBut3WaySplit";
- break;
- case features::BackupRefPtrMode::kDisabledButAddDummyRefCount:
- brp_group_name = "DisabledButAddDummyRefCount";
- break;
- }
-
- if (features::kBackupRefPtrModeParam.Get() !=
- features::BackupRefPtrMode::kDisabled) {
- std::string process_selector;
- switch (features::kBackupRefPtrEnabledProcessesParam.Get()) {
- case features::BackupRefPtrEnabledProcesses::kBrowserOnly:
- process_selector = "BrowserOnly";
- break;
- case features::BackupRefPtrEnabledProcesses::kBrowserAndRenderer:
- process_selector = "BrowserAndRenderer";
- break;
- case features::BackupRefPtrEnabledProcesses::kNonRenderer:
- process_selector = "NonRenderer";
- break;
- case features::BackupRefPtrEnabledProcesses::kAllProcesses:
- process_selector = "AllProcesses";
- break;
- }
-
- brp_group_name += ("_" + process_selector);
- }
- }
-#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- trials.emplace("BackupRefPtr_Effective", brp_group_name);
-
- // On 32-bit architectures, PCScan is not supported and permanently disabled.
- // Don't lump it into "Disabled", so that belonging to "Enabled"/"Disabled" is
- // fully controlled by Finch and thus have identical population sizes.
- std::string pcscan_group_name = "Unavailable";
- std::string pcscan_group_name_fallback = "Unavailable";
-#if BUILDFLAG(USE_STARSCAN)
- if (brp_truly_enabled) {
- // If BRP protection is enabled, just ignore the population. Check
- // brp_truly_enabled, not brp_finch_enabled, because there are certain modes
- // where BRP protection is actually disabled.
- pcscan_group_name = "Ignore_BRPIsOn";
- } else {
- pcscan_group_name = (pcscan_enabled ? "Enabled" : "Disabled");
- }
- // In case we are incorrect that PCScan is independent of partition-split
- // modes, create a fallback trial that only takes into account the BRP Finch
- // settings that preserve the default behavior.
- if (brp_nondefault_behavior) {
- pcscan_group_name_fallback = "Ignore_BRPIsOn";
- } else {
- pcscan_group_name_fallback = (pcscan_enabled ? "Enabled" : "Disabled");
- }
-#endif // BUILDFLAG(USE_STARSCAN)
- trials.emplace("PCScan_Effective", pcscan_group_name);
- trials.emplace("PCScan_Effective_Fallback", pcscan_group_name_fallback);
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
- trials.emplace("DanglingPointerDetector", "Enabled");
-#else
- trials.emplace("DanglingPointerDetector", "Disabled");
-#endif
-
- return trials;
-}
-
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
-
-namespace {
-
-internal::PartitionLock g_stack_trace_buffer_lock;
-
-struct DanglingPointerFreeInfo {
- debug::StackTrace stack_trace;
- debug::TaskTrace task_trace;
- uintptr_t id = 0;
-};
-using DanglingRawPtrBuffer =
- std::array<absl::optional<DanglingPointerFreeInfo>, 32>;
-DanglingRawPtrBuffer g_stack_trace_buffer GUARDED_BY(g_stack_trace_buffer_lock);
-
-void DanglingRawPtrDetected(uintptr_t id) {
- // This is called from inside the allocator. No allocation is allowed.
-
- internal::PartitionAutoLock guard(g_stack_trace_buffer_lock);
-
-#if DCHECK_IS_ON()
- for (absl::optional<DanglingPointerFreeInfo>& entry : g_stack_trace_buffer) {
- PA_DCHECK(!entry || entry->id != id);
- }
-#endif // DCHECK_IS_ON()
-
- for (absl::optional<DanglingPointerFreeInfo>& entry : g_stack_trace_buffer) {
- if (!entry) {
- entry = {debug::StackTrace(), debug::TaskTrace(), id};
- return;
- }
- }
-
- // The StackTrace hasn't been recorded, because the buffer isn't large
- // enough.
-}
-
-// From the traces recorded in |DanglingRawPtrDetected|, extract the one
-// whose id match |id|. Return nullopt if not found.
-absl::optional<DanglingPointerFreeInfo> TakeDanglingPointerFreeInfo(
- uintptr_t id) {
- internal::PartitionAutoLock guard(g_stack_trace_buffer_lock);
- for (absl::optional<DanglingPointerFreeInfo>& entry : g_stack_trace_buffer) {
- if (entry && entry->id == id) {
- absl::optional<DanglingPointerFreeInfo> result(entry);
- entry = absl::nullopt;
- return result;
- }
- }
- return absl::nullopt;
-}
-
-// Extract from the StackTrace output, the signature of the pertinent caller.
-// This function is meant to be used only by Chromium developers, to list what
-// are all the dangling raw_ptr occurrences in a table.
-std::string ExtractDanglingPtrSignature(std::string stacktrace) {
- std::vector<StringPiece> lines = SplitStringPiece(
- stacktrace, "\r\n", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
-
- // We are looking for the callers of the function releasing the raw_ptr and
- // freeing memory:
- const StringPiece callees[] = {
- // Common signatures
- "internal::PartitionFree",
- "base::(anonymous namespace)::FreeFn",
-
- // Linux signatures
- "internal::RawPtrBackupRefImpl<>::ReleaseInternal()",
- "base::RefCountedThreadSafe<>::Release()",
-
- // Windows signatures
- "internal::RawPtrBackupRefImpl<0>::ReleaseInternal",
- "_free_base",
- // Windows stack traces are prefixed with "Backtrace:"
- "Backtrace:",
-
- // Mac signatures
- "internal::RawPtrBackupRefImpl<false>::ReleaseInternal",
-
- // Task traces are prefixed with "Task trace:" in
- // |TaskTrace::OutputToStream|
- "Task trace:",
- };
- size_t caller_index = 0;
- for (size_t i = 0; i < lines.size(); ++i) {
- for (const auto& callee : callees) {
- if (lines[i].find(callee) != StringPiece::npos) {
- caller_index = i + 1;
- }
- }
- }
- if (caller_index >= lines.size()) {
- return "no_callee_match";
- }
- StringPiece caller = lines[caller_index];
-
- if (caller.empty()) {
- return "invalid_format";
- }
-
- // On Posix platforms |callers| follows the following format:
- //
- // #<index> <address> <symbol>
- //
- // See https://crsrc.org/c/base/debug/stack_trace_posix.cc
- if (caller[0] == '#') {
- const size_t address_start = caller.find(' ');
- const size_t function_start = caller.find(' ', address_start + 1);
-
- if (address_start == caller.npos || function_start == caller.npos) {
- return "invalid_format";
- }
-
- return std::string(caller.substr(function_start + 1));
- }
-
- // On Windows platforms |callers| follows the following format:
- //
- // \t<symbol> [0x<address>]+<displacement>(<filename>:<line>)
- //
- // See https://crsrc.org/c/base/debug/stack_trace_win.cc
- if (caller[0] == '\t') {
- const size_t symbol_start = 1;
- const size_t symbol_end = caller.find(' ');
- if (symbol_end == caller.npos) {
- return "invalid_format";
- }
- return std::string(caller.substr(symbol_start, symbol_end - symbol_start));
- }
-
- // On Mac platforms |callers| follows the following format:
- //
- // <index> <library> 0x<address> <symbol> + <line>
- //
- // See https://crsrc.org/c/base/debug/stack_trace_posix.cc
- if (caller[0] >= '0' && caller[0] <= '9') {
- const size_t address_start = caller.find("0x");
- const size_t symbol_start = caller.find(' ', address_start + 1) + 1;
- const size_t symbol_end = caller.find(' ', symbol_start);
- if (symbol_start == caller.npos || symbol_end == caller.npos) {
- return "invalid_format";
- }
- return std::string(caller.substr(symbol_start, symbol_end - symbol_start));
- }
-
- return "invalid_format";
-}
-
-std::string ExtractDanglingPtrSignature(debug::TaskTrace task_trace) {
- if (task_trace.empty()) {
- return "No active task";
- }
- return ExtractDanglingPtrSignature(task_trace.ToString());
-}
-
-std::string ExtractDanglingPtrSignature(
- absl::optional<DanglingPointerFreeInfo> free_info,
- debug::StackTrace release_stack_trace,
- debug::TaskTrace release_task_trace) {
- if (free_info) {
- return StringPrintf(
- "[DanglingSignature]\t%s\t%s\t%s\t%s",
- ExtractDanglingPtrSignature(free_info->stack_trace.ToString()).c_str(),
- ExtractDanglingPtrSignature(free_info->task_trace).c_str(),
- ExtractDanglingPtrSignature(release_stack_trace.ToString()).c_str(),
- ExtractDanglingPtrSignature(release_task_trace).c_str());
- }
- return StringPrintf(
- "[DanglingSignature]\t%s\t%s\t%s\t%s", "missing", "missing",
- ExtractDanglingPtrSignature(release_stack_trace.ToString()).c_str(),
- ExtractDanglingPtrSignature(release_task_trace).c_str());
-}
-
-template <features::DanglingPtrMode dangling_pointer_mode,
- features::DanglingPtrType dangling_pointer_type>
-void DanglingRawPtrReleased(uintptr_t id) {
- // This is called from raw_ptr<>'s release operation. Making allocations is
- // allowed. In particular, symbolizing and printing the StackTraces may
- // allocate memory.
- debug::StackTrace stack_trace_release;
- debug::TaskTrace task_trace_release;
- absl::optional<DanglingPointerFreeInfo> free_info =
- TakeDanglingPointerFreeInfo(id);
-
- if constexpr (dangling_pointer_type ==
- features::DanglingPtrType::kCrossTask) {
- if (!free_info) {
- return;
- }
- if (task_trace_release.ToString() == free_info->task_trace.ToString()) {
- return;
- }
- }
-
- std::string dangling_signature = ExtractDanglingPtrSignature(
- free_info, stack_trace_release, task_trace_release);
- static const char dangling_ptr_footer[] =
- "\n"
- "\n"
- "Please check for more information on:\n"
- "https://chromium.googlesource.com/chromium/src/+/main/docs/"
- "dangling_ptr_guide.md\n"
- "\n"
- "Googlers: Please give us your feedback about the dangling pointer\n"
- " detector at:\n"
- " http://go/dangling-ptr-cq-survey\n";
- if (free_info) {
- LOG(ERROR) << "Detected dangling raw_ptr with id="
- << StringPrintf("0x%016" PRIxPTR, id) << ":\n"
- << dangling_signature << "\n\n"
- << "The memory was freed at:\n"
- << free_info->stack_trace << "\n"
- << free_info->task_trace << "\n"
- << "The dangling raw_ptr was released at:\n"
- << stack_trace_release << "\n"
- << task_trace_release << dangling_ptr_footer;
- } else {
- LOG(ERROR) << "Detected dangling raw_ptr with id="
- << StringPrintf("0x%016" PRIxPTR, id) << ":\n\n"
- << dangling_signature << "\n\n"
- << "It was not recorded where the memory was freed.\n\n"
- << "The dangling raw_ptr was released at:\n"
- << stack_trace_release << "\n"
- << task_trace_release << dangling_ptr_footer;
- }
-
- if constexpr (dangling_pointer_mode == features::DanglingPtrMode::kCrash) {
- ImmediateCrash();
- }
-}
-
-void ClearDanglingRawPtrBuffer() {
- internal::PartitionAutoLock guard(g_stack_trace_buffer_lock);
- g_stack_trace_buffer = DanglingRawPtrBuffer();
-}
-
-} // namespace
-
-void InstallDanglingRawPtrChecks() {
- // Clearing storage is useful for running multiple unit tests without
- // restarting the test executable.
- ClearDanglingRawPtrBuffer();
-
- if (!FeatureList::IsEnabled(features::kPartitionAllocDanglingPtr)) {
- partition_alloc::SetDanglingRawPtrDetectedFn([](uintptr_t) {});
- partition_alloc::SetDanglingRawPtrReleasedFn([](uintptr_t) {});
- return;
- }
-
- partition_alloc::SetDanglingRawPtrDetectedFn(&DanglingRawPtrDetected);
- switch (features::kDanglingPtrModeParam.Get()) {
- case features::DanglingPtrMode::kCrash:
- switch (features::kDanglingPtrTypeParam.Get()) {
- case features::DanglingPtrType::kAll:
- partition_alloc::SetDanglingRawPtrReleasedFn(
- &DanglingRawPtrReleased<features::DanglingPtrMode::kCrash,
- features::DanglingPtrType::kAll>);
- break;
- case features::DanglingPtrType::kCrossTask:
- partition_alloc::SetDanglingRawPtrReleasedFn(
- &DanglingRawPtrReleased<features::DanglingPtrMode::kCrash,
- features::DanglingPtrType::kCrossTask>);
- break;
- }
- break;
- case features::DanglingPtrMode::kLogOnly:
- switch (features::kDanglingPtrTypeParam.Get()) {
- case features::DanglingPtrType::kAll:
- partition_alloc::SetDanglingRawPtrReleasedFn(
- &DanglingRawPtrReleased<features::DanglingPtrMode::kLogOnly,
- features::DanglingPtrType::kAll>);
- break;
- case features::DanglingPtrType::kCrossTask:
- partition_alloc::SetDanglingRawPtrReleasedFn(
- &DanglingRawPtrReleased<features::DanglingPtrMode::kLogOnly,
- features::DanglingPtrType::kCrossTask>);
- break;
- }
- break;
- }
-}
-
-// TODO(arthursonzogni): There might exist long lived dangling raw_ptr. If there
-// is a dangling pointer, we should crash at some point. Consider providing an
-// API to periodically check the buffer.
-
-#else // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
-void InstallDanglingRawPtrChecks() {}
-#endif // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
-
-void UnretainedDanglingRawPtrDetectedDumpWithoutCrashing(uintptr_t id) {
- PA_NO_CODE_FOLDING();
- debug::DumpWithoutCrashing();
-}
-
-void UnretainedDanglingRawPtrDetectedCrash(uintptr_t id) {
- debug::TaskTrace task_trace;
- debug::StackTrace stack_trace;
- LOG(ERROR) << "Detected dangling raw_ptr in unretained with id="
- << StringPrintf("0x%016" PRIxPTR, id) << ":\n\n"
- << task_trace << stack_trace;
- ImmediateCrash();
-}
-
-void InstallUnretainedDanglingRawPtrChecks() {
- if (!FeatureList::IsEnabled(features::kPartitionAllocUnretainedDanglingPtr)) {
- partition_alloc::SetUnretainedDanglingRawPtrDetectedFn([](uintptr_t) {});
- partition_alloc::SetUnretainedDanglingRawPtrCheckEnabled(/*enabled=*/false);
- return;
- }
-
- partition_alloc::SetUnretainedDanglingRawPtrCheckEnabled(/*enabled=*/true);
- switch (features::kUnretainedDanglingPtrModeParam.Get()) {
- case features::UnretainedDanglingPtrMode::kCrash:
- partition_alloc::SetUnretainedDanglingRawPtrDetectedFn(
- &UnretainedDanglingRawPtrDetectedCrash);
- break;
-
- case features::UnretainedDanglingPtrMode::kDumpWithoutCrashing:
- partition_alloc::SetUnretainedDanglingRawPtrDetectedFn(
- &UnretainedDanglingRawPtrDetectedDumpWithoutCrashing);
- break;
- }
-}
-
-namespace {
-
-#if BUILDFLAG(USE_STARSCAN)
-void SetProcessNameForPCScan(const std::string& process_type) {
- const char* name = [&process_type] {
- if (process_type.empty()) {
- // Empty means browser process.
- return "Browser";
- }
- if (process_type == switches::kRendererProcess) {
- return "Renderer";
- }
- if (process_type == switches::kGpuProcess) {
- return "Gpu";
- }
- if (process_type == switches::kUtilityProcess) {
- return "Utility";
- }
- return static_cast<const char*>(nullptr);
- }();
-
- if (name) {
- partition_alloc::internal::PCScan::SetProcessName(name);
- }
-}
-
-bool EnablePCScanForMallocPartitionsIfNeeded() {
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- using Config = partition_alloc::internal::PCScan::InitConfig;
- DCHECK(base::FeatureList::GetInstance());
- if (base::FeatureList::IsEnabled(base::features::kPartitionAllocPCScan)) {
- allocator_shim::EnablePCScan({Config::WantedWriteProtectionMode::kEnabled,
- Config::SafepointMode::kEnabled});
- base::allocator::RegisterPCScanStatsReporter();
- return true;
- }
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- return false;
-}
-
-bool EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded() {
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- using Config = partition_alloc::internal::PCScan::InitConfig;
- DCHECK(base::FeatureList::GetInstance());
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanBrowserOnly)) {
- const Config::WantedWriteProtectionMode wp_mode =
- base::FeatureList::IsEnabled(base::features::kPartitionAllocDCScan)
- ? Config::WantedWriteProtectionMode::kEnabled
- : Config::WantedWriteProtectionMode::kDisabled;
-#if !PA_CONFIG(STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED)
- CHECK_EQ(Config::WantedWriteProtectionMode::kDisabled, wp_mode)
- << "DCScan is currently only supported on Linux based systems";
-#endif
- allocator_shim::EnablePCScan({wp_mode, Config::SafepointMode::kEnabled});
- base::allocator::RegisterPCScanStatsReporter();
- return true;
- }
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- return false;
-}
-
-bool EnablePCScanForMallocPartitionsInRendererProcessIfNeeded() {
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- using Config = partition_alloc::internal::PCScan::InitConfig;
- DCHECK(base::FeatureList::GetInstance());
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanRendererOnly)) {
- const Config::WantedWriteProtectionMode wp_mode =
- base::FeatureList::IsEnabled(base::features::kPartitionAllocDCScan)
- ? Config::WantedWriteProtectionMode::kEnabled
- : Config::WantedWriteProtectionMode::kDisabled;
-#if !PA_CONFIG(STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED)
- CHECK_EQ(Config::WantedWriteProtectionMode::kDisabled, wp_mode)
- << "DCScan is currently only supported on Linux based systems";
-#endif
- allocator_shim::EnablePCScan({wp_mode, Config::SafepointMode::kDisabled});
- base::allocator::RegisterPCScanStatsReporter();
- return true;
- }
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- return false;
-}
-#endif // BUILDFLAG(USE_STARSCAN)
-
-} // namespace
-
-void ReconfigurePartitionForKnownProcess(const std::string& process_type) {
- DCHECK_NE(process_type, switches::kZygoteProcess);
- // TODO(keishi): Move the code to enable BRP back here after Finch
- // experiments.
-}
-
-PartitionAllocSupport* PartitionAllocSupport::Get() {
- static auto* singleton = new PartitionAllocSupport();
- return singleton;
-}
-
-PartitionAllocSupport::PartitionAllocSupport() = default;
-
-void PartitionAllocSupport::ReconfigureForTests() {
- ReconfigureEarlyish("");
- base::AutoLock scoped_lock(lock_);
- called_for_tests_ = true;
-}
-
-// static
-PartitionAllocSupport::BrpConfiguration
-PartitionAllocSupport::GetBrpConfiguration(const std::string& process_type) {
- // TODO(bartekn): Switch to DCHECK once confirmed there are no issues.
- CHECK(base::FeatureList::GetInstance());
-
- bool enable_brp = false;
- bool enable_brp_zapping = false;
- bool split_main_partition = false;
- bool use_dedicated_aligned_partition = false;
- bool add_dummy_ref_count = false;
- bool process_affected_by_brp_flag = false;
- bool enable_memory_reclaimer = false;
-
-#if (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
- BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) || \
- BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocBackupRefPtr)) {
- // No specified process type means this is the Browser process.
- switch (base::features::kBackupRefPtrEnabledProcessesParam.Get()) {
- case base::features::BackupRefPtrEnabledProcesses::kBrowserOnly:
- process_affected_by_brp_flag = process_type.empty();
- break;
- case base::features::BackupRefPtrEnabledProcesses::kBrowserAndRenderer:
- process_affected_by_brp_flag =
- process_type.empty() ||
- (process_type == switches::kRendererProcess);
- break;
- case base::features::BackupRefPtrEnabledProcesses::kNonRenderer:
- process_affected_by_brp_flag =
- (process_type != switches::kRendererProcess);
- break;
- case base::features::BackupRefPtrEnabledProcesses::kAllProcesses:
- process_affected_by_brp_flag = true;
- break;
- }
- }
-#endif // (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
- // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) ||
- // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
- BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- if (process_affected_by_brp_flag) {
- switch (base::features::kBackupRefPtrModeParam.Get()) {
- case base::features::BackupRefPtrMode::kDisabled:
- // Do nothing. Equivalent to !IsEnabled(kPartitionAllocBackupRefPtr).
- break;
-
- case base::features::BackupRefPtrMode::kEnabledWithMemoryReclaimer:
- enable_memory_reclaimer = true;
- ABSL_FALLTHROUGH_INTENDED;
- case base::features::BackupRefPtrMode::kEnabled:
- enable_brp_zapping = true;
- ABSL_FALLTHROUGH_INTENDED;
- case base::features::BackupRefPtrMode::kEnabledWithoutZapping:
- enable_brp = true;
- split_main_partition = true;
-#if !BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- // AlignedAlloc relies on natural alignment offered by the allocator
- // (see the comment inside PartitionRoot::AlignedAllocFlags). Any extras
- // in front of the allocation will mess up that alignment. Such extras
- // are used when BackupRefPtr is on, in which case, we need a separate
- // partition, dedicated to handle only aligned allocations, where those
- // extras are disabled. However, if the "previous slot" variant is used,
- // no dedicated partition is needed, as the extras won't interfere with
- // the alignment requirements.
- use_dedicated_aligned_partition = true;
-#endif
- break;
-
- case base::features::BackupRefPtrMode::kDisabledButSplitPartitions2Way:
- split_main_partition = true;
- break;
-
- case base::features::BackupRefPtrMode::
- kDisabledButSplitPartitions2WayWithMemoryReclaimer:
- split_main_partition = true;
- enable_memory_reclaimer = true;
- break;
-
- case base::features::BackupRefPtrMode::kDisabledButSplitPartitions3Way:
- split_main_partition = true;
- use_dedicated_aligned_partition = true;
- break;
-
- case base::features::BackupRefPtrMode::kDisabledButAddDummyRefCount:
- split_main_partition = true;
- add_dummy_ref_count = true;
-#if !BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- use_dedicated_aligned_partition = true;
-#endif
- break;
- }
- }
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
- // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
-
- return {enable_brp,
- enable_brp_zapping,
- enable_memory_reclaimer,
- split_main_partition,
- use_dedicated_aligned_partition,
- add_dummy_ref_count,
- process_affected_by_brp_flag};
-}
-
-void PartitionAllocSupport::ReconfigureEarlyish(
- const std::string& process_type) {
- {
- base::AutoLock scoped_lock(lock_);
-
- // In tests, ReconfigureEarlyish() is called by ReconfigureForTest(), which
- // is earlier than ContentMain().
- if (called_for_tests_) {
- DCHECK(called_earlyish_);
- return;
- }
-
- // TODO(bartekn): Switch to DCHECK once confirmed there are no issues.
- CHECK(!called_earlyish_)
- << "ReconfigureEarlyish was already called for process '"
- << established_process_type_ << "'; current process: '" << process_type
- << "'";
-
- called_earlyish_ = true;
- established_process_type_ = process_type;
- }
-
- if (process_type != switches::kZygoteProcess) {
- ReconfigurePartitionForKnownProcess(process_type);
- }
-
- // These initializations are only relevant for PartitionAlloc-Everywhere
- // builds.
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- allocator_shim::EnablePartitionAllocMemoryReclaimer();
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-}
-
-void PartitionAllocSupport::ReconfigureAfterZygoteFork(
- const std::string& process_type) {
- {
- base::AutoLock scoped_lock(lock_);
- // TODO(bartekn): Switch to DCHECK once confirmed there are no issues.
- CHECK(!called_after_zygote_fork_)
- << "ReconfigureAfterZygoteFork was already called for process '"
- << established_process_type_ << "'; current process: '" << process_type
- << "'";
- DCHECK(called_earlyish_)
- << "Attempt to call ReconfigureAfterZygoteFork without calling "
- "ReconfigureEarlyish; current process: '"
- << process_type << "'";
- DCHECK_EQ(established_process_type_, switches::kZygoteProcess)
- << "Attempt to call ReconfigureAfterZygoteFork while "
- "ReconfigureEarlyish was called on non-zygote process '"
- << established_process_type_ << "'; current process: '" << process_type
- << "'";
-
- called_after_zygote_fork_ = true;
- established_process_type_ = process_type;
- }
-
- if (process_type != switches::kZygoteProcess) {
- ReconfigurePartitionForKnownProcess(process_type);
- }
-}
-
-void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
- const std::string& process_type,
- bool configure_dangling_pointer_detector) {
- if (configure_dangling_pointer_detector) {
- base::allocator::InstallDanglingRawPtrChecks();
- }
- base::allocator::InstallUnretainedDanglingRawPtrChecks();
- {
- base::AutoLock scoped_lock(lock_);
- // Avoid initializing more than once.
- // TODO(bartekn): See if can be converted to (D)CHECK.
- if (called_after_feature_list_init_) {
- DCHECK_EQ(established_process_type_, process_type)
- << "ReconfigureAfterFeatureListInit was already called for process '"
- << established_process_type_ << "'; current process: '"
- << process_type << "'";
- return;
- }
- DCHECK(called_earlyish_)
- << "Attempt to call ReconfigureAfterFeatureListInit without calling "
- "ReconfigureEarlyish; current process: '"
- << process_type << "'";
- DCHECK_NE(established_process_type_, switches::kZygoteProcess)
- << "Attempt to call ReconfigureAfterFeatureListInit without calling "
- "ReconfigureAfterZygoteFork; current process: '"
- << process_type << "'";
- DCHECK_EQ(established_process_type_, process_type)
- << "ReconfigureAfterFeatureListInit wasn't called for an already "
- "established process '"
- << established_process_type_ << "'; current process: '" << process_type
- << "'";
-
- called_after_feature_list_init_ = true;
- }
-
- DCHECK_NE(process_type, switches::kZygoteProcess);
- [[maybe_unused]] BrpConfiguration brp_config =
- GetBrpConfiguration(process_type);
-
-#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
- if (brp_config.process_affected_by_brp_flag) {
- base::RawPtrAsanService::GetInstance().Configure(
- base::EnableDereferenceCheck(
- base::features::kBackupRefPtrAsanEnableDereferenceCheckParam.Get()),
- base::EnableExtractionCheck(
- base::features::kBackupRefPtrAsanEnableExtractionCheckParam.Get()),
- base::EnableInstantiationCheck(
- base::features::kBackupRefPtrAsanEnableInstantiationCheckParam
- .Get()));
- } else {
- base::RawPtrAsanService::GetInstance().Configure(
- base::EnableDereferenceCheck(false), base::EnableExtractionCheck(false),
- base::EnableInstantiationCheck(false));
- }
-#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- // No specified type means we are in the browser.
- auto bucket_distribution =
- process_type == ""
- ? base::features::kPartitionAllocAlternateBucketDistributionParam
- .Get()
- : base::features::AlternateBucketDistributionMode::kDefault;
-
- allocator_shim::ConfigurePartitions(
- allocator_shim::EnableBrp(brp_config.enable_brp),
- allocator_shim::EnableBrpZapping(brp_config.enable_brp_zapping),
- allocator_shim::EnableBrpPartitionMemoryReclaimer(
- brp_config.enable_brp_partition_memory_reclaimer),
- allocator_shim::SplitMainPartition(brp_config.split_main_partition),
- allocator_shim::UseDedicatedAlignedPartition(
- brp_config.use_dedicated_aligned_partition),
- allocator_shim::AddDummyRefCount(brp_config.add_dummy_ref_count),
- allocator_shim::AlternateBucketDistribution(bucket_distribution));
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
- // If BRP is not enabled, check if any of PCScan flags is enabled.
- [[maybe_unused]] bool scan_enabled = false;
-#if BUILDFLAG(USE_STARSCAN)
- if (!brp_config.enable_brp) {
- scan_enabled = EnablePCScanForMallocPartitionsIfNeeded();
- // No specified process type means this is the Browser process.
- if (process_type.empty()) {
- scan_enabled = scan_enabled ||
- EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded();
- }
- if (process_type == switches::kRendererProcess) {
- scan_enabled = scan_enabled ||
- EnablePCScanForMallocPartitionsInRendererProcessIfNeeded();
- }
- if (scan_enabled) {
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanStackScanning)) {
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- partition_alloc::internal::PCScan::EnableStackScanning();
- // Notify PCScan about the main thread.
- partition_alloc::internal::PCScan::NotifyThreadCreated(
- partition_alloc::internal::GetStackTop());
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- }
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanImmediateFreeing)) {
- partition_alloc::internal::PCScan::EnableImmediateFreeing();
- }
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanEagerClearing)) {
- partition_alloc::internal::PCScan::SetClearType(
- partition_alloc::internal::PCScan::ClearType::kEager);
- }
- SetProcessNameForPCScan(process_type);
- }
- }
-#endif // BUILDFLAG(USE_STARSCAN)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-#if BUILDFLAG(USE_STARSCAN)
- // Non-quarantinable partition is dealing with hot V8's zone allocations.
- // In case PCScan is enabled in Renderer, enable thread cache on this
- // partition. At the same time, thread cache on the main(malloc) partition
- // must be disabled, because only one partition can have it on.
- if (scan_enabled && process_type == switches::kRendererProcess) {
- base::internal::NonQuarantinableAllocator::Instance()
- .root()
- ->EnableThreadCacheIfSupported();
- } else
-#endif // BUILDFLAG(USE_STARSCAN)
- {
- allocator_shim::internal::PartitionAllocMalloc::Allocator()
- ->EnableThreadCacheIfSupported();
- }
-
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocLargeEmptySlotSpanRing)) {
- allocator_shim::internal::PartitionAllocMalloc::Allocator()
- ->EnableLargeEmptySlotSpanRing();
- allocator_shim::internal::PartitionAllocMalloc::AlignedAllocator()
- ->EnableLargeEmptySlotSpanRing();
- }
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-#if BUILDFLAG(IS_WIN)
- // Browser process only, since this is the one we want to prevent from
- // crashing the most (as it takes down all the tabs).
- if (base::FeatureList::IsEnabled(
- base::features::kPageAllocatorRetryOnCommitFailure) &&
- process_type.empty()) {
- partition_alloc::SetRetryOnCommitFailure(true);
- }
-#endif
-}
-
-void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
- const std::string& process_type) {
- {
- base::AutoLock scoped_lock(lock_);
-
- // Init only once.
- if (called_after_thread_pool_init_) {
- return;
- }
-
- DCHECK_EQ(established_process_type_, process_type);
- // Enforce ordering.
- DCHECK(called_earlyish_);
- DCHECK(called_after_feature_list_init_);
-
- called_after_thread_pool_init_ = true;
- }
-
-#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
- BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- // This should be called in specific processes, as the main thread is
- // initialized later.
- DCHECK(process_type != switches::kZygoteProcess);
-
- base::allocator::StartThreadCachePeriodicPurge();
-
-#if BUILDFLAG(IS_ANDROID)
- // Lower thread cache limits to avoid stranding too much memory in the caches.
- if (base::SysInfo::IsLowEndDeviceOrPartialLowEndModeEnabled()) {
- ::partition_alloc::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier(
- ::partition_alloc::ThreadCache::kDefaultMultiplier / 2.);
- }
-#endif // BUILDFLAG(IS_ANDROID)
-
- // Renderer processes are more performance-sensitive, increase thread cache
- // limits.
- if (process_type == switches::kRendererProcess &&
- base::FeatureList::IsEnabled(
- base::features::kPartitionAllocLargeThreadCacheSize)) {
- largest_cached_size_ =
- ::partition_alloc::ThreadCacheLimits::kLargeSizeThreshold;
-
-#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
- // Devices almost always report less physical memory than what they actually
- // have, so anything above 3GiB will catch 4GiB and above.
- if (base::SysInfo::AmountOfPhysicalMemoryMB() <= 3500) {
- largest_cached_size_ =
- ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold;
- }
-#endif // BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS)
-
- ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size_);
- }
-#endif // PA_CONFIG(THREAD_CACHE_SUPPORTED) &&
- // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-#if BUILDFLAG(USE_STARSCAN)
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocPCScanMUAwareScheduler)) {
- // Assign PCScan a task-based scheduling backend.
- static base::NoDestructor<
- partition_alloc::internal::MUAwareTaskBasedBackend>
- mu_aware_task_based_backend{
- partition_alloc::internal::PCScan::scheduler(),
- &partition_alloc::internal::PCScan::PerformDelayedScan};
- partition_alloc::internal::PCScan::scheduler().SetNewSchedulingBackend(
- *mu_aware_task_based_backend.get());
- }
-#endif // BUILDFLAG(USE_STARSCAN)
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- base::allocator::StartMemoryReclaimer(
- base::SingleThreadTaskRunner::GetCurrentDefault());
-#endif
-
- if (base::FeatureList::IsEnabled(
- base::features::kPartitionAllocSortActiveSlotSpans)) {
- partition_alloc::PartitionRoot<
- partition_alloc::internal::ThreadSafe>::EnableSortActiveSlotSpans();
- }
-}
-
-void PartitionAllocSupport::OnForegrounded(bool has_main_frame) {
-#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
- BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- {
- base::AutoLock scoped_lock(lock_);
- if (established_process_type_ != switches::kRendererProcess) {
- return;
- }
- }
-
- if (!base::FeatureList::IsEnabled(
- features::kLowerPAMemoryLimitForNonMainRenderers) ||
- has_main_frame) {
- ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size_);
- }
-#endif // PA_CONFIG(THREAD_CACHE_SUPPORTED) &&
- // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-}
-
-void PartitionAllocSupport::OnBackgrounded() {
-#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
- BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- {
- base::AutoLock scoped_lock(lock_);
- if (established_process_type_ != switches::kRendererProcess) {
- return;
- }
- }
-
- // Performance matters less for background renderers, don't pay the memory
- // cost.
- ::partition_alloc::ThreadCache::SetLargestCachedSize(
- ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold);
-
- // In renderers, memory reclaim uses the "idle time" task runner to run
- // periodic reclaim. This does not always run when the renderer is idle, and
- // in particular after the renderer gets backgrounded. As a result, empty slot
- // spans are potentially never decommitted. To mitigate that, run a one-off
- // reclaim a few seconds later. Even if the renderer comes back to foreground
- // in the meantime, the worst case is a few more system calls.
- //
- // TODO(lizeb): Remove once/if the behavior of idle tasks changes.
- base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
- FROM_HERE, base::BindOnce([]() {
- ::partition_alloc::MemoryReclaimer::Instance()->ReclaimAll();
- }),
- base::Seconds(10));
-
-#endif // PA_CONFIG(THREAD_CACHE_SUPPORTED) &&
- // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-}
-
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
-std::string PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
- std::string stacktrace) {
- return ExtractDanglingPtrSignature(stacktrace);
-}
-#endif
-
-} // namespace base::allocator
diff --git a/base/allocator/partition_alloc_support.h b/base/allocator/partition_alloc_support.h
deleted file mode 100644
index f9095a3..0000000
--- a/base/allocator/partition_alloc_support.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_ALLOCATOR_PARTITION_ALLOC_SUPPORT_H_
-#define BASE_ALLOCATOR_PARTITION_ALLOC_SUPPORT_H_
-
-#include <map>
-#include <string>
-
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/allocator/partition_allocator/partition_alloc_config.h"
-#include "base/allocator/partition_allocator/thread_cache.h"
-#include "base/base_export.h"
-#include "base/memory/scoped_refptr.h"
-#include "base/synchronization/lock.h"
-#include "base/task/sequenced_task_runner.h"
-#include "base/thread_annotations.h"
-
-namespace base::allocator {
-
-#if BUILDFLAG(USE_STARSCAN)
-BASE_EXPORT void RegisterPCScanStatsReporter();
-#endif
-
-// Starts a periodic timer on the current thread to purge all thread caches.
-BASE_EXPORT void StartThreadCachePeriodicPurge();
-
-BASE_EXPORT void StartMemoryReclaimer(
- scoped_refptr<SequencedTaskRunner> task_runner);
-
-BASE_EXPORT std::map<std::string, std::string> ProposeSyntheticFinchTrials();
-
-// Install handlers for when dangling raw_ptr(s) have been detected. This prints
-// two StackTraces. One where the memory is freed, one where the last dangling
-// raw_ptr stopped referencing it.
-//
-// This is currently effective, only when compiled with
-// `enable_dangling_raw_ptr_checks` build flag.
-BASE_EXPORT void InstallDanglingRawPtrChecks();
-BASE_EXPORT void InstallUnretainedDanglingRawPtrChecks();
-
-// Allows to re-configure PartitionAlloc at run-time.
-class BASE_EXPORT PartitionAllocSupport {
- public:
- struct BrpConfiguration {
- bool enable_brp = false;
- bool enable_brp_zapping = false;
- bool enable_brp_partition_memory_reclaimer = false;
- bool split_main_partition = false;
- bool use_dedicated_aligned_partition = false;
- bool add_dummy_ref_count = false;
- bool process_affected_by_brp_flag = false;
- };
- // Reconfigure* functions re-configure PartitionAlloc. It is impossible to
- // configure PartitionAlloc before/at its initialization using information not
- // known at compile-time (e.g. process type, Finch), because by the time this
- // information is available memory allocations would have surely happened,
- // that requiring a functioning allocator.
- //
- // *Earlyish() is called as early as it is reasonably possible.
- // *AfterZygoteFork() is its complement to finish configuring process-specific
- // stuff that had to be postponed due to *Earlyish() being called with
- // |process_type==kZygoteProcess|.
- // *AfterFeatureListInit() is called in addition to the above, once
- // FeatureList has been initialized and ready to use. It is guaranteed to be
- // called on non-zygote processes or after the zygote has been forked.
- // *AfterTaskRunnerInit() is called once it is possible to post tasks, and
- // after the previous steps.
- //
- // *Earlyish() must be called exactly once. *AfterZygoteFork() must be called
- // once iff *Earlyish() was called before with |process_type==kZygoteProcess|.
- //
- // *AfterFeatureListInit() may be called more than once, but will perform its
- // re-configuration steps exactly once.
- //
- // *AfterTaskRunnerInit() may be called more than once.
- void ReconfigureForTests();
- void ReconfigureEarlyish(const std::string& process_type);
- void ReconfigureAfterZygoteFork(const std::string& process_type);
- void ReconfigureAfterFeatureListInit(
- const std::string& process_type,
- bool configure_dangling_pointer_detector = true);
- void ReconfigureAfterTaskRunnerInit(const std::string& process_type);
-
- // |has_main_frame| tells us if the renderer contains a main frame.
- void OnForegrounded(bool has_main_frame);
- void OnBackgrounded();
-
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
- static std::string ExtractDanglingPtrSignatureForTests(
- std::string stacktrace);
-#endif
-
- static PartitionAllocSupport* Get();
-
- static BrpConfiguration GetBrpConfiguration(const std::string& process_type);
-
- private:
- PartitionAllocSupport();
-
- base::Lock lock_;
- bool called_for_tests_ GUARDED_BY(lock_) = false;
- bool called_earlyish_ GUARDED_BY(lock_) = false;
- bool called_after_zygote_fork_ GUARDED_BY(lock_) = false;
- bool called_after_feature_list_init_ GUARDED_BY(lock_) = false;
- bool called_after_thread_pool_init_ GUARDED_BY(lock_) = false;
- std::string established_process_type_ GUARDED_BY(lock_) = "INVALID";
-
-#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
- BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- size_t largest_cached_size_ =
- ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold;
-#endif
-};
-
-} // namespace base::allocator
-
-#endif // BASE_ALLOCATOR_PARTITION_ALLOC_SUPPORT_H_
diff --git a/base/allocator/partition_alloc_support_unittest.cc b/base/allocator/partition_alloc_support_unittest.cc
deleted file mode 100644
index 13a6da5..0000000
--- a/base/allocator/partition_alloc_support_unittest.cc
+++ /dev/null
@@ -1,385 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/allocator/partition_alloc_support.h"
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/allocator/partition_alloc_features.h"
-#include "base/allocator/partition_allocator/dangling_raw_ptr_checks.h"
-#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
-#include "base/feature_list.h"
-#include "base/task/single_thread_task_runner.h"
-#include "base/test/gtest_util.h"
-#include "base/test/scoped_feature_list.h"
-#include "base/test/task_environment.h"
-#include "build/build_config.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace base {
-namespace allocator {
-
-using testing::AllOf;
-using testing::HasSubstr;
-
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-TEST(PartitionAllocSupportTest, ProposeSyntheticFinchTrials_BRPAndPCScan) {
- for (bool pcscan_enabled : {false, true}) {
- test::ScopedFeatureList pcscan_scope;
- std::vector<test::FeatureRef> empty_list = {};
- std::vector<test::FeatureRef> pcscan_list = {
- features::kPartitionAllocPCScanBrowserOnly};
- pcscan_scope.InitWithFeatures(pcscan_enabled ? pcscan_list : empty_list,
- pcscan_enabled ? empty_list : pcscan_list);
-#if !BUILDFLAG(USE_STARSCAN)
- pcscan_enabled = false;
-#endif
-
- std::string brp_expectation;
- std::string pcscan_expectation;
-
- {
- test::ScopedFeatureList brp_scope;
- brp_scope.InitWithFeatures({}, {features::kPartitionAllocBackupRefPtr});
-
- brp_expectation = "Unavailable";
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" : "Ignore_NoGroup";
-#endif
- pcscan_expectation = "Unavailable";
-#if BUILDFLAG(USE_STARSCAN)
- pcscan_expectation = pcscan_enabled ? "Enabled" : "Disabled";
-#endif
-
- auto trials = ProposeSyntheticFinchTrials();
- auto group_iter = trials.find("BackupRefPtr_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, brp_expectation);
- group_iter = trials.find("PCScan_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation);
- group_iter = trials.find("PCScan_Effective_Fallback");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation);
- }
-
- {
- test::ScopedFeatureList brp_scope;
- brp_scope.InitAndEnableFeatureWithParameters(
- features::kPartitionAllocBackupRefPtr, {});
-
- brp_expectation = "Unavailable";
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn"
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || \
- (BUILDFLAG(USE_ASAN_BACKUP_REF_PTR) && BUILDFLAG(IS_LINUX)) || \
- BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG)
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- : "EnabledPrevSlot_NonRenderer";
-#else
- : "EnabledBeforeAlloc_NonRenderer";
-#endif // BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
-#else
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- : "EnabledPrevSlot_BrowserOnly";
-#else
- : "EnabledBeforeAlloc_BrowserOnly";
-#endif // BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
-#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) ||
- // (BUILDFLAG(USE_ASAN_BACKUP_REF_PTR) && BUILDFLAG(IS_LINUX))
-#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- pcscan_expectation = "Unavailable";
-#if BUILDFLAG(USE_STARSCAN)
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- pcscan_expectation = "Ignore_BRPIsOn";
-#else
- pcscan_expectation = pcscan_enabled ? "Enabled" : "Disabled";
-#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
-#endif // BUILDFLAG(USE_STARSCAN)
-
- auto trials = ProposeSyntheticFinchTrials();
- auto group_iter = trials.find("BackupRefPtr_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, brp_expectation);
- group_iter = trials.find("PCScan_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation);
- group_iter = trials.find("PCScan_Effective_Fallback");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation);
- }
-
- const std::string kEnabledMode =
-#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT)
- "PrevSlot_";
-#else
- "BeforeAlloc_";
-#endif
- const std::vector<std::pair<std::string, std::string>> kModes = {
- {"disabled", "Disabled"},
- {"enabled", "Enabled" + kEnabledMode},
- {"disabled-but-2-way-split", "DisabledBut2WaySplit_"},
- {"disabled-but-3-way-split", "DisabledBut3WaySplit_"}};
- const std::vector<std::pair<std::string, std::string>> kProcesses = {
- {"browser-only", "BrowserOnly"},
- {"browser-and-renderer", "BrowserAndRenderer"},
- {"non-renderer", "NonRenderer"},
- {"all-processes", "AllProcesses"}};
-
- for (auto mode : kModes) {
- for (auto process_set : kProcesses) {
- test::ScopedFeatureList brp_scope;
- brp_scope.InitAndEnableFeatureWithParameters(
- features::kPartitionAllocBackupRefPtr,
- {{"brp-mode", mode.first},
- {"enabled-processes", process_set.first}});
-
- [[maybe_unused]] bool brp_truly_enabled = false;
- [[maybe_unused]] bool brp_nondefault_behavior = false;
- brp_expectation = "Unavailable";
-#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" : mode.second;
- brp_truly_enabled = (mode.first == "enabled");
- brp_nondefault_behavior = (mode.first != "disabled");
-#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
- if (brp_expectation[brp_expectation.length() - 1] == '_') {
- brp_expectation += process_set.second;
- }
- pcscan_expectation = "Unavailable";
- std::string pcscan_expectation_fallback = "Unavailable";
-#if BUILDFLAG(USE_STARSCAN)
- pcscan_expectation = brp_truly_enabled
- ? "Ignore_BRPIsOn"
- : (pcscan_enabled ? "Enabled" : "Disabled");
- pcscan_expectation_fallback =
- brp_nondefault_behavior ? "Ignore_BRPIsOn"
- : (pcscan_enabled ? "Enabled" : "Disabled");
-#endif // BUILDFLAG(USE_STARSCAN)
-
- auto trials = ProposeSyntheticFinchTrials();
- auto group_iter = trials.find("BackupRefPtr_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, brp_expectation);
- group_iter = trials.find("PCScan_Effective");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation);
- group_iter = trials.find("PCScan_Effective_Fallback");
- EXPECT_NE(group_iter, trials.end());
- EXPECT_EQ(group_iter->second, pcscan_expectation_fallback);
- }
- }
- }
-}
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
-
-TEST(PartitionAllocSupportTest,
- ProposeSyntheticFinchTrials_DanglingPointerDetector) {
- std::string dpd_group =
- ProposeSyntheticFinchTrials()["DanglingPointerDetector"];
-
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
- EXPECT_EQ(dpd_group, "Enabled");
-#else
- EXPECT_EQ(dpd_group, "Disabled");
-#endif
-}
-
-// - Death tests misbehave on Android, http://crbug.com/643760.
-#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS) && !BUILDFLAG(IS_ANDROID) && \
- defined(GTEST_HAS_DEATH_TEST)
-
-namespace {
-
-// Install dangling raw_ptr handler and restore them when going out of scope.
-class ScopedInstallDanglingRawPtrChecks {
- public:
- struct ConstructorParams {
- std::string mode = "crash";
- std::string type = "all";
- };
- ScopedInstallDanglingRawPtrChecks(ConstructorParams params) {
- enabled_feature_list_.InitWithFeaturesAndParameters(
- {{features::kPartitionAllocDanglingPtr,
- {{"mode", params.mode}, {"type", params.type}}}},
- {/* disabled_features */});
-
- old_detected_fn_ = partition_alloc::GetDanglingRawPtrDetectedFn();
- old_dereferenced_fn_ = partition_alloc::GetDanglingRawPtrReleasedFn();
- InstallDanglingRawPtrChecks();
- }
- ScopedInstallDanglingRawPtrChecks()
- : ScopedInstallDanglingRawPtrChecks(ConstructorParams{}) {}
- ~ScopedInstallDanglingRawPtrChecks() {
- partition_alloc::SetDanglingRawPtrDetectedFn(old_detected_fn_);
- partition_alloc::SetDanglingRawPtrReleasedFn(old_dereferenced_fn_);
- }
-
- private:
- test::ScopedFeatureList enabled_feature_list_;
- partition_alloc::DanglingRawPtrDetectedFn* old_detected_fn_;
- partition_alloc::DanglingRawPtrReleasedFn* old_dereferenced_fn_;
-};
-
-} // namespace
-
-TEST(PartitionAllocDanglingPtrChecks, Basic) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks;
- partition_alloc::GetDanglingRawPtrDetectedFn()(42);
- EXPECT_DEATH(
- partition_alloc::GetDanglingRawPtrReleasedFn()(42),
- AllOf(HasSubstr("Detected dangling raw_ptr with id=0x000000000000002a:"),
- HasSubstr("[DanglingSignature]\t"),
- HasSubstr("The memory was freed at:"),
- HasSubstr("The dangling raw_ptr was released at:")));
-}
-
-// The StackTrace buffer might run out of storage and not record where the
-// memory was freed. Anyway, it must still report the error.
-TEST(PartitionAllocDanglingPtrChecks, FreeNotRecorded) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks;
- EXPECT_DEATH(
- partition_alloc::GetDanglingRawPtrReleasedFn()(42),
- AllOf(HasSubstr("Detected dangling raw_ptr with id=0x000000000000002a:"),
- HasSubstr("[DanglingSignature]\tmissing\tmissing\t"),
- HasSubstr("It was not recorded where the memory was freed."),
- HasSubstr("The dangling raw_ptr was released at:")));
-}
-
-// DCHECK message are stripped in official build. It causes death tests with
-// matchers to fail.
-#if !defined(OFFICIAL_BUILD) || !defined(NDEBUG)
-TEST(PartitionAllocDanglingPtrChecks, DoubleDetection) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks;
- partition_alloc::GetDanglingRawPtrDetectedFn()(42);
- EXPECT_DCHECK_DEATH_WITH(partition_alloc::GetDanglingRawPtrDetectedFn()(42),
- "Check failed: !entry \\|\\| entry->id != id");
-}
-#endif // !defined(OFFICIAL_BUILD) || !defined(NDEBUG)
-
-// Free and release from two different tasks with cross task dangling pointer
-// detection enabled.
-TEST(PartitionAllocDanglingPtrChecks, CrossTask) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks({
- .type = "cross_task",
- });
-
- base::test::TaskEnvironment task_environment;
- task_environment.GetMainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::BindOnce(partition_alloc::GetDanglingRawPtrDetectedFn(), 42));
- task_environment.GetMainThreadTaskRunner()->PostTask(
- FROM_HERE, base::BindOnce([]() {
- BASE_EXPECT_DEATH(
- partition_alloc::GetDanglingRawPtrReleasedFn()(42),
- AllOf(HasSubstr(
- "Detected dangling raw_ptr with id=0x000000000000002a:"),
- HasSubstr("[DanglingSignature]\t"),
- HasSubstr("The memory was freed at:"),
- HasSubstr("The dangling raw_ptr was released at:")));
- }));
- task_environment.RunUntilIdle();
-}
-
-TEST(PartitionAllocDanglingPtrChecks, CrossTaskIgnoredFailuresClearsCache) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks({
- .type = "cross_task",
- });
-
- base::test::TaskEnvironment task_environment;
- partition_alloc::GetDanglingRawPtrDetectedFn()(42);
- partition_alloc::GetDanglingRawPtrReleasedFn()(42);
- task_environment.GetMainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::BindOnce(partition_alloc::GetDanglingRawPtrReleasedFn(), 42));
- task_environment.RunUntilIdle();
-}
-
-TEST(PartitionAllocDanglingPtrChecks, CrossTaskIgnoresNoTask) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks({
- .type = "cross_task",
- });
-
- partition_alloc::GetDanglingRawPtrDetectedFn()(42);
- partition_alloc::GetDanglingRawPtrReleasedFn()(42);
-}
-
-TEST(PartitionAllocDanglingPtrChecks, CrossTaskIgnoresSameTask) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks({
- .type = "cross_task",
- });
-
- base::test::TaskEnvironment task_environment;
- task_environment.GetMainThreadTaskRunner()->PostTask(
- FROM_HERE, base::BindOnce([]() {
- partition_alloc::GetDanglingRawPtrDetectedFn()(37);
- partition_alloc::GetDanglingRawPtrReleasedFn()(37);
- }));
- task_environment.RunUntilIdle();
-}
-
-TEST(PartitionAllocDanglingPtrChecks, CrossTaskNoFreeConsideredCrossTask) {
- ScopedInstallDanglingRawPtrChecks scoped_install_dangling_checks({
- .type = "cross_task",
- });
- partition_alloc::GetDanglingRawPtrReleasedFn()(42);
-}
-
-TEST(PartitionAllocDanglingPtrChecks,
- ExtractDanglingPtrSignatureMacStackTrace) {
- const std::string stack_trace_output =
- "0 lib_1 0x0000000115fdfa12 base::F1(**) + 18\r\n"
- "1 lib_1 0x0000000115ec0043 base::F2() + 19\r\n"
- "2 lib_1 0x000000011601fb01 "
- "allocator_shim::internal::PartitionFree(foo) + 13265\r\n"
- "3 lib_1 0x0000000114831027 base::F3(bar) + 42\r\n"
- "4 lib_2 0x00000001148eae35 base::F4() + 437\r\n";
- EXPECT_EQ("base::F3(bar)",
- PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
- stack_trace_output));
-}
-
-TEST(PartitionAllocDanglingPtrChecks, ExtractDanglingPtrSignatureMacTaskTrace) {
- const std::string task_trace_output =
- "Task trace:\r\n"
- "0 lib_1 0x00000001161fd431 base::F1() + 257\r\n"
- "1 lib_1 0x0000000115a49404 base::F2() + 68\r\n";
- EXPECT_EQ("base::F1()",
- PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
- task_trace_output));
-}
-
-TEST(PartitionAllocDanglingPtrChecks,
- ExtractDanglingPtrSignatureWindowsStackTrace) {
- const std::string stack_trace_output =
- "Backtrace:\r\n"
- "\tbase::F1 [0x055643C3+19] (o:\\base\\F1.cc:329)\r\n"
- "\tallocator_shim::internal::PartitionFree [0x0648F87B+5243] "
- "(o:\\path.cc:441)\r\n"
- "\t_free_base [0x0558475D+29] (o:\\file_path.cc:142)\r\n"
- "\tbase::F2 [0x04E5B317+23] (o:\\base\\F2.cc:91)\r\n"
- "\tbase::F3 [0x04897800+544] (o:\\base\\F3.cc:638)\r\n";
- EXPECT_EQ("base::F2",
- PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
- stack_trace_output));
-}
-
-TEST(PartitionAllocDanglingPtrChecks,
- ExtractDanglingPtrSignatureWindowsTaskTrace) {
- const std::string task_trace_output =
- "Task trace:\r\n"
- "Backtrace:\r\n"
- "\tbase::F1 [0x049068A3+813] (o:\\base\\F1.cc:207)\r\n"
- "\tbase::F2 [0x0490614C+192] (o:\\base\\F2.cc:116)\r\n";
- EXPECT_EQ("base::F1",
- PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
- task_trace_output));
-}
-
-#endif
-
-} // namespace allocator
-} // namespace base
diff --git a/base/allocator/partition_allocator/.gn b/base/allocator/partition_allocator/.gn
deleted file mode 100644
index ee3f918..0000000
--- a/base/allocator/partition_allocator/.gn
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2022 The Chromium Authors<