OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 update.get(chromeos::ACCELEROMETER_SOURCE_SCREEN)).Length()) <= | 87 update.get(chromeos::ACCELEROMETER_SOURCE_SCREEN)).Length()) <= |
88 kNoisyMagnitudeDeviation; | 88 kNoisyMagnitudeDeviation; |
89 } | 89 } |
90 #endif // OS_CHROMEOS | 90 #endif // OS_CHROMEOS |
91 | 91 |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 MaximizeModeController::MaximizeModeController() | 94 MaximizeModeController::MaximizeModeController() |
95 : have_seen_accelerometer_data_(false), | 95 : have_seen_accelerometer_data_(false), |
96 lid_open_past_180_(false), | 96 lid_open_past_180_(false), |
97 last_touchview_transition_time_(base::Time::Now()), | 97 touchview_usage_interval_start_time_(base::Time::Now()), |
98 tick_clock_(new base::DefaultTickClock()), | 98 tick_clock_(new base::DefaultTickClock()), |
99 lid_is_closed_(false) { | 99 lid_is_closed_(false) { |
100 Shell::GetInstance()->AddShellObserver(this); | 100 Shell::GetInstance()->AddShellObserver(this); |
101 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
102 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); | 102 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); |
103 chromeos::DBusThreadManager::Get()-> | 103 chromeos::DBusThreadManager::Get()-> |
104 GetPowerManagerClient()->AddObserver(this); | 104 GetPowerManagerClient()->AddObserver(this); |
105 #endif // OS_CHROMEOS | 105 #endif // OS_CHROMEOS |
106 } | 106 } |
107 | 107 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 178 |
179 void MaximizeModeController::LidEventReceived(bool open, | 179 void MaximizeModeController::LidEventReceived(bool open, |
180 const base::TimeTicks& time) { | 180 const base::TimeTicks& time) { |
181 if (open) | 181 if (open) |
182 last_lid_open_time_ = time; | 182 last_lid_open_time_ = time; |
183 lid_is_closed_ = !open; | 183 lid_is_closed_ = !open; |
184 LeaveMaximizeMode(); | 184 LeaveMaximizeMode(); |
185 } | 185 } |
186 | 186 |
187 void MaximizeModeController::SuspendImminent() { | 187 void MaximizeModeController::SuspendImminent() { |
188 RecordTouchViewStateTransition(); | 188 // The system is about to suspend, so record TouchView usage interval metrics |
189 // based on whether TouchView mode is currently active. | |
190 TouchViewIntervalType type = TOUCH_VIEW_INTERVAL_INACTIVE; | |
191 if (IsMaximizeModeWindowManagerEnabled()) | |
192 type = TOUCH_VIEW_INTERVAL_ACTIVE; | |
flackr
2015/02/12 19:59:06
If it's a bool, can you just use IsMaximizeModeWin
tdanderson
2015/02/12 20:30:49
OK, will do.
tdanderson
2015/02/12 21:38:22
Done.
| |
193 RecordTouchViewUsageInterval(type); | |
189 } | 194 } |
190 | 195 |
191 void MaximizeModeController::SuspendDone( | 196 void MaximizeModeController::SuspendDone( |
192 const base::TimeDelta& sleep_duration) { | 197 const base::TimeDelta& sleep_duration) { |
193 last_touchview_transition_time_ = base::Time::Now(); | 198 // We do not want TouchView usage metrics to include time spent in suspend. |
199 touchview_usage_interval_start_time_ = base::Time::Now(); | |
194 } | 200 } |
195 | 201 |
196 void MaximizeModeController::HandleHingeRotation( | 202 void MaximizeModeController::HandleHingeRotation( |
197 const chromeos::AccelerometerUpdate& update) { | 203 const chromeos::AccelerometerUpdate& update) { |
198 static const gfx::Vector3dF hinge_vector(1.0f, 0.0f, 0.0f); | 204 static const gfx::Vector3dF hinge_vector(1.0f, 0.0f, 0.0f); |
199 // Ignore the component of acceleration parallel to the hinge for the purposes | 205 // Ignore the component of acceleration parallel to the hinge for the purposes |
200 // of hinge angle calculation. | 206 // of hinge angle calculation. |
201 gfx::Vector3dF base_flattened(ui::ConvertAccelerometerReadingToVector3dF( | 207 gfx::Vector3dF base_flattened(ui::ConvertAccelerometerReadingToVector3dF( |
202 update.get(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD))); | 208 update.get(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD))); |
203 gfx::Vector3dF lid_flattened(ui::ConvertAccelerometerReadingToVector3dF( | 209 gfx::Vector3dF lid_flattened(ui::ConvertAccelerometerReadingToVector3dF( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 } | 267 } |
262 | 268 |
263 void MaximizeModeController::LeaveMaximizeMode() { | 269 void MaximizeModeController::LeaveMaximizeMode() { |
264 if (!IsMaximizeModeWindowManagerEnabled()) | 270 if (!IsMaximizeModeWindowManagerEnabled()) |
265 return; | 271 return; |
266 EnableMaximizeModeWindowManager(false); | 272 EnableMaximizeModeWindowManager(false); |
267 } | 273 } |
268 | 274 |
269 // Called after maximize mode has started, windows might still animate though. | 275 // Called after maximize mode has started, windows might still animate though. |
270 void MaximizeModeController::OnMaximizeModeStarted() { | 276 void MaximizeModeController::OnMaximizeModeStarted() { |
271 RecordTouchViewStateTransition(); | 277 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); |
272 } | 278 } |
273 | 279 |
274 // Called after maximize mode has ended, windows might still be returning to | 280 // Called after maximize mode has ended, windows might still be returning to |
275 // their original position. | 281 // their original position. |
276 void MaximizeModeController::OnMaximizeModeEnded() { | 282 void MaximizeModeController::OnMaximizeModeEnded() { |
277 RecordTouchViewStateTransition(); | 283 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_ACTIVE); |
278 } | 284 } |
279 | 285 |
280 void MaximizeModeController::RecordTouchViewStateTransition() { | 286 void MaximizeModeController::RecordTouchViewUsageInterval( |
281 if (CanEnterMaximizeMode()) { | 287 TouchViewIntervalType type) { |
282 base::Time current_time = base::Time::Now(); | 288 if (!CanEnterMaximizeMode()) |
283 base::TimeDelta delta = current_time - last_touchview_transition_time_; | 289 return; |
284 if (IsMaximizeModeWindowManagerEnabled()) { | 290 |
291 base::Time current_time = base::Time::Now(); | |
292 base::TimeDelta delta = current_time - touchview_usage_interval_start_time_; | |
293 switch (type) { | |
294 case TOUCH_VIEW_INTERVAL_INACTIVE: | |
285 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewInactive", delta); | 295 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewInactive", delta); |
286 total_non_touchview_time_ += delta; | 296 total_non_touchview_time_ += delta; |
287 } else { | 297 break; |
298 case TOUCH_VIEW_INTERVAL_ACTIVE: | |
288 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewActive", delta); | 299 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewActive", delta); |
289 total_touchview_time_ += delta; | 300 total_touchview_time_ += delta; |
290 } | 301 break; |
291 last_touchview_transition_time_ = current_time; | |
292 } | 302 } |
303 | |
304 touchview_usage_interval_start_time_ = current_time; | |
293 } | 305 } |
294 | 306 |
295 void MaximizeModeController::OnAppTerminating() { | 307 void MaximizeModeController::OnAppTerminating() { |
308 // The system is about to shut down, so record TouchView usage interval | |
309 // metrics based on whether TouchView mode is currently active. | |
310 TouchViewIntervalType type = TOUCH_VIEW_INTERVAL_INACTIVE; | |
311 if (IsMaximizeModeWindowManagerEnabled()) | |
312 type = TOUCH_VIEW_INTERVAL_ACTIVE; | |
313 RecordTouchViewUsageInterval(type); | |
314 | |
296 if (CanEnterMaximizeMode()) { | 315 if (CanEnterMaximizeMode()) { |
297 RecordTouchViewStateTransition(); | |
298 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", | 316 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", |
299 total_touchview_time_.InMinutes(), | 317 total_touchview_time_.InMinutes(), |
300 1, base::TimeDelta::FromDays(7).InMinutes(), 50); | 318 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
301 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal", | 319 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal", |
302 total_non_touchview_time_.InMinutes(), | 320 total_non_touchview_time_.InMinutes(), |
303 1, base::TimeDelta::FromDays(7).InMinutes(), 50); | 321 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
304 base::TimeDelta total_runtime = total_touchview_time_ + | 322 base::TimeDelta total_runtime = total_touchview_time_ + |
305 total_non_touchview_time_; | 323 total_non_touchview_time_; |
306 if (total_runtime.InSeconds() > 0) { | 324 if (total_runtime.InSeconds() > 0) { |
307 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", | 325 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", |
(...skipping 12 matching lines...) Expand all Loading... | |
320 return elapsed_time <= kLidRecentlyOpenedDuration; | 338 return elapsed_time <= kLidRecentlyOpenedDuration; |
321 } | 339 } |
322 | 340 |
323 void MaximizeModeController::SetTickClockForTest( | 341 void MaximizeModeController::SetTickClockForTest( |
324 scoped_ptr<base::TickClock> tick_clock) { | 342 scoped_ptr<base::TickClock> tick_clock) { |
325 DCHECK(tick_clock_); | 343 DCHECK(tick_clock_); |
326 tick_clock_ = tick_clock.Pass(); | 344 tick_clock_ = tick_clock.Pass(); |
327 } | 345 } |
328 | 346 |
329 } // namespace ash | 347 } // namespace ash |
OLD | NEW |