[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 | |
| 31 | // Counts the number of active RenderProcessHosts and logs them. |
| 32 | void LogRenderProcessHostCount() const; |
| 33 | |
| 34 | // Counts the number of tabs in each browser window and logs them. This is |
| 35 | // different than the number of WebContents objects since WebContents objects |
| 36 | // can be used for popups and in dialog boxes. We're just counting toplevel |
| 37 | // tabs here. |
| 38 | void LogBrowserTabCount() const; |
| 39 | |
| 40 | content::NotificationRegistrar registrar_; |
kouhei | ae802877 | 2015-08-17 03:01:46 | [diff] [blame] | 41 | TabStripModelStatsRecorder tab_recorder_; |
[email protected] | 3770c24 | 2012-07-12 22:58:17 | [diff] [blame] | 42 | |
| 43 | DISALLOW_COPY_AND_ASSIGN(UMABrowsingActivityObserver); |
| 44 | }; |
| 45 | |
| 46 | } // namespace chrome |
| 47 | |
| 48 | #endif // CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_ |