Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into master.lion
Browse files Browse the repository at this point in the history
# Conflicts:
#	base/BUILD.gn
  • Loading branch information
blueboxd committed Feb 13, 2023
2 parents fe68b88 + 876e6f0 commit 6eb3fe0
Show file tree
Hide file tree
Showing 6,453 changed files with 116,125 additions and 72,307 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Anton Obzhirov <[email protected]>
Antonin Hildebrand <[email protected]>
Antonio Gomes <[email protected]>
Anuj Kumar Sharma <[email protected]>
Ao Hui <[email protected]>
Ao Sun <[email protected]>
Ao Wang <[email protected]>
Aquibuzzaman Md. Sayem <[email protected]>
Expand Down Expand Up @@ -743,6 +744,7 @@ Li Yanbo <[email protected]>
Li Yin <[email protected]>
Lidwine Genevet <[email protected]>
Lin Sun <[email protected]>
Lin Peng <[email protected]>
Lin Peng <[email protected]>
Lingqi Chi <[email protected]>
Lingyun Cai <[email protected]>
Expand Down Expand Up @@ -918,6 +920,7 @@ Noj Vek <[email protected]>
Nolan Cao <[email protected]>
Oleksii Kadurin <[email protected]>
Oliver Dunk <[email protected]>
Olivier Tilloy <[email protected]>
Olli Raula (Old name Olli Syrjälä) <[email protected]>
Omar Sandoval <[email protected]>
Owen Yuwono <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ group("gn_all") {
"//build/android/gyp/test:hello_world",
"//build/android/stacktrace:java_deobfuscate",
"//build/config/android/test/proto:test_build_protos",
"//build/private_code_test:private_paths",
"//chrome/android/monochrome:monochrome_public_apk_checker",
"//chrome/android/webapk/shell_apk:maps_go_webapk",
"//chrome/android/webapk/shell_apk:webapk",
Expand Down
166 changes: 97 additions & 69 deletions DEPS

Large diffs are not rendered by default.

169 changes: 45 additions & 124 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,51 @@ class BanRule:
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
),
BanRule(
r'/\bstd::aligned_alloc\b',
(
'std::aligned_alloc() is not yet approved for use (crbug.com/1412818).',
' Use base::AlignedAlloc() instead.',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
BanRule(
r'/\bstd::invoke\b',
(
'std::invoke() is not yet approved for use (crbug.com/1412520). Use ',
'base::invoke() instead.',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
BanRule(
r'/\bstd::not_fn\b',
(
'std::not_fn() is not yet approved for use (crbug.com/1412529). Use ',
'base::not_fn() instead.',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
BanRule(
r'/\bstd::string_view\b',
(
'std::string_view is not yet approved for use (crbug.com/691162). Use ',
'base::StringPiece instead.',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
BanRule(
r'/\bstd::u16string_view\b',
(
'std::u16string_view is not yet approved for use (crbug.com/691162). ',
'Use base::StringPiece16 instead.',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
BanRule(
r'/\bRunMessageLoop\b',
(
Expand Down Expand Up @@ -6428,130 +6473,6 @@ def CheckConsistentGrdChanges(input_api, output_api):
return errors


def CheckMPArchApiUsage(input_api, output_api):
"""CC the MPArch watchlist if the CL uses an API that is ambiguous in the
presence of MPArch features such as bfcache, prerendering, and fenced frames.
"""

# Only consider top-level directories that (1) can use content APIs or
# problematic blink APIs, (2) apply to desktop or android chrome, and (3)
# are known to have a significant number of uses of the APIs of concern.
files_to_check = (
r'^(chrome|components|content|extensions|third_party/blink/renderer)/.+%s' %
_IMPLEMENTATION_EXTENSIONS,
r'^(chrome|components|content|extensions|third_party/blink/renderer)/.+%s' %
_HEADER_EXTENSIONS,
)
files_to_skip = (_EXCLUDED_PATHS + _TEST_CODE_EXCLUDED_PATHS +
input_api.DEFAULT_FILES_TO_SKIP)
source_file_filter = lambda f: input_api.FilterSourceFile(
f, files_to_check=files_to_check, files_to_skip=files_to_skip)

# Here we list the classes/methods we're monitoring. For the "fyi" cases,
# we add the CL to the watchlist, but we don't omit a warning or have it be
# included in the triage rotation.
# Note that since these are are just regular expressions and we don't have
# the compiler's AST, we could have spurious matches (e.g. an unrelated class
# could have a method named IsInMainFrame).
fyi_concerning_class_pattern = input_api.re.compile(
r'WebContentsObserver|WebContentsUserData')
# A subset of WebContentsObserver overrides where there's particular risk for
# confusing tab and page level operations and data (e.g. incorrectly
# resetting page state in DidFinishNavigation).
fyi_concerning_wco_methods = [
'DidStartNavigation',
'ReadyToCommitNavigation',
'DidFinishNavigation',
'RenderViewReady',
'RenderViewDeleted',
'RenderViewHostChanged',
'DOMContentLoaded',
'DidFinishLoad',
]
concerning_nav_handle_methods = [
'IsInMainFrame',
]
concerning_web_contents_methods = [
'FromRenderFrameHost',
'FromRenderViewHost',
]
fyi_concerning_web_contents_methods = [
'GetRenderViewHost',
]
concerning_rfh_methods = [
'GetParent',
'GetMainFrame',
]
fyi_concerning_rfh_methods = [
'GetFrameTreeNodeId',
]
concerning_rfhi_methods = [
'is_main_frame',
]
concerning_ftn_methods = [
'IsMainFrame',
]
concerning_blink_frame_methods = [
'IsCrossOriginToNearestMainFrame',
]
concerning_method_pattern = input_api.re.compile(r'(' + r'|'.join(
item for sublist in [
concerning_nav_handle_methods,
concerning_web_contents_methods, concerning_rfh_methods,
concerning_rfhi_methods, concerning_ftn_methods,
concerning_blink_frame_methods,
] for item in sublist) + r')\(')
fyi_concerning_method_pattern = input_api.re.compile(r'(' + r'|'.join(
item for sublist in [
fyi_concerning_wco_methods, fyi_concerning_web_contents_methods,
fyi_concerning_rfh_methods,
] for item in sublist) + r')\(')

used_apis = set()
used_fyi_methods = False
for f in input_api.AffectedFiles(include_deletes=False,
file_filter=source_file_filter):
for line_num, line in f.ChangedContents():
fyi_class_match = fyi_concerning_class_pattern.search(line)
if fyi_class_match:
used_fyi_methods = True
fyi_method_match = fyi_concerning_method_pattern.search(line)
if fyi_method_match:
used_fyi_methods = True
method_match = concerning_method_pattern.search(line)
if method_match:
used_apis.add(method_match[1])

if not used_apis:
if used_fyi_methods:
output_api.AppendCC('[email protected]')

return []

output_api.AppendCC('[email protected]')
message = ('This change uses API(s) that are ambiguous in the presence of '
'MPArch features such as bfcache, prerendering, and fenced '
'frames.')
explanation = (
'Please double check whether new code assumes that a WebContents only '
'contains a single page at a time. Notably, checking whether a frame '
'is the \"main frame\" is not specific enough to determine whether it '
'corresponds to the document reflected in the omnibox. A WebContents '
'may have additional main frames for prerendered pages, bfcached '
'pages, fenced frames, etc. '
'See this doc [1] and the comments on the individual APIs '
'for guidance and this doc [2] for context. The MPArch review '
'watchlist has been CC\'d on this change to help identify any issues.\n'
'[1] https://docs.google.com/document/d/13l16rWTal3o5wce4i0RwdpMP5ESELLKr439Faj2BBRo/edit?usp=sharing\n'
'[2] https://docs.google.com/document/d/1NginQ8k0w3znuwTiJ5qjYmBKgZDekvEPC22q0I4swxQ/edit?usp=sharing'
)
return [
output_api.PresubmitNotifyResult(message,
items=list(used_apis),
long_text=explanation)
]


def CheckAssertAshOnlyCode(input_api, output_api):
"""Errors if a BUILD.gn file in an ash/ directory doesn't include
assert(is_chromeos_ash).
Expand Down
97 changes: 0 additions & 97 deletions PRESUBMIT_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4461,103 +4461,6 @@ def testNoWarningNoneRelatedMojom(self):
self.assertEqual(0, len(result))


class MPArchApiUsage(unittest.TestCase):
def _assert_notify(
self, expected_uses, expect_fyi, msg, local_path, new_contents):
mock_input_api = MockInputApi()
mock_output_api = MockOutputApi()
mock_input_api.files = [
MockFile(local_path, new_contents),
]
result = PRESUBMIT.CheckMPArchApiUsage(mock_input_api, mock_output_api)

watchlist_email = ('[email protected]'
if expect_fyi else '[email protected]')
self.assertEqual(
bool(expected_uses or expect_fyi),
watchlist_email in mock_output_api.more_cc,
msg)
if expected_uses:
self.assertEqual(1, len(result), msg)
self.assertEqual(result[0].type, 'notify', msg)
self.assertEqual(sorted(result[0].items), sorted(expected_uses), msg)
else:
self.assertEqual(0, len(result), msg)

def testNotify(self):
self._assert_notify(
['IsInMainFrame'],
False,
'Introduce IsInMainFrame',
'chrome/my_feature.cc',
['void DoSomething(content::NavigationHandle* navigation_handle) {',
' if (navigation_handle->IsInMainFrame())',
' all_of_our_page_state.reset();',
'}',
])
self._assert_notify(
['FromRenderFrameHost'],
False,
'Introduce WC::FromRenderFrameHost',
'chrome/my_feature.cc',
['void DoSomething(content::RenderFrameHost* rfh) {',
' auto* wc = content::WebContents::FromRenderFrameHost(rfh);',
' ChangeTabState(wc);',
'}',
])

def testFyi(self):
self._assert_notify(
[],
True,
'Introduce WCO and WCUD',
'chrome/my_feature.h',
['class MyFeature',
' : public content::WebContentsObserver,',
' public content::WebContentsUserData<MyFeature> {};',
])
self._assert_notify(
[],
True,
'Introduce WCO override',
'chrome/my_feature.h',
['void DidFinishNavigation(',
' content::NavigationHandle* navigation_handle) override;',
])

def testNoNotify(self):
self._assert_notify(
[],
False,
'No API usage',
'chrome/my_feature.cc',
['void DoSomething() {',
' // TODO: Something',
'}',
])
# Something under a top level directory we're not concerned about happens
# to share a name with a content API.
self._assert_notify(
[],
False,
'Uninteresting top level directory',
'third_party/my_dep/my_code.cc',
['bool HasParent(Node* node) {',
' return node->GetParent();',
'}',
])
# We're not concerned with usage in test code.
self._assert_notify(
[],
False,
'Usage in test code',
'chrome/my_feature_unittest.cc',
['TEST_F(MyFeatureTest, DoesSomething) {',
' EXPECT_TRUE(rfh()->GetMainFrame());',
'}',
])


class AssertAshOnlyCodeTest(unittest.TestCase):
def testErrorsOnlyOnAshDirectories(self):
files_in_ash = [
Expand Down
20 changes: 20 additions & 0 deletions WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,9 @@
'extensions/renderer/resources/guest_view|'\
'extensions/test/data/(app|web)_view',
},
'hashprefix_realtime': {
'filepath': 'components/safe_browsing/core/browser/hashprefix_realtime/'
},
'hats': {
'filepath': 'chrome/browser/ash/hats/',
},
Expand Down Expand Up @@ -1275,6 +1278,9 @@
'ios/chrome/browser/experimental_flags\.(h|mm)|'\
'ios/chrome/browser/resources/Settings.bundle/Experimental\.plist',
},
'ios_ntp': {
'filepath': 'ios/chrome/browser/ui/ntp/',
},
'ios_showcase': {
'filepath': 'ios/showcase/',
},
Expand Down Expand Up @@ -1432,6 +1438,15 @@
'minidump_tests': {
'filepath': 'tools/perf/core/minidump_unittest.py',
},
'multi_apps': {
'filepath': 'chrome/test/data/webapps_integration/has_sub_apps/'\
'|third_party/blink/renderer/modules/subapps/'\
'|chrome/browser/ui/web_applications/.*sub_app'\
'|third_party/blink/public/mojom/subapps/'\
'|chrome/browser/web_applications/commands/.*sub_app'\
'|third_party/blink/web_tests/external/wpt/resources/chromium/mock-subapps.js'\
'|third_party/blink/web_tests/external/wpt/subapps/',
},
'multidevice': {
'filepath': 'ash/multi_device_setup/'\
'|ash/resources/multidevice_resources.grdp'\
Expand Down Expand Up @@ -2714,6 +2729,7 @@
'gpu_passthrough_cmd_decoder': ['[email protected]'],
'guest_view': ['[email protected]',
'[email protected]'],
'hashprefix_realtime': ['[email protected]'],
'hats': ['[email protected]'],
'headless': ['[email protected]'],
'heap_mojo': ['[email protected]'],
Expand Down Expand Up @@ -2745,6 +2761,7 @@
'[email protected]'],
'ios_credential_provider': ['[email protected]'],
'ios_flags': ['[email protected]'],
'ios_ntp': ['[email protected]'],
'ios_showcase': ['[email protected]',
'[email protected]'],
'ios_web': ['[email protected]'],
Expand Down Expand Up @@ -2801,6 +2818,9 @@
'metrics_perf': ['[email protected]'],
'midi': ['[email protected]'],
'minidump_tests': ['[email protected]'],
'multi_apps': ['[email protected]',
'[email protected]',
'[email protected]'],
'multidevice': ['[email protected]',
'[email protected]',
'[email protected]',
Expand Down
1 change: 1 addition & 0 deletions android_webview/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ android_library("common_java") {
"//build/android:build_java",
"//cc/base:cc_base_java",
"//components/autofill/android:autofill_features_java",
"//components/embedder_support/android/metrics:java",
"//components/feature_engagement/public:public_java",
"//components/metrics:metrics_java",
"//components/network_session_configurator/android:network_session_configurator_java",
Expand Down
Loading

0 comments on commit 6eb3fe0

Please sign in to comment.