Chromium Code Reviews| 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 void OnLoadInMainFrame(int pid); | |
|
Alexei Svitkine (slow)
2017/03/02 16:12:24
Add a comment.
keishi
2017/03/08 14:27:43
Done.
| |
| 27 | |
| 28 // content::NotificationObserver: | |
| 29 void Observe(int type, | |
| 30 const content::NotificationSource& source, | |
| 31 const content::NotificationDetails& details) override; | |
| 32 | |
| 33 protected: | |
| 34 RendererUptimeTracker(); | |
| 35 ~RendererUptimeTracker() override; | |
| 36 | |
| 37 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.
| |
| 38 void OnRendererTerminated(int pid); | |
| 39 | |
| 40 private: | |
| 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 |