1 // Copyright 2013 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_PROCESS_METRICS_HISTORY_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
8 #include "base/memory/linked_ptr.h"
9 #include "base/process/process_handle.h"
10 #include "content/public/browser/child_process_data.h"
11 #include "content/public/common/process_type.h"
17 namespace performance_monitor
{
18 enum ProcessSubtypes
{
19 kProcessSubtypeUnknown
,
20 kProcessSubtypePPAPIFlash
,
21 kProcessSubtypeExtensionPersistent
,
22 kProcessSubtypeExtensionEvent
25 struct ProcessMetricsMetadata
{
26 base::ProcessHandle handle
;
28 ProcessSubtypes process_subtype
;
30 ProcessMetricsMetadata()
31 : handle(base::kNullProcessHandle
),
32 process_type(content::PROCESS_TYPE_UNKNOWN
),
33 process_subtype(kProcessSubtypeUnknown
) {}
36 class ProcessMetricsHistory
{
38 ProcessMetricsHistory();
39 ~ProcessMetricsHistory();
41 // Configure this to monitor a specific process.
42 void Initialize(const ProcessMetricsMetadata
& process_data
,
43 int initial_update_sequence
);
45 // Gather metrics for the process and accumulate with past data.
48 // Used to mark when this object was last updated, so we can cull
50 void set_last_update_sequence(int new_update_sequence
) {
51 last_update_sequence_
= new_update_sequence
;
54 int last_update_sequence() const { return last_update_sequence_
; }
57 void RunPerformanceTriggers();
59 // May not be fully populated. e.g. no |id| and no |name| for browser and
60 // renderer processes.
61 ProcessMetricsMetadata process_data_
;
62 linked_ptr
<base::ProcessMetrics
> process_metrics_
;
63 int last_update_sequence_
;
67 DISALLOW_ASSIGN(ProcessMetricsHistory
);
70 } // namespace performance_monitor
72 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_