Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / performance_monitor / performance_monitor.h
blob22bdb584ac695ba5be7d8fccd9b590ba56e4a063
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_
8 #include <map>
9 #include <vector>
11 #include "base/process/process_handle.h"
12 #include "base/timer/timer.h"
13 #include "chrome/browser/performance_monitor/process_metrics_history.h"
15 template <typename Type>
16 struct DefaultSingletonTraits;
18 namespace content {
19 struct ChildProcessData;
22 namespace performance_monitor {
24 // PerformanceMonitor is a tool which periodically monitors performance metrics
25 // for histogram logging and possibly taking action upon noticing serious
26 // performance degradation.
27 class PerformanceMonitor {
28 public:
29 // Returns the current PerformanceMonitor instance if one exists; otherwise
30 // constructs a new PerformanceMonitor.
31 static PerformanceMonitor* GetInstance();
33 // Start the cycle of metrics gathering.
34 void StartGatherCycle();
36 private:
37 typedef std::map<base::ProcessHandle, ProcessMetricsHistory> MetricsMap;
39 friend struct DefaultSingletonTraits<PerformanceMonitor>;
41 PerformanceMonitor();
42 virtual ~PerformanceMonitor();
44 // Perform any collections that are done on a timed basis.
45 void DoTimedCollections();
47 // 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
49 // already present.
50 void MarkProcessAsAlive(const ProcessMetricsMetadata& process_data,
51 int current_update_sequence);
52 void MarkProcessesAsAliveOnUIThread(
53 scoped_ptr<std::vector<ProcessMetricsMetadata>> process_data_list,
54 int current_update_sequence);
56 // Updates the ProcessMetrics map with the current list of processes and
57 // gathers metrics from each entry.
58 void GatherMetricsMapOnUIThread();
59 void GatherMetricsMapOnIOThread(int current_update_sequence);
61 void UpdateMetricsOnIOThread(int current_update_sequence);
62 void RunTriggersUIThread();
64 // A map of currently running ProcessHandles to ProcessMetrics.
65 MetricsMap metrics_map_;
67 // The timer to signal PerformanceMonitor to perform its timed collections.
68 base::OneShotTimer<PerformanceMonitor> repeating_timer_;
70 DISALLOW_COPY_AND_ASSIGN(PerformanceMonitor);
73 } // namespace performance_monitor
75 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_