Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: ash/display/resolution_notification_controller.cc

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/display/resolution_notification_controller.cc
diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc
index ed57757b099a03156ff11e9b73a578819ad7a1fb..288960068fa72b4bd61c8a9d201f34315c99ef1e 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -94,8 +94,8 @@ const char ResolutionNotificationController::kNotificationId[] =
struct ResolutionNotificationController::ResolutionChangeInfo {
ResolutionChangeInfo(int64_t display_id,
- const DisplayMode& old_resolution,
- const DisplayMode& new_resolution,
+ const scoped_refptr<DisplayMode>& old_resolution,
+ const scoped_refptr<DisplayMode>& new_resolution,
const base::Closure& accept_callback);
~ResolutionChangeInfo();
@@ -103,14 +103,14 @@ struct ResolutionNotificationController::ResolutionChangeInfo {
int64_t display_id;
// The resolution before the change.
- DisplayMode old_resolution;
+ scoped_refptr<DisplayMode> old_resolution;
// The requested resolution. Note that this may be different from
// |current_resolution| which is the actual resolution set.
- DisplayMode new_resolution;
+ scoped_refptr<DisplayMode> new_resolution;
// The actual resolution after the change.
- DisplayMode current_resolution;
+ scoped_refptr<DisplayMode> current_resolution;
// The callback when accept is chosen.
base::Closure accept_callback;
@@ -129,8 +129,8 @@ struct ResolutionNotificationController::ResolutionChangeInfo {
ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo(
int64_t display_id,
- const DisplayMode& old_resolution,
- const DisplayMode& new_resolution,
+ const scoped_refptr<DisplayMode>& old_resolution,
+ const scoped_refptr<DisplayMode>& new_resolution,
const base::Closure& accept_callback)
: display_id(display_id),
old_resolution(old_resolution),
@@ -145,7 +145,11 @@ ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo(
}
ResolutionNotificationController::ResolutionChangeInfo::
- ~ResolutionChangeInfo() {}
+ ~ResolutionChangeInfo() {
+ old_resolution = nullptr;
+ new_resolution = nullptr;
+ current_resolution = nullptr;
+}
ResolutionNotificationController::ResolutionNotificationController() {
Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
@@ -159,22 +163,25 @@ ResolutionNotificationController::~ResolutionNotificationController() {
void ResolutionNotificationController::PrepareNotification(
int64_t display_id,
- const DisplayMode& old_resolution,
- const DisplayMode& new_resolution,
+ const scoped_refptr<DisplayMode>& old_resolution,
+ const scoped_refptr<DisplayMode>& new_resolution,
const base::Closure& accept_callback) {
+ DCHECK(old_resolution);
+ DCHECK(new_resolution);
+
DCHECK(!display::Display::IsInternalDisplayId(display_id));
// If multiple resolution changes are invoked for the same display,
// the original resolution for the first resolution change has to be used
// instead of the specified |old_resolution|.
- DisplayMode original_resolution;
+ scoped_refptr<DisplayMode> original_resolution;
if (change_info_ && change_info_->display_id == display_id) {
- DCHECK(change_info_->new_resolution.size == old_resolution.size);
+ DCHECK(change_info_->new_resolution->size() == old_resolution->size());
original_resolution = change_info_->old_resolution;
}
change_info_.reset(new ResolutionChangeInfo(display_id, old_resolution,
new_resolution, accept_callback));
- if (!original_resolution.size.IsEmpty())
+ if (original_resolution && !original_resolution->size().IsEmpty())
change_info_->old_resolution = original_resolution;
}
@@ -211,17 +218,19 @@ void ResolutionNotificationController::CreateOrUpdateNotification(
Shell::GetInstance()->display_manager()->GetDisplayNameForId(
change_info_->display_id));
const base::string16 message =
- (change_info_->new_resolution.size ==
- change_info_->current_resolution.size)
+ (change_info_->new_resolution->size() ==
+ change_info_->current_resolution->size())
? l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, display_name,
- base::UTF8ToUTF16(change_info_->new_resolution.size.ToString()))
+ base::UTF8ToUTF16(
+ change_info_->new_resolution->size().ToString()))
: l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED_TO_UNSUPPORTED,
display_name,
- base::UTF8ToUTF16(change_info_->new_resolution.size.ToString()),
base::UTF8ToUTF16(
- change_info_->current_resolution.size.ToString()));
+ change_info_->new_resolution->size().ToString()),
+ base::UTF8ToUTF16(
+ change_info_->current_resolution->size().ToString()));
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
std::unique_ptr<Notification> notification(new Notification(
@@ -267,7 +276,7 @@ void ResolutionNotificationController::RevertResolutionChange() {
if (!change_info_)
return;
int64_t display_id = change_info_->display_id;
- DisplayMode old_resolution = change_info_->old_resolution;
+ scoped_refptr<DisplayMode> old_resolution = change_info_->old_resolution;
change_info_.reset();
Shell::GetInstance()->display_manager()->SetDisplayMode(display_id,
old_resolution);

Powered by Google App Engine
This is Rietveld 408576698