Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/performance_monitor/process_metrics_history.h

Issue 2181493002: Return unique_ptrs from base::ProcessMetrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove os_resource_win.* Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_PROCESS_METRICS_HISTORY_H_ 5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_ 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/linked_ptr.h"
10 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
11 #include "content/public/browser/background_tracing_manager.h" 12 #include "content/public/browser/background_tracing_manager.h"
12 #include "content/public/browser/child_process_data.h" 13 #include "content/public/browser/child_process_data.h"
13 #include "content/public/common/process_type.h" 14 #include "content/public/common/process_type.h"
14 15
15 namespace base { 16 namespace base {
16 class ProcessMetrics; 17 class ProcessMetrics;
17 } 18 }
18 19
19 namespace performance_monitor { 20 namespace performance_monitor {
(...skipping 11 matching lines...) Expand all
31 32
32 ProcessMetricsMetadata() 33 ProcessMetricsMetadata()
33 : handle(base::kNullProcessHandle), 34 : handle(base::kNullProcessHandle),
34 process_type(content::PROCESS_TYPE_UNKNOWN), 35 process_type(content::PROCESS_TYPE_UNKNOWN),
35 process_subtype(kProcessSubtypeUnknown) {} 36 process_subtype(kProcessSubtypeUnknown) {}
36 }; 37 };
37 38
38 class ProcessMetricsHistory { 39 class ProcessMetricsHistory {
39 public: 40 public:
40 ProcessMetricsHistory(); 41 ProcessMetricsHistory();
41 ProcessMetricsHistory(const ProcessMetricsHistory& other); 42 ProcessMetricsHistory(const ProcessMetricsHistory& other) = delete;
42 ~ProcessMetricsHistory(); 43 ~ProcessMetricsHistory();
43 44
44 // Configure this to monitor a specific process. 45 // Configure this to monitor a specific process.
45 void Initialize(const ProcessMetricsMetadata& process_data, 46 void Initialize(const ProcessMetricsMetadata& process_data,
46 int initial_update_sequence); 47 int initial_update_sequence);
47 48
48 // Gather metrics for the process and accumulate with past data. 49 // Gather metrics for the process and accumulate with past data.
49 void SampleMetrics(); 50 void SampleMetrics();
50 51
51 // Triggers any UMA histograms or background traces if cpu_usage is excessive. 52 // Triggers any UMA histograms or background traces if cpu_usage is excessive.
52 void RunPerformanceTriggers(); 53 void RunPerformanceTriggers();
53 54
54 // Used to mark when this object was last updated, so we can cull 55 // Used to mark when this object was last updated, so we can cull
55 // dead ones. 56 // dead ones.
56 void set_last_update_sequence(int new_update_sequence) { 57 void set_last_update_sequence(int new_update_sequence) {
57 last_update_sequence_ = new_update_sequence; 58 last_update_sequence_ = new_update_sequence;
58 } 59 }
59 60
60 int last_update_sequence() const { return last_update_sequence_; } 61 int last_update_sequence() const { return last_update_sequence_; }
61 62
62 private: 63 private:
63 // May not be fully populated. e.g. no |id| and no |name| for browser and 64 // May not be fully populated. e.g. no |id| and no |name| for browser and
64 // renderer processes. 65 // renderer processes.
65 ProcessMetricsMetadata process_data_; 66 ProcessMetricsMetadata process_data_;
66 linked_ptr<base::ProcessMetrics> process_metrics_; 67 std::unique_ptr<base::ProcessMetrics> process_metrics_;
67 int last_update_sequence_; 68 int last_update_sequence_;
68 69
69 double cpu_usage_; 70 double cpu_usage_;
70 71
71 content::BackgroundTracingManager::TriggerHandle trace_trigger_handle_; 72 content::BackgroundTracingManager::TriggerHandle trace_trigger_handle_;
72 73
73 DISALLOW_ASSIGN(ProcessMetricsHistory); 74 DISALLOW_ASSIGN(ProcessMetricsHistory);
74 }; 75 };
75 76
76 } // namespace performance_monitor 77 } // namespace performance_monitor
77 78
78 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_ 79 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698