OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback_list.h" | 10 #include "base/callback_list.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // SessionRestoreStatsCollector observes SessionRestore events ands records UMA | 21 // SessionRestoreStatsCollector observes SessionRestore events ands records UMA |
22 // accordingly. | 22 // accordingly. |
23 class SessionRestoreStatsCollector | 23 class SessionRestoreStatsCollector |
24 : public content::NotificationObserver, | 24 : public content::NotificationObserver, |
25 public base::RefCounted<SessionRestoreStatsCollector> { | 25 public base::RefCounted<SessionRestoreStatsCollector> { |
26 public: | 26 public: |
27 // Called to start tracking tabs. If a restore is already occuring, the tabs | 27 // Called to start tracking tabs. If a restore is already occuring, the tabs |
28 // are added to the existing list of tracked tabs. | 28 // are added to the existing list of tracked tabs. |
29 static void TrackTabs( | 29 static void TrackTabs( |
30 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs, | 30 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs, |
31 const base::TimeTicks& restore_started); | 31 const base::TimeTicks& restore_started, |
| 32 bool active_only); |
32 | 33 |
33 private: | 34 private: |
34 friend class base::RefCounted<SessionRestoreStatsCollector>; | 35 friend class base::RefCounted<SessionRestoreStatsCollector>; |
35 | 36 |
36 using RenderWidgetHostSet = std::set<content::RenderWidgetHost*>; | 37 using RenderWidgetHostSet = std::set<content::RenderWidgetHost*>; |
37 | 38 |
38 explicit SessionRestoreStatsCollector(const base::TimeTicks& restore_started); | 39 explicit SessionRestoreStatsCollector(const base::TimeTicks& restore_started, |
| 40 bool active_only); |
39 ~SessionRestoreStatsCollector() override; | 41 ~SessionRestoreStatsCollector() override; |
40 | 42 |
41 // NotificationObserver method. | 43 // NotificationObserver method. |
42 void Observe(int type, | 44 void Observe(int type, |
43 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
44 const content::NotificationDetails& details) override; | 46 const content::NotificationDetails& details) override; |
45 | 47 |
46 // Adds new tabs to the list of tracked tabs. | 48 // Adds new tabs to the list of tracked tabs. |
47 void AddTabs(const std::vector<SessionRestoreDelegate::RestoredTab>& tabs); | 49 void AddTabs(const std::vector<SessionRestoreDelegate::RestoredTab>& tabs); |
48 | 50 |
(...skipping 27 matching lines...) Expand all Loading... |
76 | 78 |
77 // The number of tabs that have been restored. | 79 // The number of tabs that have been restored. |
78 int tab_count_; | 80 int tab_count_; |
79 | 81 |
80 // Max number of tabs that were loaded in parallel (for metrics). | 82 // Max number of tabs that were loaded in parallel (for metrics). |
81 size_t max_parallel_tab_loads_; | 83 size_t max_parallel_tab_loads_; |
82 | 84 |
83 // Notification registrar. | 85 // Notification registrar. |
84 content::NotificationRegistrar registrar_; | 86 content::NotificationRegistrar registrar_; |
85 | 87 |
| 88 // Are we only restoring active tabs? |
| 89 bool active_only_; |
| 90 |
86 // To keep the collector alive as long as needed. | 91 // To keep the collector alive as long as needed. |
87 scoped_refptr<SessionRestoreStatsCollector> this_retainer_; | 92 scoped_refptr<SessionRestoreStatsCollector> this_retainer_; |
88 | 93 |
89 // The shared SessionRestoreNotifier instance for all SessionRestores running | 94 // The shared SessionRestoreNotifier instance for all SessionRestores running |
90 // at this time. | 95 // at this time. |
91 static SessionRestoreStatsCollector* shared_collector_; | 96 static SessionRestoreStatsCollector* shared_collector_; |
92 | 97 |
93 DISALLOW_COPY_AND_ASSIGN(SessionRestoreStatsCollector); | 98 DISALLOW_COPY_AND_ASSIGN(SessionRestoreStatsCollector); |
94 }; | 99 }; |
95 | 100 |
96 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ | 101 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ |
OLD | NEW |