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 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType()); |
189 } | 191 } |
190 | 192 |
191 void MaximizeModeController::SuspendDone( | 193 void MaximizeModeController::SuspendDone( |
192 const base::TimeDelta& sleep_duration) { | 194 const base::TimeDelta& sleep_duration) { |
193 last_touchview_transition_time_ = base::Time::Now(); | 195 // We do not want TouchView usage metrics to include time spent in suspend. |
| 196 touchview_usage_interval_start_time_ = base::Time::Now(); |
194 } | 197 } |
195 | 198 |
196 void MaximizeModeController::HandleHingeRotation( | 199 void MaximizeModeController::HandleHingeRotation( |
197 const chromeos::AccelerometerUpdate& update) { | 200 const chromeos::AccelerometerUpdate& update) { |
198 static const gfx::Vector3dF hinge_vector(1.0f, 0.0f, 0.0f); | 201 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 | 202 // Ignore the component of acceleration parallel to the hinge for the purposes |
200 // of hinge angle calculation. | 203 // of hinge angle calculation. |
201 gfx::Vector3dF base_flattened(ui::ConvertAccelerometerReadingToVector3dF( | 204 gfx::Vector3dF base_flattened(ui::ConvertAccelerometerReadingToVector3dF( |
202 update.get(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD))); | 205 update.get(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD))); |
203 gfx::Vector3dF lid_flattened(ui::ConvertAccelerometerReadingToVector3dF( | 206 gfx::Vector3dF lid_flattened(ui::ConvertAccelerometerReadingToVector3dF( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 264 } |
262 | 265 |
263 void MaximizeModeController::LeaveMaximizeMode() { | 266 void MaximizeModeController::LeaveMaximizeMode() { |
264 if (!IsMaximizeModeWindowManagerEnabled()) | 267 if (!IsMaximizeModeWindowManagerEnabled()) |
265 return; | 268 return; |
266 EnableMaximizeModeWindowManager(false); | 269 EnableMaximizeModeWindowManager(false); |
267 } | 270 } |
268 | 271 |
269 // Called after maximize mode has started, windows might still animate though. | 272 // Called after maximize mode has started, windows might still animate though. |
270 void MaximizeModeController::OnMaximizeModeStarted() { | 273 void MaximizeModeController::OnMaximizeModeStarted() { |
271 RecordTouchViewStateTransition(); | 274 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); |
272 } | 275 } |
273 | 276 |
274 // Called after maximize mode has ended, windows might still be returning to | 277 // Called after maximize mode has ended, windows might still be returning to |
275 // their original position. | 278 // their original position. |
276 void MaximizeModeController::OnMaximizeModeEnded() { | 279 void MaximizeModeController::OnMaximizeModeEnded() { |
277 RecordTouchViewStateTransition(); | 280 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_ACTIVE); |
278 } | 281 } |
279 | 282 |
280 void MaximizeModeController::RecordTouchViewStateTransition() { | 283 void MaximizeModeController::RecordTouchViewUsageInterval( |
281 if (CanEnterMaximizeMode()) { | 284 TouchViewIntervalType type) { |
282 base::Time current_time = base::Time::Now(); | 285 if (!CanEnterMaximizeMode()) |
283 base::TimeDelta delta = current_time - last_touchview_transition_time_; | 286 return; |
284 if (IsMaximizeModeWindowManagerEnabled()) { | 287 |
| 288 base::Time current_time = base::Time::Now(); |
| 289 base::TimeDelta delta = current_time - touchview_usage_interval_start_time_; |
| 290 switch (type) { |
| 291 case TOUCH_VIEW_INTERVAL_INACTIVE: |
285 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewInactive", delta); | 292 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewInactive", delta); |
286 total_non_touchview_time_ += delta; | 293 total_non_touchview_time_ += delta; |
287 } else { | 294 break; |
| 295 case TOUCH_VIEW_INTERVAL_ACTIVE: |
288 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewActive", delta); | 296 UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewActive", delta); |
289 total_touchview_time_ += delta; | 297 total_touchview_time_ += delta; |
290 } | 298 break; |
291 last_touchview_transition_time_ = current_time; | |
292 } | 299 } |
| 300 |
| 301 touchview_usage_interval_start_time_ = current_time; |
| 302 } |
| 303 |
| 304 MaximizeModeController::TouchViewIntervalType |
| 305 MaximizeModeController::CurrentTouchViewIntervalType() { |
| 306 if (IsMaximizeModeWindowManagerEnabled()) |
| 307 return TOUCH_VIEW_INTERVAL_ACTIVE; |
| 308 return TOUCH_VIEW_INTERVAL_INACTIVE; |
293 } | 309 } |
294 | 310 |
295 void MaximizeModeController::OnAppTerminating() { | 311 void MaximizeModeController::OnAppTerminating() { |
| 312 // The system is about to shut down, so record TouchView usage interval |
| 313 // metrics based on whether TouchView mode is currently active. |
| 314 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType()); |
| 315 |
296 if (CanEnterMaximizeMode()) { | 316 if (CanEnterMaximizeMode()) { |
297 RecordTouchViewStateTransition(); | |
298 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", | 317 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", |
299 total_touchview_time_.InMinutes(), | 318 total_touchview_time_.InMinutes(), |
300 1, base::TimeDelta::FromDays(7).InMinutes(), 50); | 319 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
301 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal", | 320 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal", |
302 total_non_touchview_time_.InMinutes(), | 321 total_non_touchview_time_.InMinutes(), |
303 1, base::TimeDelta::FromDays(7).InMinutes(), 50); | 322 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
304 base::TimeDelta total_runtime = total_touchview_time_ + | 323 base::TimeDelta total_runtime = total_touchview_time_ + |
305 total_non_touchview_time_; | 324 total_non_touchview_time_; |
306 if (total_runtime.InSeconds() > 0) { | 325 if (total_runtime.InSeconds() > 0) { |
307 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", | 326 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", |
(...skipping 12 matching lines...) Expand all Loading... |
320 return elapsed_time <= kLidRecentlyOpenedDuration; | 339 return elapsed_time <= kLidRecentlyOpenedDuration; |
321 } | 340 } |
322 | 341 |
323 void MaximizeModeController::SetTickClockForTest( | 342 void MaximizeModeController::SetTickClockForTest( |
324 scoped_ptr<base::TickClock> tick_clock) { | 343 scoped_ptr<base::TickClock> tick_clock) { |
325 DCHECK(tick_clock_); | 344 DCHECK(tick_clock_); |
326 tick_clock_ = tick_clock.Pass(); | 345 tick_clock_ = tick_clock.Pass(); |
327 } | 346 } |
328 | 347 |
329 } // namespace ash | 348 } // namespace ash |
OLD | NEW |