[CodeHealth] Update and fix base::Callback exceptions
Adds exceptions for directories/files found to contain base::Bind, Callback, or Closure methods. Additionally, fixes a handful of files that only had a single trivial instance needing to be cleaned up. Bug: 714018 Change-Id: I7a7ac5f07b7c62fff680ac6daa9e52ce490f24b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2660396 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Alexander Cooper <alcooper@chromium.org> Cr-Commit-Position: refs/heads/master@{#849214}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9418d10b23
commit
b3f1af66d1
PRESUBMIT.py
chrome/browser/enterprise/connectors
chromeos/services/machine_learning/public/cpp
codelabs/cpp101
remoting/host/security_key
styleguide/c++
third_party/blink/renderer/platform/scheduler
15
PRESUBMIT.py
15
PRESUBMIT.py
@ -332,15 +332,19 @@ _NOT_CONVERTED_TO_MODERN_BIND_AND_CALLBACK = '|'.join((
|
||||
'^base/callback.h', # Intentional.
|
||||
'^base/cancelable_callback.h', # Intentional.
|
||||
'^chrome/browser/apps/guest_view/web_view_browsertest.cc',
|
||||
"^chrome/browser/ash/accessibility/",
|
||||
'^chrome/browser/captive_portal/captive_portal_browsertest.cc',
|
||||
'^chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc', # pylint: disable=line-too-long
|
||||
'^chrome/browser/history/android/android_history_provider_service_unittest.cc', # pylint: disable=line-too-long
|
||||
'^chrome/browser/media_galleries/',
|
||||
"^chrome/browser/metrics/",
|
||||
'^chrome/browser/net/websocket_browsertest.cc',
|
||||
'^chrome/browser/ntp_tiles/ntp_tiles_browsertest.cc',
|
||||
'^chrome/browser/page_load_metrics/observers/data_saver_site_breakdown_metrics_observer_browsertest.cc', # pylint: disable=line-too-long
|
||||
'^chrome/browser/payments/payment_manifest_parser_browsertest.cc',
|
||||
'^chrome/browser/portal/portal_browsertest.cc',
|
||||
"^chrome/browser/prefetch/no_state_prefetch/",
|
||||
'^chrome/browser/previews/',
|
||||
'^chrome/browser/profiling_host/profiling_process_host.cc',
|
||||
'^chrome/browser/recovery/recovery_install_global_error.cc',
|
||||
'^chrome/browser/resources/chromeos/accessibility/',
|
||||
@ -350,11 +354,22 @@ _NOT_CONVERTED_TO_MODERN_BIND_AND_CALLBACK = '|'.join((
|
||||
'^chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc',
|
||||
'^chrome/browser/sync_file_system/',
|
||||
'^chrome/browser/web_applications/',
|
||||
"^components/browsing_data/content/",
|
||||
"^components/enterprise/browser/controller/chrome_browser_cloud_management_controller\\.cc", # pylint: disable=line-too-long
|
||||
"^components/feature_engagement/internal/",
|
||||
"^docs/callback\\.md", # Intentional
|
||||
"^docs/webui_explainer\\.md",
|
||||
"^docs/process/lsc/large_scale_changes\\.md", # Intentional
|
||||
"^docs/security/mojo\\.md",
|
||||
"^docs/threading_and_tasks\\.md",
|
||||
"^docs/ui/learn/bestpractices/layout\\.md",
|
||||
'^extensions/browser/',
|
||||
'^extensions/renderer/',
|
||||
'^media/blink/webmediaplayer_impl.cc',
|
||||
'^media/blink/webmediaplayer_impl.h',
|
||||
'^ppapi/proxy/',
|
||||
'^third_party/blink/PRESUBMIT_test.py', # Intentional.
|
||||
'^third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py' # Intentional pylint: disable=line-too-long
|
||||
'^tools/clang/base_bind_rewriters/', # Intentional.
|
||||
'^tools/gdb/gdb_chrome.py', # Intentional.
|
||||
))
|
||||
|
@ -49,7 +49,7 @@ class FakeContentAnalysisDelegate : public ContentAnalysisDelegate {
|
||||
|
||||
// Use with ContentAnalysisDelegate::SetFactoryForTesting() to create
|
||||
// fake instances of this class. Note that all but the last three arguments
|
||||
// will need to be bound at base::Bind() time.
|
||||
// will need to be bound at base::BindRepeating() time.
|
||||
static std::unique_ptr<ContentAnalysisDelegate> Create(
|
||||
base::RepeatingClosure delete_closure,
|
||||
StatusCallback status_callback,
|
||||
|
@ -549,7 +549,7 @@ TEST_F(ServiceConnectionTest, FakeHandWritingRecognizer) {
|
||||
bool infer_callback_done = false;
|
||||
recognizer->Recognize(
|
||||
std::move(query),
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
[](bool* infer_callback_done,
|
||||
mojom::HandwritingRecognizerResultPtr result) {
|
||||
*infer_callback_done = true;
|
||||
|
@ -205,9 +205,9 @@ those tasks.
|
||||
|
||||
`base::SequencedTaskRunner` (which extends `base::TaskRunner`) is a commonly
|
||||
used abstraction which handles running tasks (which are instances
|
||||
of `base::Closure`) in sequential order. These tasks are not guaranteed to run
|
||||
on the same thread. The preferred way of posting to the current (virtual) thread
|
||||
is `base::SequencedTaskRunnerHandle::Get()`.
|
||||
of `base::OnceClosure`) in sequential order. These tasks are not guaranteed to
|
||||
run on the same thread. The preferred way of posting to the current (virtual)
|
||||
thread is `base::SequencedTaskRunnerHandle::Get()`.
|
||||
|
||||
A task that can run on any thread and doesn’t have ordering or mutual exclusion
|
||||
requirements with other tasks should be posted using one of the
|
||||
|
@ -492,7 +492,7 @@ TEST_F(SecurityKeyIpcServerTest, CleanupPendingConnection) {
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Create a fake client and connect to the IPC server channel.
|
||||
FakeSecurityKeyIpcClient fake_ipc_client(base::Bind(
|
||||
FakeSecurityKeyIpcClient fake_ipc_client(base::BindRepeating(
|
||||
&SecurityKeyIpcServerTest::OperationComplete, base::Unretained(this)));
|
||||
ASSERT_TRUE(fake_ipc_client.ConnectViaIpc(server_name));
|
||||
WaitForOperationComplete();
|
||||
|
@ -184,7 +184,7 @@ The current status of existing standards and Abseil features is:
|
||||
<td><code>std::function</code></td>
|
||||
<td>Wraps a standard polymorphic function</td>
|
||||
<td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std::function</a></td>
|
||||
<td>Use <code>base::Callback</code> instead. Compared to <code>std::function</code>, <code>base::Callback</code> directly supports Chromium's refcounting classes and weak pointers and deals with additional thread safety concerns. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td>
|
||||
<td>Use <code>base::{Once,Repeating}Callback</code> instead. Compared to <code>std::function</code>, <code>base::{Once,Repeating}Callback</code> directly supports Chromium's refcounting classes and weak pointers and deals with additional thread safety concerns. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -18,7 +18,7 @@ to find out how to schedule this type of work.
|
||||
|
||||
## Tasks
|
||||
|
||||
The main scheduling unit in Blink is a task. A task is a base::Closure posted via
|
||||
The main scheduling unit in Blink is a task. A task is a base::OnceClosure posted via
|
||||
TaskRunner::PostTask or TaskRunner::PostDelayedTask interface. The regular method of
|
||||
creating closures (base::BindOnce/Repeating) [is banned](#binding-tasks).
|
||||
Blink should use WTF::Bind (for tasks which are posted to the same thread) and
|
||||
@ -175,4 +175,3 @@ on a different thread.
|
||||
|
||||
|
||||
## TODO(altimin): Document idle tasks
|
||||
|
||||
|
Reference in New Issue
Block a user