| OLD | NEW |
| (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_ |
| OLD | NEW |