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

Side by Side Diff: ash/display/resolution_notification_controller.cc

Issue 1540753002: Switch to standard integer types in ash/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arraysize Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/resolution_notification_controller.h" 5 #include "ash/display/resolution_notification_controller.h"
6 6
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/system_notifier.h" 10 #include "ash/system/system_notifier.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } // namespace 86 } // namespace
87 87
88 // static 88 // static
89 const int ResolutionNotificationController::kTimeoutInSec = 15; 89 const int ResolutionNotificationController::kTimeoutInSec = 15;
90 90
91 // static 91 // static
92 const char ResolutionNotificationController::kNotificationId[] = 92 const char ResolutionNotificationController::kNotificationId[] =
93 "chrome://settings/display/resolution"; 93 "chrome://settings/display/resolution";
94 94
95 struct ResolutionNotificationController::ResolutionChangeInfo { 95 struct ResolutionNotificationController::ResolutionChangeInfo {
96 ResolutionChangeInfo(int64 display_id, 96 ResolutionChangeInfo(int64_t display_id,
97 const DisplayMode& old_resolution, 97 const DisplayMode& old_resolution,
98 const DisplayMode& new_resolution, 98 const DisplayMode& new_resolution,
99 const base::Closure& accept_callback); 99 const base::Closure& accept_callback);
100 ~ResolutionChangeInfo(); 100 ~ResolutionChangeInfo();
101 101
102 // The id of the display where the resolution change happens. 102 // The id of the display where the resolution change happens.
103 int64 display_id; 103 int64_t display_id;
104 104
105 // The resolution before the change. 105 // The resolution before the change.
106 DisplayMode old_resolution; 106 DisplayMode old_resolution;
107 107
108 // The requested resolution. Note that this may be different from 108 // The requested resolution. Note that this may be different from
109 // |current_resolution| which is the actual resolution set. 109 // |current_resolution| which is the actual resolution set.
110 DisplayMode new_resolution; 110 DisplayMode new_resolution;
111 111
112 // The actual resolution after the change. 112 // The actual resolution after the change.
113 DisplayMode current_resolution; 113 DisplayMode current_resolution;
114 114
115 // The callback when accept is chosen. 115 // The callback when accept is chosen.
116 base::Closure accept_callback; 116 base::Closure accept_callback;
117 117
118 // The remaining timeout in seconds. 0 if the change does not time out. 118 // The remaining timeout in seconds. 0 if the change does not time out.
119 uint8 timeout_count; 119 uint8_t timeout_count;
120 120
121 // The timer to invoke OnTimerTick() every second. This cannot be 121 // The timer to invoke OnTimerTick() every second. This cannot be
122 // OneShotTimer since the message contains text "automatically closed in xx 122 // OneShotTimer since the message contains text "automatically closed in xx
123 // seconds..." which has to be updated every second. 123 // seconds..." which has to be updated every second.
124 base::RepeatingTimer timer; 124 base::RepeatingTimer timer;
125 125
126 private: 126 private:
127 DISALLOW_COPY_AND_ASSIGN(ResolutionChangeInfo); 127 DISALLOW_COPY_AND_ASSIGN(ResolutionChangeInfo);
128 }; 128 };
129 129
130 ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo( 130 ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo(
131 int64 display_id, 131 int64_t display_id,
132 const DisplayMode& old_resolution, 132 const DisplayMode& old_resolution,
133 const DisplayMode& new_resolution, 133 const DisplayMode& new_resolution,
134 const base::Closure& accept_callback) 134 const base::Closure& accept_callback)
135 : display_id(display_id), 135 : display_id(display_id),
136 old_resolution(old_resolution), 136 old_resolution(old_resolution),
137 new_resolution(new_resolution), 137 new_resolution(new_resolution),
138 accept_callback(accept_callback), 138 accept_callback(accept_callback),
139 timeout_count(0) { 139 timeout_count(0) {
140 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 140 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
141 if (!gfx::Display::HasInternalDisplay() && 141 if (!gfx::Display::HasInternalDisplay() &&
(...skipping 10 matching lines...) Expand all
152 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); 152 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
153 Shell::GetScreen()->AddObserver(this); 153 Shell::GetScreen()->AddObserver(this);
154 } 154 }
155 155
156 ResolutionNotificationController::~ResolutionNotificationController() { 156 ResolutionNotificationController::~ResolutionNotificationController() {
157 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 157 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
158 Shell::GetScreen()->RemoveObserver(this); 158 Shell::GetScreen()->RemoveObserver(this);
159 } 159 }
160 160
161 void ResolutionNotificationController::PrepareNotification( 161 void ResolutionNotificationController::PrepareNotification(
162 int64 display_id, 162 int64_t display_id,
163 const DisplayMode& old_resolution, 163 const DisplayMode& old_resolution,
164 const DisplayMode& new_resolution, 164 const DisplayMode& new_resolution,
165 const base::Closure& accept_callback) { 165 const base::Closure& accept_callback) {
166 DCHECK(!gfx::Display::IsInternalDisplayId(display_id)); 166 DCHECK(!gfx::Display::IsInternalDisplayId(display_id));
167 // If multiple resolution changes are invoked for the same display, 167 // If multiple resolution changes are invoked for the same display,
168 // the original resolution for the first resolution change has to be used 168 // the original resolution for the first resolution change has to be used
169 // instead of the specified |old_resolution|. 169 // instead of the specified |old_resolution|.
170 DisplayMode original_resolution; 170 DisplayMode original_resolution;
171 if (change_info_ && change_info_->display_id == display_id) { 171 if (change_info_ && change_info_->display_id == display_id) {
172 DCHECK(change_info_->new_resolution.size == old_resolution.size); 172 DCHECK(change_info_->new_resolution.size == old_resolution.size);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 base::Closure callback = change_info_->accept_callback; 260 base::Closure callback = change_info_->accept_callback;
261 change_info_.reset(); 261 change_info_.reset();
262 callback.Run(); 262 callback.Run();
263 } 263 }
264 264
265 void ResolutionNotificationController::RevertResolutionChange() { 265 void ResolutionNotificationController::RevertResolutionChange() {
266 message_center::MessageCenter::Get()->RemoveNotification( 266 message_center::MessageCenter::Get()->RemoveNotification(
267 kNotificationId, false /* by_user */); 267 kNotificationId, false /* by_user */);
268 if (!change_info_) 268 if (!change_info_)
269 return; 269 return;
270 int64 display_id = change_info_->display_id; 270 int64_t display_id = change_info_->display_id;
271 DisplayMode old_resolution = change_info_->old_resolution; 271 DisplayMode old_resolution = change_info_->old_resolution;
272 change_info_.reset(); 272 change_info_.reset();
273 Shell::GetInstance()->display_manager()->SetDisplayMode( 273 Shell::GetInstance()->display_manager()->SetDisplayMode(
274 display_id, old_resolution); 274 display_id, old_resolution);
275 } 275 }
276 276
277 void ResolutionNotificationController::OnDisplayAdded( 277 void ResolutionNotificationController::OnDisplayAdded(
278 const gfx::Display& new_display) { 278 const gfx::Display& new_display) {
279 } 279 }
280 280
(...skipping 20 matching lines...) Expand all
301 this, 301 this,
302 &ResolutionNotificationController::OnTimerTick); 302 &ResolutionNotificationController::OnTimerTick);
303 } 303 }
304 } 304 }
305 305
306 void ResolutionNotificationController::SuppressTimerForTest() { 306 void ResolutionNotificationController::SuppressTimerForTest() {
307 g_use_timer = false; 307 g_use_timer = false;
308 } 308 }
309 309
310 } // namespace ash 310 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/resolution_notification_controller.h ('k') | ash/display/resolution_notification_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698