-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-subtree-dir: base git-subtree-split: 1759c6ae9316996b9f150c0ce9d0ca78a3d15c02
- Loading branch information
0 parents
commit 8edf8dd
Showing
3,349 changed files
with
659,087 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
monorail { | ||
component: "Internals>Core" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# See //base/README.md to find qualification for being an owner. | ||
|
||
set noparent | ||
# NOTE: keep this in sync with [email protected] owners | ||
# by emailing [email protected] when this list changes. | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
# NOTE: keep this in sync with [email protected] owners | ||
# by emailing [email protected] 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*[email protected] | ||
per-file feature_list*[email protected] | ||
per-file feature_list*[email protected] | ||
|
||
# Logging-related changes: | ||
per-file check*[email protected] | ||
per-file check*[email protected] | ||
per-file dcheck*[email protected] | ||
per-file dcheck*[email protected] | ||
per-file logging*[email protected] | ||
per-file logging*[email protected] | ||
per-file [email protected] | ||
per-file [email protected] | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 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. | ||
[email protected] | ||
[email protected] | ||
[email protected] |
Oops, something went wrong.