blob: 8390eca98728ae70b17f5d07600e8e735c5a25ba [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
avi655876a2015-12-25 07:18:158#include "base/macros.h"
kouheiae8028772015-08-17 03:01:469#include "chrome/browser/ui/tabs/tab_strip_model_stats_recorder.h"
[email protected]3770c242012-07-12 22:58:1710#include "content/public/browser/notification_observer.h"
kouheiae8028772015-08-17 03:01:4611#include "content/public/browser/notification_registrar.h"
[email protected]3770c242012-07-12 22:58:1712
13namespace 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.
18class UMABrowsingActivityObserver : public content::NotificationObserver {
19 public:
20 static void Init();
21
22 private:
23 UMABrowsingActivityObserver();
dcheng5dd5ff62014-10-21 12:42:3824 ~UMABrowsingActivityObserver() override;
[email protected]3770c242012-07-12 22:58:1725
26 // content::NotificationObserver implementation.
dcheng5dd5ff62014-10-21 12:42:3827 void Observe(int type,
28 const content::NotificationSource& source,
29 const content::NotificationDetails& details) override;
[email protected]3770c242012-07-12 22:58:1730
Kyle Spiers6fef8a82019-05-08 23:05:0731 // 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]3770c242012-07-12 22:58:1735 // 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 Yana3e849e72020-10-09 23:16:4744 // 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]3770c242012-07-12 22:58:1748 content::NotificationRegistrar registrar_;
kouheiae8028772015-08-17 03:01:4649 TabStripModelStatsRecorder tab_recorder_;
[email protected]3770c242012-07-12 22:58:1750
51 DISALLOW_COPY_AND_ASSIGN(UMABrowsingActivityObserver);
52};
53
54} // namespace chrome
55
56#endif // CHROME_BROWSER_UI_UMA_BROWSING_ACTIVITY_OBSERVER_H_