Commit 36ebf62f authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

CodeHealthRotation: migrate Bind to BindOnce/Repeating in c/b/profiles/profile_shortcut_manager*

This change migrates uses of base::Bind to BindOnce/BindRepeating, and
uses of base::Callback to OnceCallback/RepeatingCallback.

Please see crbug.com/714018 for full details about the migration.

Bug: 1147284
Change-Id: Iaca33379eb8d81e667488bbdbc6fb8b053fcfd1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2534609
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827200}
parent 28c8eb1a
...@@ -44,9 +44,8 @@ class ProfileShortcutManager { ...@@ -44,9 +44,8 @@ class ProfileShortcutManager {
// Checks if a profile at |profile_path| has any shortcuts and invokes // Checks if a profile at |profile_path| has any shortcuts and invokes
// |callback| with the bool result some time later. Does not consider // |callback| with the bool result some time later. Does not consider
// non-profile specific shortcuts. // non-profile specific shortcuts.
virtual void HasProfileShortcuts( virtual void HasProfileShortcuts(const base::FilePath& profile_path,
const base::FilePath& profile_path, base::OnceCallback<void(bool)> callback) = 0;
const base::Callback<void(bool)>& callback) = 0;
// Populates the |command_line|, |name| and |icon_path| that a shortcut for // Populates the |command_line|, |name| and |icon_path| that a shortcut for
// the given |profile_path| should use. // the given |profile_path| should use.
......
...@@ -739,12 +739,10 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) { ...@@ -739,12 +739,10 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
void set_has_shortcuts(bool value) { has_shortcuts = value; } void set_has_shortcuts(bool value) { has_shortcuts = value; }
} result = { false }; } result = { false };
const base::Callback<void(bool)> callback =
base::Bind(&HasShortcutsResult::set_has_shortcuts,
base::Unretained(&result));
// Profile 2 should have a shortcut initially. // Profile 2 should have a shortcut initially.
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); profile_shortcut_manager_->HasProfileShortcuts(
profile_2_path_, base::BindOnce(&HasShortcutsResult::set_has_shortcuts,
base::Unretained(&result)));
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
EXPECT_TRUE(result.has_shortcuts); EXPECT_TRUE(result.has_shortcuts);
...@@ -753,7 +751,9 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) { ...@@ -753,7 +751,9 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
GetDefaultShortcutPathForProfile(profile_2_name_); GetDefaultShortcutPathForProfile(profile_2_name_);
ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path)); ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path));
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); EXPECT_FALSE(base::PathExists(profile_2_shortcut_path));
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); profile_shortcut_manager_->HasProfileShortcuts(
profile_2_path_, base::BindOnce(&HasShortcutsResult::set_has_shortcuts,
base::Unretained(&result)));
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
EXPECT_FALSE(result.has_shortcuts); EXPECT_FALSE(result.has_shortcuts);
} }
......
...@@ -791,11 +791,11 @@ void ProfileShortcutManagerWin::RemoveProfileShortcuts( ...@@ -791,11 +791,11 @@ void ProfileShortcutManagerWin::RemoveProfileShortcuts(
void ProfileShortcutManagerWin::HasProfileShortcuts( void ProfileShortcutManagerWin::HasProfileShortcuts(
const base::FilePath& profile_path, const base::FilePath& profile_path,
const base::Callback<void(bool)>& callback) { base::OnceCallback<void(bool)> callback) {
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
base::ThreadPool::CreateCOMSTATaskRunner({base::MayBlock()}).get(), base::ThreadPool::CreateCOMSTATaskRunner({base::MayBlock()}).get(),
FROM_HERE, base::BindOnce(&HasAnyProfileShortcuts, profile_path), FROM_HERE, base::BindOnce(&HasAnyProfileShortcuts, profile_path),
base::BindOnce(callback)); base::BindOnce(std::move(callback)));
} }
void ProfileShortcutManagerWin::GetShortcutProperties( void ProfileShortcutManagerWin::GetShortcutProperties(
......
...@@ -93,7 +93,7 @@ class ProfileShortcutManagerWin : public ProfileShortcutManager, ...@@ -93,7 +93,7 @@ class ProfileShortcutManagerWin : public ProfileShortcutManager,
void CreateProfileShortcut(const base::FilePath& profile_path) override; void CreateProfileShortcut(const base::FilePath& profile_path) override;
void RemoveProfileShortcuts(const base::FilePath& profile_path) override; void RemoveProfileShortcuts(const base::FilePath& profile_path) override;
void HasProfileShortcuts(const base::FilePath& profile_path, void HasProfileShortcuts(const base::FilePath& profile_path,
const base::Callback<void(bool)>& callback) override; base::OnceCallback<void(bool)> callback) override;
void GetShortcutProperties(const base::FilePath& profile_path, void GetShortcutProperties(const base::FilePath& profile_path,
base::CommandLine* command_line, base::CommandLine* command_line,
base::string16* name, base::string16* name,
......
...@@ -233,8 +233,8 @@ void ManageProfileHandler::HandleRequestProfileShortcutStatus( ...@@ -233,8 +233,8 @@ void ManageProfileHandler::HandleRequestProfileShortcutStatus(
DCHECK(shortcut_manager); DCHECK(shortcut_manager);
shortcut_manager->HasProfileShortcuts( shortcut_manager->HasProfileShortcuts(
profile_->GetPath(), profile_->GetPath(),
base::Bind(&ManageProfileHandler::OnHasProfileShortcuts, base::BindOnce(&ManageProfileHandler::OnHasProfileShortcuts,
weak_factory_.GetWeakPtr(), callback_id)); weak_factory_.GetWeakPtr(), callback_id));
} }
void ManageProfileHandler::OnHasProfileShortcuts( void ManageProfileHandler::OnHasProfileShortcuts(
......
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