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

Side by Side Diff: chrome/browser/power/process_power_collector.cc

Issue 2339303002: Speculative workaround for VS 2015 code-gen bug (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 void ProcessPowerCollector::StartTimer() { 89 void ProcessPowerCollector::StartTimer() {
90 DCHECK(!timer_.IsRunning()); 90 DCHECK(!timer_.IsRunning());
91 timer_.Start(FROM_HERE, 91 timer_.Start(FROM_HERE,
92 base::TimeDelta::FromSeconds(kSecondsPerSample), 92 base::TimeDelta::FromSeconds(kSecondsPerSample),
93 this, 93 this,
94 &ProcessPowerCollector::HandleUpdateTimeout); 94 &ProcessPowerCollector::HandleUpdateTimeout);
95 } 95 }
96 96
97 // Work around VS 2015 code-gen bug, seen in Update 2 and Update 3.
98 // crbug.com/640588
99 #if defined(COMPILER_MSVC)
100 #pragma optimize("", off)
101 #endif
97 double ProcessPowerCollector::UpdatePowerConsumption() { 102 double ProcessPowerCollector::UpdatePowerConsumption() {
98 double total_cpu_percent = SynchronizeProcesses(); 103 double total_cpu_percent = SynchronizeProcesses();
99 104
100 // Invalidate the process for the next cycle. 105 // Invalidate the process for the next cycle.
101 for (auto& metrics : metrics_map_) 106 for (auto& metrics : metrics_map_)
102 metrics.second->set_seen_this_cycle(false); 107 metrics.second->set_seen_this_cycle(false);
103 108
104 RecordCpuUsageByOrigin(total_cpu_percent); 109 RecordCpuUsageByOrigin(total_cpu_percent);
105 return total_cpu_percent; 110 return total_cpu_percent;
106 } 111 }
107 112
108 void ProcessPowerCollector::HandleUpdateTimeout() { 113 void ProcessPowerCollector::HandleUpdateTimeout() {
109 UpdatePowerConsumption(); 114 UpdatePowerConsumption();
110 } 115 }
116 #if defined(COMPILER_MSVC)
117 #pragma optimize("", on)
118 #endif
111 119
112 double ProcessPowerCollector::SynchronizeProcesses() { 120 double ProcessPowerCollector::SynchronizeProcesses() {
113 // Update all tabs. 121 // Update all tabs.
114 for (TabContentsIterator it; !it.done(); it.Next()) { 122 for (TabContentsIterator it; !it.done(); it.Next()) {
115 content::RenderProcessHost* render_process = it->GetRenderProcessHost(); 123 content::RenderProcessHost* render_process = it->GetRenderProcessHost();
116 // Skip incognito web contents. 124 // Skip incognito web contents.
117 if (render_process->GetBrowserContext()->IsOffTheRecord()) 125 if (render_process->GetBrowserContext()->IsOffTheRecord())
118 continue; 126 continue;
119 UpdateProcessInMap(render_process, it->GetLastCommittedURL().GetOrigin()); 127 UpdateProcessInMap(render_process, it->GetLastCommittedURL().GetOrigin());
120 } 128 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 #endif 199 #endif
192 origin, Profile::FromBrowserContext(rph->GetBrowserContext())); 200 origin, Profile::FromBrowserContext(rph->GetBrowserContext()));
193 } 201 }
194 202
195 PerProcessData* process_data = metrics_map_[handle].get(); 203 PerProcessData* process_data = metrics_map_[handle].get();
196 process_data->set_last_cpu_percent(std::max(0.0, 204 process_data->set_last_cpu_percent(std::max(0.0,
197 cpu_usage_callback_.is_null() ? process_data->metrics()->GetCPUUsage() 205 cpu_usage_callback_.is_null() ? process_data->metrics()->GetCPUUsage()
198 : cpu_usage_callback_.Run(handle))); 206 : cpu_usage_callback_.Run(handle)));
199 process_data->set_seen_this_cycle(true); 207 process_data->set_seen_this_cycle(true);
200 } 208 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698