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

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

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, 4 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 #include "chrome/browser/performance_monitor/process_metrics_history.h" 5 #include "chrome/browser/performance_monitor/process_metrics_history.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 18 matching lines...) Expand all
29 } // namespace 29 } // namespace
30 30
31 // If a process is consistently above this CPU utilization percentage over time, 31 // If a process is consistently above this CPU utilization percentage over time,
32 // we consider it as high and may take action. 32 // we consider it as high and may take action.
33 const float kHighCPUUtilizationThreshold = 90.0f; 33 const float kHighCPUUtilizationThreshold = 90.0f;
34 34
35 ProcessMetricsHistory::ProcessMetricsHistory() 35 ProcessMetricsHistory::ProcessMetricsHistory()
36 : last_update_sequence_(0), cpu_usage_(0.0), trace_trigger_handle_(-1) { 36 : last_update_sequence_(0), cpu_usage_(0.0), trace_trigger_handle_(-1) {
37 } 37 }
38 38
39 ProcessMetricsHistory::ProcessMetricsHistory(
40 const ProcessMetricsHistory& other) = default;
41
42 ProcessMetricsHistory::~ProcessMetricsHistory() { 39 ProcessMetricsHistory::~ProcessMetricsHistory() {
43 } 40 }
44 41
45 void ProcessMetricsHistory::Initialize( 42 void ProcessMetricsHistory::Initialize(
46 const ProcessMetricsMetadata& process_data, 43 const ProcessMetricsMetadata& process_data,
47 int initial_update_sequence) { 44 int initial_update_sequence) {
48 DCHECK_EQ(base::kNullProcessHandle, process_data_.handle); 45 DCHECK_EQ(base::kNullProcessHandle, process_data_.handle);
49 process_data_ = process_data; 46 process_data_ = process_data;
50 last_update_sequence_ = initial_update_sequence; 47 last_update_sequence_ = initial_update_sequence;
51 48
52 #if defined(OS_MACOSX) 49 #if defined(OS_MACOSX)
53 process_metrics_.reset(base::ProcessMetrics::CreateProcessMetrics( 50 process_metrics_ = base::ProcessMetrics::CreateProcessMetrics(
54 process_data_.handle, 51 process_data_.handle,
55 content::BrowserChildProcessHost::GetPortProvider())); 52 content::BrowserChildProcessHost::GetPortProvider());
56 #else 53 #else
57 process_metrics_.reset( 54 process_metrics_ =
58 base::ProcessMetrics::CreateProcessMetrics(process_data_.handle)); 55 base::ProcessMetrics::CreateProcessMetrics(process_data_.handle);
59 #endif 56 #endif
60 57
61 const char* trigger_name = NULL; 58 const char* trigger_name = NULL;
62 switch (process_data_.process_type) { 59 switch (process_data_.process_type) {
63 case content::PROCESS_TYPE_BROWSER: 60 case content::PROCESS_TYPE_BROWSER:
64 trigger_name = kBrowserProcessTrigger; 61 trigger_name = kBrowserProcessTrigger;
65 break; 62 break;
66 case content::PROCESS_TYPE_GPU: 63 case content::PROCESS_TYPE_GPU:
67 trigger_name = kGPUProcessTrigger; 64 trigger_name = kGPUProcessTrigger;
68 break; 65 break;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 165
169 if (cpu_usage_ > kHighCPUUtilizationThreshold && 166 if (cpu_usage_ > kHighCPUUtilizationThreshold &&
170 trace_trigger_handle_ != -1) { 167 trace_trigger_handle_ != -1) {
171 content::BackgroundTracingManager::GetInstance()->TriggerNamedEvent( 168 content::BackgroundTracingManager::GetInstance()->TriggerNamedEvent(
172 trace_trigger_handle_, 169 trace_trigger_handle_,
173 content::BackgroundTracingManager::StartedFinalizingCallback()); 170 content::BackgroundTracingManager::StartedFinalizingCallback());
174 } 171 }
175 } 172 }
176 173
177 } // namespace performance_monitor 174 } // namespace performance_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698