| OLD | NEW |
| 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/metrics/user_metrics_recorder.h" | 5 #include "ash/metrics/user_metrics_recorder.h" |
| 6 | 6 |
| 7 #include "ash/common/metrics/pointer_metrics_recorder.h" | 7 #include "ash/common/metrics/pointer_metrics_recorder.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/shelf_delegate.h" | |
| 10 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/shelf/shelf_view.h" | 10 #include "ash/common/shelf/shelf_view.h" |
| 12 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 17 #include "ash/metrics/desktop_task_switch_metric_recorder.h" | 16 #include "ash/metrics/desktop_task_switch_metric_recorder.h" |
| 18 #include "ash/public/cpp/shelf_item.h" | 17 #include "ash/public/cpp/shelf_item.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 18 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 maximized_or_fullscreen_window_present = true; | 161 maximized_or_fullscreen_window_present = true; |
| 163 break; | 162 break; |
| 164 } | 163 } |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 return visible_window_count; | 166 return visible_window_count; |
| 168 } | 167 } |
| 169 | 168 |
| 170 // Records the number of items in the shelf as an UMA statistic. | 169 // Records the number of items in the shelf as an UMA statistic. |
| 171 void RecordShelfItemCounts() { | 170 void RecordShelfItemCounts() { |
| 172 ShelfDelegate* shelf_delegate = Shell::Get()->shelf_delegate(); | |
| 173 DCHECK(shelf_delegate); | |
| 174 | |
| 175 int pinned_item_count = 0; | 171 int pinned_item_count = 0; |
| 176 int unpinned_item_count = 0; | 172 int unpinned_item_count = 0; |
| 177 | 173 for (const ShelfItem& item : Shell::Get()->shelf_model()->items()) { |
| 178 for (const ShelfItem& shelf_item : Shell::Get()->shelf_model()->items()) { | 174 if (item.type == TYPE_PINNED_APP || item.type == TYPE_BROWSER_SHORTCUT) |
| 179 if (shelf_item.type != TYPE_APP_LIST) { | 175 ++pinned_item_count; |
| 180 // Internal ash apps do not have an app id and thus will always be counted | 176 else if (item.type != TYPE_APP_LIST) |
| 181 // as unpinned. | 177 ++unpinned_item_count; |
| 182 if (shelf_delegate->HasShelfIDToAppIDMapping(shelf_item.id) && | |
| 183 shelf_delegate->IsAppPinned( | |
| 184 shelf_delegate->GetAppIDForShelfID(shelf_item.id))) { | |
| 185 ++pinned_item_count; | |
| 186 } else { | |
| 187 ++unpinned_item_count; | |
| 188 } | |
| 189 } | |
| 190 } | 178 } |
| 191 | 179 |
| 192 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfItems", | 180 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfItems", |
| 193 pinned_item_count + unpinned_item_count); | 181 pinned_item_count + unpinned_item_count); |
| 194 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfPinnedItems", pinned_item_count); | 182 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfPinnedItems", pinned_item_count); |
| 195 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfUnpinnedItems", | 183 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfUnpinnedItems", |
| 196 unpinned_item_count); | 184 unpinned_item_count); |
| 197 } | 185 } |
| 198 | 186 |
| 199 } // namespace | 187 } // namespace |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive(); | 629 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive(); |
| 642 } | 630 } |
| 643 | 631 |
| 644 void UserMetricsRecorder::StartTimer() { | 632 void UserMetricsRecorder::StartTimer() { |
| 645 timer_.Start(FROM_HERE, | 633 timer_.Start(FROM_HERE, |
| 646 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), | 634 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), |
| 647 this, &UserMetricsRecorder::RecordPeriodicMetrics); | 635 this, &UserMetricsRecorder::RecordPeriodicMetrics); |
| 648 } | 636 } |
| 649 | 637 |
| 650 } // namespace ash | 638 } // namespace ash |
| OLD | NEW |