Commit 7a1b71e9 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Use OnceClosure in ResolutionNotificationController

Bug: None
Change-Id: I93b4d00f99cf355c41365de52e5288219d47258a
Reviewed-on: https://chromium-review.googlesource.com/1014292Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551088}
parent d34c6cf1
......@@ -626,7 +626,7 @@ TEST_F(DisplayPrefsTest, PreventStore) {
display::ManagedDisplayMode new_mode(gfx::Size(500, 400));
EXPECT_TRUE(shell->resolution_notification_controller()
->PrepareNotificationAndSetDisplayMode(id, old_mode, new_mode,
base::Closure()));
base::OnceClosure()));
UpdateDisplay("500x400#500x400|400x300|300x200");
const base::DictionaryValue* properties =
......
......@@ -44,7 +44,7 @@ struct ResolutionNotificationController::ResolutionChangeInfo {
ResolutionChangeInfo(int64_t display_id,
const display::ManagedDisplayMode& old_resolution,
const display::ManagedDisplayMode& new_resolution,
const base::Closure& accept_callback);
base::OnceClosure accept_callback);
~ResolutionChangeInfo();
// The id of the display where the resolution change happens.
......@@ -61,7 +61,7 @@ struct ResolutionNotificationController::ResolutionChangeInfo {
display::ManagedDisplayMode current_resolution;
// The callback when accept is chosen.
const base::Closure accept_callback;
base::OnceClosure accept_callback;
// The remaining timeout in seconds. 0 if the change does not time out.
uint8_t timeout_count;
......@@ -79,11 +79,11 @@ ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo(
int64_t display_id,
const display::ManagedDisplayMode& old_resolution,
const display::ManagedDisplayMode& new_resolution,
const base::Closure& accept_callback)
base::OnceClosure accept_callback)
: display_id(display_id),
old_resolution(old_resolution),
new_resolution(new_resolution),
accept_callback(accept_callback),
accept_callback(std::move(accept_callback)),
timeout_count(0) {
display::DisplayManager* display_manager = Shell::Get()->display_manager();
if (!display::Display::HasInternalDisplay() &&
......@@ -115,7 +115,7 @@ bool ResolutionNotificationController::PrepareNotificationAndSetDisplayMode(
int64_t display_id,
const display::ManagedDisplayMode& old_resolution,
const display::ManagedDisplayMode& new_resolution,
const base::Closure& accept_callback) {
base::OnceClosure accept_callback) {
Shell::Get()->screen_layout_observer()->SetDisplayChangedFromSettingsUI(
display_id);
display::DisplayManager* const display_manager =
......@@ -144,7 +144,7 @@ bool ResolutionNotificationController::PrepareNotificationAndSetDisplayMode(
}
change_info_ = std::make_unique<ResolutionChangeInfo>(
display_id, old_resolution, new_resolution, accept_callback);
display_id, old_resolution, new_resolution, std::move(accept_callback));
if (!original_resolution.size().IsEmpty())
change_info_->old_resolution = original_resolution;
......@@ -243,9 +243,9 @@ void ResolutionNotificationController::AcceptResolutionChange(
}
if (!change_info_)
return;
base::Closure callback = change_info_->accept_callback;
base::OnceClosure callback = std::move(change_info_->accept_callback);
change_info_.reset();
callback.Run();
std::move(callback).Run();
}
void ResolutionNotificationController::RevertResolutionChange(
......
......@@ -59,7 +59,7 @@ class ASH_EXPORT ResolutionNotificationController
int64_t display_id,
const display::ManagedDisplayMode& old_resolution,
const display::ManagedDisplayMode& new_resolution,
const base::Closure& accept_callback) WARN_UNUSED_RESULT;
base::OnceClosure accept_callback) WARN_UNUSED_RESULT;
// Returns true if the notification is visible or scheduled to be visible and
// the notification times out.
......
......@@ -68,8 +68,8 @@ class ResolutionNotificationControllerTest : public AshTestBase {
EXPECT_TRUE(controller()->PrepareNotificationAndSetDisplayMode(
display.id(), old_mode, new_mode,
base::Bind(&ResolutionNotificationControllerTest::OnAccepted,
base::Unretained(this))));
base::BindOnce(&ResolutionNotificationControllerTest::OnAccepted,
base::Unretained(this))));
// OnConfigurationChanged event won't be emitted in the test environment,
// so invoke UpdateDisplay() to emit that event explicitly.
......
......@@ -335,7 +335,7 @@ std::string SetDisplayMode(display::DisplayManager* display_manager,
if (!ash::Shell::Get()
->resolution_notification_controller()
->PrepareNotificationAndSetDisplayMode(
id, current_mode, new_mode, base::BindRepeating([]() {
id, current_mode, new_mode, base::BindOnce([]() {
ash::Shell::Get()->display_prefs()->StoreDisplayPrefs();
}))) {
return "Failed to set display mode.";
......
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