chore: remove last instances of base::Bind (#18178)
* chore: remove last instances of base::Bind * MessageBoxCallback is a OnceCallback * convert permission helepr cbs to Once * convert ResponseCallback to Once
This commit is contained in:
parent
96371b6d75
commit
9af5072115
23 changed files with 122 additions and 109 deletions
|
@ -58,9 +58,9 @@ class ProcessSingleton {
|
|||
// Chrome process was launched. Return true if the command line will be
|
||||
// handled within the current browser instance or false if the remote process
|
||||
// should handle it (i.e., because the current process is shutting down).
|
||||
using NotificationCallback =
|
||||
base::Callback<bool(const base::CommandLine::StringVector& command_line,
|
||||
const base::FilePath& current_directory)>;
|
||||
using NotificationCallback = base::RepeatingCallback<bool(
|
||||
const base::CommandLine::StringVector& command_line,
|
||||
const base::FilePath& current_directory)>;
|
||||
|
||||
ProcessSingleton(const base::FilePath& user_data_dir,
|
||||
const NotificationCallback& notification_callback);
|
||||
|
@ -94,7 +94,7 @@ class ProcessSingleton {
|
|||
#if defined(OS_WIN)
|
||||
// Called to query whether to kill a hung browser process that has visible
|
||||
// windows. Return true to allow killing the hung process.
|
||||
using ShouldKillRemoteProcessCallback = base::Callback<bool()>;
|
||||
using ShouldKillRemoteProcessCallback = base::RepeatingCallback<bool()>;
|
||||
void OverrideShouldKillRemoteProcessCallbackForTesting(
|
||||
const ShouldKillRemoteProcessCallback& display_dialog_callback);
|
||||
#endif
|
||||
|
@ -120,7 +120,7 @@ class ProcessSingleton {
|
|||
const base::TimeDelta& timeout);
|
||||
void OverrideCurrentPidForTesting(base::ProcessId pid);
|
||||
void OverrideKillCallbackForTesting(
|
||||
const base::Callback<void(int)>& callback);
|
||||
const base::RepeatingCallback<void(int)>& callback);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -482,8 +482,8 @@ class ProcessSingleton::LinuxWatcher
|
|||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
// Wait for reads.
|
||||
fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
|
||||
fd, base::Bind(&SocketReader::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this)));
|
||||
fd, base::BindRepeating(&SocketReader::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this)));
|
||||
// If we haven't completed in a reasonable amount of time, give up.
|
||||
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
|
||||
this, &SocketReader::CleanupAndDeleteSelf);
|
||||
|
@ -592,8 +592,8 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
|||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
// Watch for client connections on this socket.
|
||||
socket_watcher_ = base::FileDescriptorWatcher::WatchReadable(
|
||||
socket, base::Bind(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this), socket));
|
||||
socket, base::BindRepeating(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
|
||||
base::Unretained(this), socket));
|
||||
}
|
||||
|
||||
void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||
|
@ -686,8 +686,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
|||
|
||||
// Return to the UI thread to handle opening a new browser tab.
|
||||
ui_task_runner_->PostTask(
|
||||
FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
||||
parent_, current_dir, tokens, this));
|
||||
FROM_HERE, base::BindOnce(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
||||
parent_, current_dir, tokens, this));
|
||||
fd_watch_controller_.reset();
|
||||
|
||||
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
|
||||
|
@ -707,8 +707,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
|||
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&ProcessSingleton::LinuxWatcher::RemoveSocketReader, parent_,
|
||||
this));
|
||||
base::BindOnce(&ProcessSingleton::LinuxWatcher::RemoveSocketReader,
|
||||
parent_, this));
|
||||
// We will be deleted once the posted RemoveSocketReader task runs.
|
||||
}
|
||||
|
||||
|
@ -728,8 +728,8 @@ ProcessSingleton::ProcessSingleton(
|
|||
lock_path_ = user_data_dir.Append(kSingletonLockFilename);
|
||||
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
|
||||
|
||||
kill_callback_ =
|
||||
base::Bind(&ProcessSingleton::KillProcess, base::Unretained(this));
|
||||
kill_callback_ = base::BindRepeating(&ProcessSingleton::KillProcess,
|
||||
base::Unretained(this));
|
||||
}
|
||||
|
||||
ProcessSingleton::~ProcessSingleton() {
|
||||
|
@ -887,8 +887,8 @@ void ProcessSingleton::StartListeningOnSocket() {
|
|||
watcher_ = new LinuxWatcher(this);
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
|
||||
sock_));
|
||||
base::BindOnce(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
|
||||
sock_));
|
||||
}
|
||||
|
||||
void ProcessSingleton::OnBrowserReady() {
|
||||
|
@ -950,7 +950,7 @@ void ProcessSingleton::OverrideCurrentPidForTesting(base::ProcessId pid) {
|
|||
}
|
||||
|
||||
void ProcessSingleton::OverrideKillCallbackForTesting(
|
||||
const base::Callback<void(int)>& callback) {
|
||||
const base::RepeatingCallback<void(int)>& callback) {
|
||||
kill_callback_ = callback;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,8 @@ ProcessSingleton::ProcessSingleton(
|
|||
is_virtualized_(false),
|
||||
lock_file_(INVALID_HANDLE_VALUE),
|
||||
user_data_dir_(user_data_dir),
|
||||
should_kill_remote_process_callback_(base::Bind(&TerminateAppWithError)) {
|
||||
should_kill_remote_process_callback_(
|
||||
base::BindRepeating(&TerminateAppWithError)) {
|
||||
// The user_data_dir may have not been created yet.
|
||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||
}
|
||||
|
@ -290,9 +291,10 @@ bool ProcessSingleton::Create() {
|
|||
if (lock_file_ != INVALID_HANDLE_VALUE) {
|
||||
// Set the window's title to the path of our user data directory so
|
||||
// other Chrome instances can decide if they should forward to us.
|
||||
bool result = window_.CreateNamed(
|
||||
base::Bind(&ProcessLaunchNotification, notification_callback_),
|
||||
user_data_dir_.value());
|
||||
bool result =
|
||||
window_.CreateNamed(base::BindRepeating(&ProcessLaunchNotification,
|
||||
notification_callback_),
|
||||
user_data_dir_.value());
|
||||
|
||||
// NB: Ensure that if the primary app gets started as elevated
|
||||
// admin inadvertently, secondary windows running not as elevated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue