Chromium Code Reviews| 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..6de0f47e06489dde68140bdc0ae87e3a6e4887c7 |
| --- /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(); |
| + |
| + void OnLoadInMainFrame(int pid); |
|
Alexei Svitkine (slow)
2017/03/02 16:12:24
Add a comment.
keishi
2017/03/08 14:27:43
Done.
|
| + |
| + // content::NotificationObserver: |
| + void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) override; |
| + |
| + protected: |
| + RendererUptimeTracker(); |
| + ~RendererUptimeTracker() override; |
| + |
| + void OnRendererStarted(int pid); |
|
Alexei Svitkine (slow)
2017/03/02 16:12:24
Why protected and not private?
keishi
2017/03/08 14:27:44
Done.
|
| + void OnRendererTerminated(int pid); |
| + |
| + private: |
| + // 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_ |