OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/power/process_power_collector.h" | 5 #include "chrome/browser/power/process_power_collector.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 power::OriginPowerMapFactory::GetForBrowserContext(profile); | 175 power::OriginPowerMapFactory::GetForBrowserContext(profile); |
176 if (origin_power_map) | 176 if (origin_power_map) |
177 origin_power_map->OnAllOriginsUpdated(); | 177 origin_power_map->OnAllOriginsUpdated(); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 void ProcessPowerCollector::UpdateProcessInMap( | 181 void ProcessPowerCollector::UpdateProcessInMap( |
182 const content::RenderProcessHost* rph, | 182 const content::RenderProcessHost* rph, |
183 const GURL& origin) { | 183 const GURL& origin) { |
184 base::ProcessHandle handle = rph->GetHandle(); | 184 base::ProcessHandle handle = rph->GetHandle(); |
185 if (!ContainsKey(metrics_map_, handle)) { | 185 if (!base::ContainsKey(metrics_map_, handle)) { |
186 metrics_map_[handle] = base::MakeUnique<PerProcessData>( | 186 metrics_map_[handle] = base::MakeUnique<PerProcessData>( |
187 #if defined(OS_MACOSX) | 187 #if defined(OS_MACOSX) |
188 base::ProcessMetrics::CreateProcessMetrics(handle, nullptr), | 188 base::ProcessMetrics::CreateProcessMetrics(handle, nullptr), |
189 #else | 189 #else |
190 base::ProcessMetrics::CreateProcessMetrics(handle), | 190 base::ProcessMetrics::CreateProcessMetrics(handle), |
191 #endif | 191 #endif |
192 origin, Profile::FromBrowserContext(rph->GetBrowserContext())); | 192 origin, Profile::FromBrowserContext(rph->GetBrowserContext())); |
193 } | 193 } |
194 | 194 |
195 PerProcessData* process_data = metrics_map_[handle].get(); | 195 PerProcessData* process_data = metrics_map_[handle].get(); |
196 process_data->set_last_cpu_percent(std::max(0.0, | 196 process_data->set_last_cpu_percent(std::max(0.0, |
197 cpu_usage_callback_.is_null() ? process_data->metrics()->GetCPUUsage() | 197 cpu_usage_callback_.is_null() ? process_data->metrics()->GetCPUUsage() |
198 : cpu_usage_callback_.Run(handle))); | 198 : cpu_usage_callback_.Run(handle))); |
199 process_data->set_seen_this_cycle(true); | 199 process_data->set_seen_this_cycle(true); |
200 } | 200 } |
OLD | NEW |