Commit 1e4db11a authored by Reilly Grant's avatar Reilly Grant Committed by Chromium LUCI CQ

Convert callbacks in //chrome/browser/chromeos/app_mode

This change converts callbacks from base::Bind and base::Callback to
Once/Repeating in //chrome/browser/chromeos/app_mode.

Bug: 1148570
Change-Id: I92338ffa90e975cf9c79e151f2c784a55ddd2556
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2645404
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846293}
parent 1e0082f7
...@@ -200,7 +200,7 @@ void FakeCWS::Init(net::EmbeddedTestServer* embedded_test_server) { ...@@ -200,7 +200,7 @@ void FakeCWS::Init(net::EmbeddedTestServer* embedded_test_server) {
SetupWebStoreURL(embedded_test_server->base_url()); SetupWebStoreURL(embedded_test_server->base_url());
OverrideGalleryCommandlineSwitches(); OverrideGalleryCommandlineSwitches();
embedded_test_server->RegisterRequestHandler( embedded_test_server->RegisterRequestHandler(
base::Bind(&FakeCWS::HandleRequest, base::Unretained(this))); base::BindRepeating(&FakeCWS::HandleRequest, base::Unretained(this)));
} }
void FakeCWS::InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server, void FakeCWS::InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server,
...@@ -212,7 +212,7 @@ void FakeCWS::InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server, ...@@ -212,7 +212,7 @@ void FakeCWS::InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server,
OverrideGalleryCommandlineSwitches(); OverrideGalleryCommandlineSwitches();
embedded_test_server->RegisterRequestHandler( embedded_test_server->RegisterRequestHandler(
base::Bind(&FakeCWS::HandleRequest, base::Unretained(this))); base::BindRepeating(&FakeCWS::HandleRequest, base::Unretained(this)));
} }
void FakeCWS::SetUpdateCrx(const std::string& app_id, void FakeCWS::SetUpdateCrx(const std::string& app_id,
......
...@@ -24,21 +24,22 @@ class IconImageRequest : public ImageDecoder::ImageRequest { ...@@ -24,21 +24,22 @@ class IconImageRequest : public ImageDecoder::ImageRequest {
public: public:
IconImageRequest(const scoped_refptr<base::SequencedTaskRunner>& task_runner, IconImageRequest(const scoped_refptr<base::SequencedTaskRunner>& task_runner,
KioskAppIconLoader::ResultCallback result_callback) KioskAppIconLoader::ResultCallback result_callback)
: ImageRequest(task_runner), result_callback_(result_callback) {} : ImageRequest(task_runner),
result_callback_(std::move(result_callback)) {}
void OnImageDecoded(const SkBitmap& decoded_image) override { void OnImageDecoded(const SkBitmap& decoded_image) override {
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image); gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image);
image.MakeThreadSafe(); image.MakeThreadSafe();
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(result_callback_, image)); FROM_HERE, base::BindOnce(std::move(result_callback_), image));
delete this; delete this;
} }
void OnDecodeImageFailed() override { void OnDecodeImageFailed() override {
LOG(ERROR) << "Failed to decode icon image."; LOG(ERROR) << "Failed to decode icon image.";
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(std::move(result_callback_),
base::BindOnce(result_callback_, base::Optional<gfx::ImageSkia>())); base::Optional<gfx::ImageSkia>()));
delete this; delete this;
} }
...@@ -57,14 +58,14 @@ void LoadOnBlockingPool( ...@@ -57,14 +58,14 @@ void LoadOnBlockingPool(
if (!base::ReadFileToString(base::FilePath(icon_path), &data)) { if (!base::ReadFileToString(base::FilePath(icon_path), &data)) {
LOG(ERROR) << "Failed to read icon file."; LOG(ERROR) << "Failed to read icon file.";
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(std::move(result_callback),
base::BindOnce(result_callback, base::Optional<gfx::ImageSkia>())); base::Optional<gfx::ImageSkia>()));
return; return;
} }
// IconImageRequest will delete itself on completion of ImageDecoder callback. // IconImageRequest will delete itself on completion of ImageDecoder callback.
IconImageRequest* image_request = IconImageRequest* image_request =
new IconImageRequest(callback_task_runner, result_callback); new IconImageRequest(callback_task_runner, std::move(result_callback));
ImageDecoder::Start(image_request, ImageDecoder::Start(image_request,
std::vector<uint8_t>(data.begin(), data.end())); std::vector<uint8_t>(data.begin(), data.end()));
} }
...@@ -80,8 +81,9 @@ void KioskAppIconLoader::Start(const base::FilePath& icon_path) { ...@@ -80,8 +81,9 @@ void KioskAppIconLoader::Start(const base::FilePath& icon_path) {
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); {base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&LoadOnBlockingPool, icon_path, task_runner, base::BindOnce(
base::Bind(&KioskAppIconLoader::OnImageDecodingFinished, &LoadOnBlockingPool, icon_path, task_runner,
base::BindOnce(&KioskAppIconLoader::OnImageDecodingFinished,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
} }
......
...@@ -31,7 +31,7 @@ class KioskAppIconLoader { ...@@ -31,7 +31,7 @@ class KioskAppIconLoader {
}; };
using ResultCallback = using ResultCallback =
base::Callback<void(base::Optional<gfx::ImageSkia> result)>; base::OnceCallback<void(base::Optional<gfx::ImageSkia> result)>;
explicit KioskAppIconLoader(Delegate* delegate); explicit KioskAppIconLoader(Delegate* delegate);
......
...@@ -55,11 +55,11 @@ constexpr base::TimeDelta kAutomaticRebootManagerInitTimeout = ...@@ -55,11 +55,11 @@ constexpr base::TimeDelta kAutomaticRebootManagerInitTimeout =
// |success_out| to false and runs |quit_closure|. // |success_out| to false and runs |quit_closure|.
void WaitForAutomaticRebootManagerInit(system::AutomaticRebootManager* manager, void WaitForAutomaticRebootManagerInit(system::AutomaticRebootManager* manager,
const base::TimeDelta& timeout, const base::TimeDelta& timeout,
const base::Closure& quit_closure, base::OnceClosure quit_closure,
bool* success_out) { bool* success_out) {
base::ScopedAllowBaseSyncPrimitivesForTesting allow_base_sync_primitives; base::ScopedAllowBaseSyncPrimitivesForTesting allow_base_sync_primitives;
*success_out = manager->WaitForInitForTesting(timeout); *success_out = manager->WaitForInitForTesting(timeout);
quit_closure.Run(); std::move(quit_closure).Run();
} }
} // namespace } // namespace
......
...@@ -146,7 +146,7 @@ void KioskCryptohomeRemover::CancelDelayedCryptohomeRemoval( ...@@ -146,7 +146,7 @@ void KioskCryptohomeRemover::CancelDelayedCryptohomeRemoval(
void KioskCryptohomeRemover::RemoveCryptohomesAndExitIfNeeded( void KioskCryptohomeRemover::RemoveCryptohomesAndExitIfNeeded(
const std::vector<AccountId>& account_ids) { const std::vector<AccountId>& account_ids) {
base::Closure cryptohomes_barrier_closure; base::RepeatingClosure cryptohomes_barrier_closure;
const user_manager::User* active_user = const user_manager::User* active_user =
user_manager::UserManager::Get()->GetActiveUser(); user_manager::UserManager::Get()->GetActiveUser();
AccountId active_account_id; AccountId active_account_id;
......
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