Commit 6b447b2f authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Convert remaining top level Bind/Callbacks in chrome/browser

Converts shell_integration::DefaultWebClientWorkerCallback to a
RepeatingCallback, since it is used to pass the result of state queires.
Converts callbacks for shell_integration::win::GetIsPinnedTaskbarState
to Once callbacks, given that exactly one of them is called once.
Converts the sole caller of GetIsPinnedTaskbarState to base::BindOnce.
Converts the shell_integration::win::DefaultBrowserActionRecorder to use
a OnceClosure, wince this matches it's usage.
Updates a missed comment in process_resource_usage.h
Switches the ChromeContentBrowserClient UnitTest to use a NullCallback.
This matches the intention of the test, and can be used independent of
updating the underlying API.

Finally, with all top level usages of base::Bind/Callback cleaned up,
modifies PRESUBMIT.py to replace chrome/browser with the children that
still need to be converted. Where a directory has only one file that
needs conversion, that file is listed. Otherwise, the deepest
subdirectory under chrome/browser that has files that need to be
converted is listed.

Bug: 1007635
Change-Id: I2cbdcd37cd0da411e106c0f3b14b8f6e92d7209f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304129Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790638}
parent 19cdf8b2
......@@ -283,7 +283,69 @@ _BANNED_IOS_EGTEST_FUNCTIONS = (
_NOT_CONVERTED_TO_MODERN_BIND_AND_CALLBACK = '|'.join((
'^apps/',
'^base/callback.h', # Intentional.
'^chrome/browser/',
'^chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc',
'^chrome/browser/apps/guest_view/',
'^chrome/browser/apps/platform_apps/shortcut_manager.cc',
'^chrome/browser/browsing_data/',
'^chrome/browser/captive_portal/captive_portal_browsertest.cc',
'^chrome/browser/chromeos/',
'^chrome/browser/component_updater/',
'^chrome/browser/custom_handlers/protocol_handler_registry.cc',
'^chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc',
'^chrome/browser/devtools/',
'^chrome/browser/download/',
'^chrome/browser/extensions/',
'^chrome/browser/external_protocol/external_protocol_handler.cc',
'^chrome/browser/history/',
'^chrome/browser/installable/installable_manager_browsertest.cc',
'^chrome/browser/lifetime/',
'^chrome/browser/media_galleries/',
'^chrome/browser/media/',
'^chrome/browser/metrics/',
'^chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc',
'^chrome/browser/nearby_sharing/client/nearby_share_api_call_flow_impl_unittest.cc',
'^chrome/browser/net/',
'^chrome/browser/notifications/',
'^chrome/browser/ntp_tiles/ntp_tiles_browsertest.cc',
'^chrome/browser/offline_pages/',
'^chrome/browser/page_load_metrics/observers/data_saver_site_breakdown_metrics_observer_browsertest.cc',
'^chrome/browser/password_manager/',
'^chrome/browser/payments/payment_manifest_parser_browsertest.cc',
'^chrome/browser/pdf/pdf_extension_test.cc',
'^chrome/browser/plugins/',
'^chrome/browser/policy/',
'^chrome/browser/portal/portal_browsertest.cc',
'^chrome/browser/prefs/profile_pref_store_manager_unittest.cc',
'^chrome/browser/prerender/',
'^chrome/browser/previews/',
'^chrome/browser/printing/printing_message_filter.cc',
'^chrome/browser/profiles/',
'^chrome/browser/profiling_host/profiling_process_host.cc',
'^chrome/browser/push_messaging/',
'^chrome/browser/recovery/recovery_install_global_error.cc',
'^chrome/browser/renderer_context_menu/',
'^chrome/browser/renderer_host/pepper/',
'^chrome/browser/resource_coordinator/',
'^chrome/browser/resources/chromeos/accessibility/',
'^chrome/browser/rlz/chrome_rlz_tracker_delegate.cc',
'^chrome/browser/safe_browsing/',
'^chrome/browser/search_engines/',
'^chrome/browser/service_process/',
'^chrome/browser/signin/',
'^chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc',
'^chrome/browser/ssl/',
'^chrome/browser/subresource_filter/',
'^chrome/browser/supervised_user/',
'^chrome/browser/sync_file_system/',
'^chrome/browser/sync/',
'^chrome/browser/themes/theme_service.cc',
'^chrome/browser/thumbnail/cc/',
'^chrome/browser/tracing/chrome_tracing_delegate_browsertest.cc',
'^chrome/browser/translate/',
'^chrome/browser/ui/',
'^chrome/browser/vr/databinding/vector_binding.h',
'^chrome/browser/web_applications/',
'^chrome/browser/win/',
'^chrome/chrome_elf/',
'^chrome/installer/',
'^chrome/services/',
......
......@@ -470,8 +470,8 @@ void OnIsPinnedToTaskbarResult(bool succeeded,
// startup.
void RecordIsPinnedToTaskbarHistogram() {
shell_integration::win::GetIsPinnedToTaskbarState(
base::Bind(&OnShellHandlerConnectionError),
base::Bind(&OnIsPinnedToTaskbarResult));
base::BindOnce(&OnShellHandlerConnectionError),
base::BindOnce(&OnIsPinnedToTaskbarResult));
}
class ScHandleTraits {
......
......@@ -50,7 +50,8 @@
// service.InitWithNewPipeAndPassReceiver();
// base::PostTask(
// FROM_HERE, {content::BrowserThread::IO},
// base::Bind(&Foo::ConnectToService, this, base::Passed(&receiver)));
// base::BindOnce(&Foo::ConnectToService, this,
// base::Passed(&receiver)));
// resource_usage_.reset(new ProcessResourceUsage(std::move(service)));
// ...
//
......
......@@ -143,7 +143,7 @@ base::string16 GetAppShortcutsSubdirName();
// The type of callback used to communicate processing state to consumers of
// DefaultBrowserWorker and DefaultProtocolClientWorker.
using DefaultWebClientWorkerCallback =
base::Callback<void(DefaultWebClientState)>;
base::RepeatingCallback<void(DefaultWebClientState)>;
// Helper objects that handle checking if Chrome is the default browser
// or application for a url protocol on Windows and Linux, and also setting
......
......@@ -231,7 +231,7 @@ class DefaultBrowserActionRecorder : public SettingsAppMonitor::Delegate {
// Creates the recorder and the monitor that drives it. |continuation| will be
// run once the monitor's initialization completes (regardless of success or
// failure).
explicit DefaultBrowserActionRecorder(base::Closure continuation)
explicit DefaultBrowserActionRecorder(base::OnceClosure continuation)
: continuation_(std::move(continuation)), settings_app_monitor_(this) {}
private:
......@@ -242,8 +242,7 @@ class DefaultBrowserActionRecorder : public SettingsAppMonitor::Delegate {
base::RecordAction(
base::UserMetricsAction("SettingsAppMonitor.Initialized"));
}
continuation_.Run();
continuation_ = base::Closure();
std::move(continuation_).Run();
}
void OnAppFocused() override {
......@@ -282,7 +281,7 @@ class DefaultBrowserActionRecorder : public SettingsAppMonitor::Delegate {
}
// A closure to be run once initialization completes.
base::Closure continuation_;
base::OnceClosure continuation_;
// Monitors user interaction with the Windows Settings app for the sake of
// reporting user actions.
......@@ -443,12 +442,12 @@ class IsPinnedToTaskbarHelper {
public:
using ResultCallback = win::IsPinnedToTaskbarCallback;
using ErrorCallback = win::ConnectionErrorCallback;
static void GetState(const ErrorCallback& error_callback,
const ResultCallback& result_callback);
static void GetState(ErrorCallback error_callback,
ResultCallback result_callback);
private:
IsPinnedToTaskbarHelper(const ErrorCallback& error_callback,
const ResultCallback& result_callback);
IsPinnedToTaskbarHelper(ErrorCallback error_callback,
ResultCallback result_callback);
void OnConnectionError();
void OnIsPinnedToTaskbarResult(bool succeeded,
......@@ -466,19 +465,18 @@ class IsPinnedToTaskbarHelper {
};
// static
void IsPinnedToTaskbarHelper::GetState(
const ErrorCallback& error_callback,
const ResultCallback& result_callback) {
void IsPinnedToTaskbarHelper::GetState(ErrorCallback error_callback,
ResultCallback result_callback) {
// Self-deleting when the ShellHandler completes.
new IsPinnedToTaskbarHelper(error_callback, result_callback);
new IsPinnedToTaskbarHelper(std::move(error_callback),
std::move(result_callback));
}
IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper(
const ErrorCallback& error_callback,
const ResultCallback& result_callback)
IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper(ErrorCallback error_callback,
ResultCallback result_callback)
: remote_util_win_(LaunchUtilWinServiceInstance()),
error_callback_(error_callback),
result_callback_(result_callback) {
error_callback_(std::move(error_callback)),
result_callback_(std::move(result_callback)) {
DCHECK(error_callback_);
DCHECK(result_callback_);
......@@ -493,7 +491,7 @@ IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper(
void IsPinnedToTaskbarHelper::OnConnectionError() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
error_callback_.Run();
std::move(error_callback_).Run();
delete this;
}
......@@ -503,8 +501,8 @@ void IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult(
bool is_pinned_to_taskbar_verb_check) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
result_callback_.Run(succeeded, is_pinned_to_taskbar,
is_pinned_to_taskbar_verb_check);
std::move(result_callback_)
.Run(succeeded, is_pinned_to_taskbar, is_pinned_to_taskbar_verb_check);
delete this;
}
......@@ -666,10 +664,10 @@ void SetAsDefaultBrowserUsingSystemSettings(
// Create an action recorder that will open the settings app once it has
// initialized.
std::unique_ptr<DefaultBrowserActionRecorder> recorder(
new DefaultBrowserActionRecorder(base::Bind(
std::unique_ptr<DefaultBrowserActionRecorder> recorder =
std::make_unique<DefaultBrowserActionRecorder>(base::BindOnce(
base::IgnoreResult(&ShellUtil::ShowMakeChromeDefaultSystemUI),
chrome_exe)));
chrome_exe));
// The helper manages its own lifetime. Bind the action recorder
// into the finished callback to keep it alive throughout the
......@@ -789,10 +787,10 @@ void MigrateTaskbarPinsCallback(const base::FilePath& taskbar_path,
}
}
void GetIsPinnedToTaskbarState(
const ConnectionErrorCallback& on_error_callback,
const IsPinnedToTaskbarCallback& result_callback) {
IsPinnedToTaskbarHelper::GetState(on_error_callback, result_callback);
void GetIsPinnedToTaskbarState(ConnectionErrorCallback on_error_callback,
IsPinnedToTaskbarCallback result_callback) {
IsPinnedToTaskbarHelper::GetState(std::move(on_error_callback),
std::move(result_callback));
}
int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
......
......@@ -64,11 +64,10 @@ base::string16 GetChromiumModelIdForProfile(const base::FilePath& profile_path);
// bool is true if Chrome is pinned to the taskbar (with verb check)
// The ConnectionErrorCallback is called instead if something wrong happened
// with the connection to the remote process.
using ConnectionErrorCallback = base::Closure;
using IsPinnedToTaskbarCallback = base::Callback<void(bool, bool, bool)>;
void GetIsPinnedToTaskbarState(
const ConnectionErrorCallback& on_error_callback,
const IsPinnedToTaskbarCallback& result_callback);
using ConnectionErrorCallback = base::OnceClosure;
using IsPinnedToTaskbarCallback = base::OnceCallback<void(bool, bool, bool)>;
void GetIsPinnedToTaskbarState(ConnectionErrorCallback on_error_callback,
IsPinnedToTaskbarCallback result_callback);
// Migrates existing chrome taskbar pins by tagging them with correct app id.
// see http://crbug.com/28104. Migrates taskbar pins via a task and runs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment