Remove aura enum from DesktopMediaID to fix desktop mirroring audio (CrOS).
[chromium-blink-merge.git] / chrome / browser / performance_monitor / process_metrics_history.h
blob21f920918de77882e835acf6d0483e11aaf4c24e
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/background_tracing_manager.h"
11 #include "content/public/browser/child_process_data.h"
12 #include "content/public/common/process_type.h"
14 namespace base {
15 class ProcessMetrics;
18 namespace performance_monitor {
19 enum ProcessSubtypes {
20 kProcessSubtypeUnknown,
21 kProcessSubtypePPAPIFlash,
22 kProcessSubtypeExtensionPersistent,
23 kProcessSubtypeExtensionEvent
26 struct ProcessMetricsMetadata {
27 base::ProcessHandle handle;
28 int process_type;
29 ProcessSubtypes process_subtype;
31 ProcessMetricsMetadata()
32 : handle(base::kNullProcessHandle),
33 process_type(content::PROCESS_TYPE_UNKNOWN),
34 process_subtype(kProcessSubtypeUnknown) {}
37 class ProcessMetricsHistory {
38 public:
39 ProcessMetricsHistory();
40 ~ProcessMetricsHistory();
42 // Configure this to monitor a specific process.
43 void Initialize(const ProcessMetricsMetadata& process_data,
44 int initial_update_sequence);
46 // Gather metrics for the process and accumulate with past data.
47 void SampleMetrics();
49 // Triggers any UMA histograms or background traces if cpu_usage is excessive.
50 void RunPerformanceTriggers();
52 // Used to mark when this object was last updated, so we can cull
53 // dead ones.
54 void set_last_update_sequence(int new_update_sequence) {
55 last_update_sequence_ = new_update_sequence;
58 int last_update_sequence() const { return last_update_sequence_; }
60 private:
61 // May not be fully populated. e.g. no |id| and no |name| for browser and
62 // renderer processes.
63 ProcessMetricsMetadata process_data_;
64 linked_ptr<base::ProcessMetrics> process_metrics_;
65 int last_update_sequence_;
67 double cpu_usage_;
69 content::BackgroundTracingManager::TriggerHandle trace_trigger_handle_;
71 DISALLOW_ASSIGN(ProcessMetricsHistory);
74 } // namespace performance_monitor
76 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_