| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ | 5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ |
| 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ | 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/performance_monitor/process_metrics_history.h" | 13 #include "chrome/browser/performance_monitor/process_metrics_history.h" |
| 14 | 14 |
| 15 namespace base { |
| 15 template <typename Type> | 16 template <typename Type> |
| 16 struct DefaultSingletonTraits; | 17 struct DefaultSingletonTraits; |
| 18 } // namespace base |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 struct ChildProcessData; | 21 struct ChildProcessData; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace performance_monitor { | 24 namespace performance_monitor { |
| 23 | 25 |
| 24 // PerformanceMonitor is a tool which periodically monitors performance metrics | 26 // PerformanceMonitor is a tool which periodically monitors performance metrics |
| 25 // for histogram logging and possibly taking action upon noticing serious | 27 // for histogram logging and possibly taking action upon noticing serious |
| 26 // performance degradation. | 28 // performance degradation. |
| 27 class PerformanceMonitor { | 29 class PerformanceMonitor { |
| 28 public: | 30 public: |
| 29 // Returns the current PerformanceMonitor instance if one exists; otherwise | 31 // Returns the current PerformanceMonitor instance if one exists; otherwise |
| 30 // constructs a new PerformanceMonitor. | 32 // constructs a new PerformanceMonitor. |
| 31 static PerformanceMonitor* GetInstance(); | 33 static PerformanceMonitor* GetInstance(); |
| 32 | 34 |
| 33 // Start the cycle of metrics gathering. | 35 // Start the cycle of metrics gathering. |
| 34 void StartGatherCycle(); | 36 void StartGatherCycle(); |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 typedef std::map<base::ProcessHandle, ProcessMetricsHistory> MetricsMap; | 39 typedef std::map<base::ProcessHandle, ProcessMetricsHistory> MetricsMap; |
| 38 | 40 |
| 39 friend struct DefaultSingletonTraits<PerformanceMonitor>; | 41 friend struct base::DefaultSingletonTraits<PerformanceMonitor>; |
| 40 | 42 |
| 41 PerformanceMonitor(); | 43 PerformanceMonitor(); |
| 42 virtual ~PerformanceMonitor(); | 44 virtual ~PerformanceMonitor(); |
| 43 | 45 |
| 44 // Perform any collections that are done on a timed basis. | 46 // Perform any collections that are done on a timed basis. |
| 45 void DoTimedCollections(); | 47 void DoTimedCollections(); |
| 46 | 48 |
| 47 // Mark the given process as alive in the current update iteration. | 49 // Mark the given process as alive in the current update iteration. |
| 48 // This means adding an entry to the map of watched processes if it's not | 50 // This means adding an entry to the map of watched processes if it's not |
| 49 // already present. | 51 // already present. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 | 68 |
| 67 // The timer to signal PerformanceMonitor to perform its timed collections. | 69 // The timer to signal PerformanceMonitor to perform its timed collections. |
| 68 base::OneShotTimer<PerformanceMonitor> repeating_timer_; | 70 base::OneShotTimer<PerformanceMonitor> repeating_timer_; |
| 69 | 71 |
| 70 DISALLOW_COPY_AND_ASSIGN(PerformanceMonitor); | 72 DISALLOW_COPY_AND_ASSIGN(PerformanceMonitor); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 } // namespace performance_monitor | 75 } // namespace performance_monitor |
| 74 | 76 |
| 75 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ | 77 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_ |
| OLD | NEW |