[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_ |
| 6 | #define CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_ |
| 7 | |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 8 | #include "base/macros.h" |
kouhei | ae802877 | 2015-08-17 03:01:46 | [diff] [blame] | 9 | #include "chrome/browser/ui/tabs/tab_strip_model_stats_recorder.h" |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 10 | #include "content/public/browser/notification_observer.h" |
kouhei | ae802877 | 2015-08-17 03:01:46 | [diff] [blame] | 11 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 12 | |
| 13 | namespace chrome { |
| 14 | |
| 15 | // This object is instantiated when the first Browser object is added to the |
| 16 | // list and delete when the last one is removed. It watches for loads and |
| 17 | // creates histograms of some global object counts. |
| 18 | class UMABrowsingActivityObserver : public content::NotificationObserver { |
| 19 | public: |
| 20 | static void Init(); |
| 21 | |
| 22 | private: |
| 23 | UMABrowsingActivityObserver(); |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 24 | ~UMABrowsingActivityObserver() override; |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 25 | |
| 26 | // content::NotificationObserver implementation. |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 27 | void Observe(int type, |
| 28 | const content::NotificationSource& source, |
| 29 | const content::NotificationDetails& details) override; |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 30 | |
Kyle Spiers | 6fef8a8 | 2019-05-08 23:05:07 | [diff] [blame] | 31 | // Calculates the time from an update being visible to the browser and |
| 32 | // the browser restarting or quitting and logs it. |
| 33 | void LogTimeBeforeUpdate() const; |
| 34 | |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 35 | // Counts the number of active RenderProcessHosts and logs them. |
| 36 | void LogRenderProcessHostCount() const; |
| 37 | |
| 38 | // Counts the number of tabs in each browser window and logs them. This is |
| 39 | // different than the number of WebContents objects since WebContents objects |
| 40 | // can be used for popups and in dialog boxes. We're just counting toplevel |
| 41 | // tabs here. |
| 42 | void LogBrowserTabCount() const; |
| 43 | |
Charlene Yan | a3e849e7 | 2020-10-09 23:16:47 | [diff] [blame^] | 44 | // Maps |total_tab_count| to the corresponding histogram bucket with the |
| 45 | // proper name suffix. |
| 46 | std::string AppendTabBucketCountToHistogramName(int total_tab_count) const; |
| 47 | |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 48 | content::NotificationRegistrar registrar_; |
kouhei | ae802877 | 2015-08-17 03:01:46 | [diff] [blame] | 49 | TabStripModelStatsRecorder tab_recorder_; |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 50 | |
| 51 | DISALLOW_COPY_AND_ASSIGN(UMABrowsingActivityObserver); |
| 52 | }; |
| 53 | |
| 54 | } // namespace chrome |
| 55 | |
| 56 | #endif // CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_ |