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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/renderer_uptime_tracker.h
diff --git a/chrome/browser/metrics/renderer_uptime_tracker.h b/chrome/browser/metrics/renderer_uptime_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c4cf2455a5ef30620b020260d337f1695030d12
--- /dev/null
+++ b/chrome/browser/metrics/renderer_uptime_tracker.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_RENDERER_UPTIME_TRACKER_H_
+#define CHROME_BROWSER_METRICS_RENDERER_UPTIME_TRACKER_H_
+
+#include <map>
+
+#include "base/time/time.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace metrics {
+
+// Class for tracking and renderer uptime info.
+class RendererUptimeTracker : public content::NotificationObserver {
+ public:
+ // Creates the |RendererUptimeTracker| instance and initializes the
+ // observers that notify to it.
+ static void Initialize();
+
+ // Returns the |RendererUptimeTracker| instance.
+ static RendererUptimeTracker* Get();
+
+ // Called when a load happens in a main frame.
+ void OnLoadInMainFrame(int pid);
+
+ // content::NotificationObserver:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ private:
+ RendererUptimeTracker();
+ ~RendererUptimeTracker() override;
+
+ void OnRendererStarted(int pid);
+ void OnRendererTerminated(int pid);
+
+ // Object for registering notification requests.
+ content::NotificationRegistrar registrar_;
+
+ struct RendererInfo {
+ base::TimeTicks launched_at_;
+ int num_loads_in_main_frame_;
+ };
+
+ // Maps RenderProcessHost ID to its info on uptime.
+ std::map<int, RendererInfo> info_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererUptimeTracker);
+};
+
+} // namespace metrics
+
+#endif // CHROME_BROWSER_METRICS_RENDERER_UPTIME_TRACKER_H_
« 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