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) {
SetupWebStoreURL(embedded_test_server->base_url());
OverrideGalleryCommandlineSwitches();
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,
......@@ -212,7 +212,7 @@ void FakeCWS::InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server,
OverrideGalleryCommandlineSwitches();
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,
......
......@@ -24,21 +24,22 @@ class IconImageRequest : public ImageDecoder::ImageRequest {
public:
IconImageRequest(const scoped_refptr<base::SequencedTaskRunner>& task_runner,
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 {
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image);
image.MakeThreadSafe();
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(result_callback_, image));
FROM_HERE, base::BindOnce(std::move(result_callback_), image));
delete this;
}
void OnDecodeImageFailed() override {
LOG(ERROR) << "Failed to decode icon image.";
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(result_callback_, base::Optional<gfx::ImageSkia>()));
FROM_HERE, base::BindOnce(std::move(result_callback_),
base::Optional<gfx::ImageSkia>()));
delete this;
}
......@@ -57,14 +58,14 @@ void LoadOnBlockingPool(
if (!base::ReadFileToString(base::FilePath(icon_path), &data)) {
LOG(ERROR) << "Failed to read icon file.";
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(result_callback, base::Optional<gfx::ImageSkia>()));
FROM_HERE, base::BindOnce(std::move(result_callback),
base::Optional<gfx::ImageSkia>()));
return;
}
// IconImageRequest will delete itself on completion of ImageDecoder callback.
IconImageRequest* image_request =
new IconImageRequest(callback_task_runner, result_callback);
new IconImageRequest(callback_task_runner, std::move(result_callback));
ImageDecoder::Start(image_request,
std::vector<uint8_t>(data.begin(), data.end()));
}
......@@ -80,8 +81,9 @@ void KioskAppIconLoader::Start(const base::FilePath& icon_path) {
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
task_runner->PostTask(
FROM_HERE,
base::BindOnce(&LoadOnBlockingPool, icon_path, task_runner,
base::Bind(&KioskAppIconLoader::OnImageDecodingFinished,
base::BindOnce(
&LoadOnBlockingPool, icon_path, task_runner,
base::BindOnce(&KioskAppIconLoader::OnImageDecodingFinished,
weak_factory_.GetWeakPtr())));
}
......
......@@ -31,7 +31,7 @@ class KioskAppIconLoader {
};
using ResultCallback =
base::Callback<void(base::Optional<gfx::ImageSkia> result)>;
base::OnceCallback<void(base::Optional<gfx::ImageSkia> result)>;
explicit KioskAppIconLoader(Delegate* delegate);
......
......@@ -55,11 +55,11 @@ constexpr base::TimeDelta kAutomaticRebootManagerInitTimeout =
// |success_out| to false and runs |quit_closure|.
void WaitForAutomaticRebootManagerInit(system::AutomaticRebootManager* manager,
const base::TimeDelta& timeout,
const base::Closure& quit_closure,
base::OnceClosure quit_closure,
bool* success_out) {
base::ScopedAllowBaseSyncPrimitivesForTesting allow_base_sync_primitives;
*success_out = manager->WaitForInitForTesting(timeout);
quit_closure.Run();
std::move(quit_closure).Run();
}
} // namespace
......
......@@ -146,7 +146,7 @@ void KioskCryptohomeRemover::CancelDelayedCryptohomeRemoval(
void KioskCryptohomeRemover::RemoveCryptohomesAndExitIfNeeded(
const std::vector<AccountId>& account_ids) {
base::Closure cryptohomes_barrier_closure;
base::RepeatingClosure cryptohomes_barrier_closure;
const user_manager::User* active_user =
user_manager::UserManager::Get()->GetActiveUser();
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