Chromium Code Reviews| Index: ash/wm/maximize_mode/maximize_mode_controller.cc |
| diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc |
| index ddf1d033f8e1dddd345e8bca1cf5c2241bfe324e..fd5129331c6e8e6dcd4172d97d2c5c5500db0985 100644 |
| --- a/ash/wm/maximize_mode/maximize_mode_controller.cc |
| +++ b/ash/wm/maximize_mode/maximize_mode_controller.cc |
| @@ -94,7 +94,7 @@ bool IsAngleBetweenAccelerometerReadingsStable( |
| MaximizeModeController::MaximizeModeController() |
| : have_seen_accelerometer_data_(false), |
| lid_open_past_180_(false), |
| - last_touchview_transition_time_(base::Time::Now()), |
| + touchview_usage_interval_start_time_(base::Time::Now()), |
| tick_clock_(new base::DefaultTickClock()), |
| lid_is_closed_(false) { |
| Shell::GetInstance()->AddShellObserver(this); |
| @@ -185,12 +185,18 @@ void MaximizeModeController::LidEventReceived(bool open, |
| } |
| void MaximizeModeController::SuspendImminent() { |
| - RecordTouchViewStateTransition(); |
| + // The system is about to suspend, so record TouchView usage interval metrics |
| + // based on whether TouchView mode is currently active. |
| + TouchViewIntervalType type = TOUCH_VIEW_INTERVAL_INACTIVE; |
| + if (IsMaximizeModeWindowManagerEnabled()) |
| + 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.
|
| + RecordTouchViewUsageInterval(type); |
| } |
| void MaximizeModeController::SuspendDone( |
| const base::TimeDelta& sleep_duration) { |
| - last_touchview_transition_time_ = base::Time::Now(); |
| + // We do not want TouchView usage metrics to include time spent in suspend. |
| + touchview_usage_interval_start_time_ = base::Time::Now(); |
| } |
| void MaximizeModeController::HandleHingeRotation( |
| @@ -268,33 +274,45 @@ void MaximizeModeController::LeaveMaximizeMode() { |
| // Called after maximize mode has started, windows might still animate though. |
| void MaximizeModeController::OnMaximizeModeStarted() { |
| - RecordTouchViewStateTransition(); |
| + RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); |
| } |
| // Called after maximize mode has ended, windows might still be returning to |
| // their original position. |
| void MaximizeModeController::OnMaximizeModeEnded() { |
| - RecordTouchViewStateTransition(); |
| + RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_ACTIVE); |
| } |
| -void MaximizeModeController::RecordTouchViewStateTransition() { |
| - if (CanEnterMaximizeMode()) { |
| - base::Time current_time = base::Time::Now(); |
| - base::TimeDelta delta = current_time - last_touchview_transition_time_; |
| - if (IsMaximizeModeWindowManagerEnabled()) { |
| +void MaximizeModeController::RecordTouchViewUsageInterval( |
| + TouchViewIntervalType type) { |
| + if (!CanEnterMaximizeMode()) |
| + return; |
| + |
| + base::Time current_time = base::Time::Now(); |
| + base::TimeDelta delta = current_time - touchview_usage_interval_start_time_; |
| + switch (type) { |
| + case TOUCH_VIEW_INTERVAL_INACTIVE: |
| UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewInactive", delta); |
| total_non_touchview_time_ += delta; |
| - } else { |
| + break; |
| + case TOUCH_VIEW_INTERVAL_ACTIVE: |
| UMA_HISTOGRAM_LONG_TIMES("Ash.TouchView.TouchViewActive", delta); |
| total_touchview_time_ += delta; |
| - } |
| - last_touchview_transition_time_ = current_time; |
| + break; |
| } |
| + |
| + touchview_usage_interval_start_time_ = current_time; |
| } |
| void MaximizeModeController::OnAppTerminating() { |
| + // The system is about to shut down, so record TouchView usage interval |
| + // metrics based on whether TouchView mode is currently active. |
| + TouchViewIntervalType type = TOUCH_VIEW_INTERVAL_INACTIVE; |
| + if (IsMaximizeModeWindowManagerEnabled()) |
| + type = TOUCH_VIEW_INTERVAL_ACTIVE; |
| + RecordTouchViewUsageInterval(type); |
| + |
| if (CanEnterMaximizeMode()) { |
| - RecordTouchViewStateTransition(); |
| UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", |
| total_touchview_time_.InMinutes(), |
| 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |