blob: f96f74da18662beef1367a97d7d5b507e0d96b71 [file] [log] [blame]
[email protected]3770c242012-07-12 22:58:171// 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
kouheiae8028772015-08-17 03:01:468#include "chrome/browser/ui/tabs/tab_strip_model_stats_recorder.h"
[email protected]3770c242012-07-12 22:58:179#include "content/public/browser/notification_observer.h"
kouheiae8028772015-08-17 03:01:4610#include "content/public/browser/notification_registrar.h"
[email protected]3770c242012-07-12 22:58:1711
12namespace chrome {
13
14// This object is instantiated when the first Browser object is added to the
15// list and delete when the last one is removed. It watches for loads and
16// creates histograms of some global object counts.
17class UMABrowsingActivityObserver : public content::NotificationObserver {
18 public:
Peter Boströmc75681ac2021-09-24 16:58:4119 UMABrowsingActivityObserver(const UMABrowsingActivityObserver&) = delete;
20 UMABrowsingActivityObserver& operator=(const UMABrowsingActivityObserver&) =
21 delete;
22
[email protected]3770c242012-07-12 22:58:1723 static void Init();
24
25 private:
26 UMABrowsingActivityObserver();
dcheng5dd5ff62014-10-21 12:42:3827 ~UMABrowsingActivityObserver() override;
[email protected]3770c242012-07-12 22:58:1728
29 // content::NotificationObserver implementation.
dcheng5dd5ff62014-10-21 12:42:3830 void Observe(int type,
31 const content::NotificationSource& source,
32 const content::NotificationDetails& details) override;
[email protected]3770c242012-07-12 22:58:1733
Kyle Spiers6fef8a82019-05-08 23:05:0734 // Calculates the time from an update being visible to the browser and
35 // the browser restarting or quitting and logs it.
36 void LogTimeBeforeUpdate() const;
37
[email protected]3770c242012-07-12 22:58:1738 // Counts the number of active RenderProcessHosts and logs them.
39 void LogRenderProcessHostCount() const;
40
41 // Counts the number of tabs in each browser window and logs them. This is
42 // different than the number of WebContents objects since WebContents objects
43 // can be used for popups and in dialog boxes. We're just counting toplevel
44 // tabs here.
45 void LogBrowserTabCount() const;
46
Charlene Yan22ab8112020-10-02 17:28:1447 // Maps |total_tab_count| to the corresponding histogram bucket with the
48 // proper name suffix.
49 std::string AppendTabBucketCountToHistogramName(int total_tab_count) const;
50
[email protected]3770c242012-07-12 22:58:1751 content::NotificationRegistrar registrar_;
kouheiae8028772015-08-17 03:01:4652 TabStripModelStatsRecorder tab_recorder_;
[email protected]3770c242012-07-12 22:58:1753};
54
55} // namespace chrome
56
57#endif // CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_