Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/metrics/renderer_uptime_tracker.h

Issue 2697323004: Adds UMA metrics for renderer uptime (Closed)
Patch Set: fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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_METRICS_RENDERER_UPTIME_TRACKER_H_
6 #define CHROME_BROWSER_METRICS_RENDERER_UPTIME_TRACKER_H_
7
8 #include <map>
9
10 #include "base/time/time.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13
14 namespace metrics {
15
16 // Class for tracking and renderer uptime info.
17 class RendererUptimeTracker : public content::NotificationObserver {
18 public:
19 // Creates the |RendererUptimeTracker| instance and initializes the
20 // observers that notify to it.
21 static void Initialize();
22
23 // Returns the |RendererUptimeTracker| instance.
24 static RendererUptimeTracker* Get();
25
26 // Called when a load happens in a main frame.
27 void OnLoadInMainFrame(int pid);
28
29 // content::NotificationObserver:
30 void Observe(int type,
31 const content::NotificationSource& source,
32 const content::NotificationDetails& details) override;
33
34 private:
35 RendererUptimeTracker();
36 ~RendererUptimeTracker() override;
37
38 void OnRendererStarted(int pid);
39 void OnRendererTerminated(int pid);
40
41 // Object for registering notification requests.
42 content::NotificationRegistrar registrar_;
43
44 struct RendererInfo {
45 base::TimeTicks launched_at_;
46 int num_loads_in_main_frame_;
47 };
48
49 // Maps RenderProcessHost ID to its info on uptime.
50 std::map<int, RendererInfo> info_map_;
51
52 DISALLOW_COPY_AND_ASSIGN(RendererUptimeTracker);
53 };
54
55 } // namespace metrics
56
57 #endif // CHROME_BROWSER_METRICS_RENDERER_UPTIME_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/renderer_uptime_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698