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

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl_private.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/gpu/gpu_data_manager_impl_private.h" 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "build/build_config.h"
18 #include "cc/base/switches.h" 19 #include "cc/base/switches.h"
19 #include "content/browser/gpu/gpu_process_host.h" 20 #include "content/browser/gpu/gpu_process_host.h"
20 #include "content/common/gpu/gpu_messages.h" 21 #include "content/common/gpu/gpu_messages.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/gpu_data_manager_observer.h" 23 #include "content/public/browser/gpu_data_manager_observer.h"
23 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_constants.h" 25 #include "content/public/common/content_constants.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/common/web_preferences.h" 27 #include "content/public/common/web_preferences.h"
27 #include "gpu/command_buffer/service/gpu_switches.h" 28 #include "gpu/command_buffer/service/gpu_switches.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 break; 105 break;
105 } 106 }
106 return entry_index; 107 return entry_index;
107 } 108 }
108 #endif // OS_WIN 109 #endif // OS_WIN
109 110
110 // Send UMA histograms about the enabled features and GPU properties. 111 // Send UMA histograms about the enabled features and GPU properties.
111 void UpdateStats(const gpu::GPUInfo& gpu_info, 112 void UpdateStats(const gpu::GPUInfo& gpu_info,
112 const gpu::GpuBlacklist* blacklist, 113 const gpu::GpuBlacklist* blacklist,
113 const std::set<int>& blacklisted_features) { 114 const std::set<int>& blacklisted_features) {
114 uint32 max_entry_id = blacklist->max_entry_id(); 115 uint32_t max_entry_id = blacklist->max_entry_id();
115 if (max_entry_id == 0) { 116 if (max_entry_id == 0) {
116 // GPU Blacklist was not loaded. No need to go further. 117 // GPU Blacklist was not loaded. No need to go further.
117 return; 118 return;
118 } 119 }
119 120
120 const base::CommandLine& command_line = 121 const base::CommandLine& command_line =
121 *base::CommandLine::ForCurrentProcess(); 122 *base::CommandLine::ForCurrentProcess();
122 bool disabled = false; 123 bool disabled = false;
123 124
124 // Use entry 0 to capture the total number of times that data 125 // Use entry 0 to capture the total number of times that data
125 // was recorded in this histogram in order to have a convenient 126 // was recorded in this histogram in order to have a convenient
126 // denominator to compute blacklist percentages for the rest of the 127 // denominator to compute blacklist percentages for the rest of the
127 // entries. 128 // entries.
128 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 129 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
129 0, max_entry_id + 1); 130 0, max_entry_id + 1);
130 131
131 if (blacklisted_features.size() != 0) { 132 if (blacklisted_features.size() != 0) {
132 std::vector<uint32> flag_entries; 133 std::vector<uint32_t> flag_entries;
133 blacklist->GetDecisionEntries(&flag_entries, disabled); 134 blacklist->GetDecisionEntries(&flag_entries, disabled);
134 DCHECK_GT(flag_entries.size(), 0u); 135 DCHECK_GT(flag_entries.size(), 0u);
135 for (size_t i = 0; i < flag_entries.size(); ++i) { 136 for (size_t i = 0; i < flag_entries.size(); ++i) {
136 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 137 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
137 flag_entries[i], max_entry_id + 1); 138 flag_entries[i], max_entry_id + 1);
138 } 139 }
139 } 140 }
140 141
141 // This counts how many users are affected by a disabled entry - this allows 142 // This counts how many users are affected by a disabled entry - this allows
142 // us to understand the impact of an entry before enable it. 143 // us to understand the impact of an entry before enable it.
143 std::vector<uint32> flag_disabled_entries; 144 std::vector<uint32_t> flag_disabled_entries;
144 disabled = true; 145 disabled = true;
145 blacklist->GetDecisionEntries(&flag_disabled_entries, disabled); 146 blacklist->GetDecisionEntries(&flag_disabled_entries, disabled);
146 for (uint32 disabled_entry : flag_disabled_entries) { 147 for (uint32_t disabled_entry : flag_disabled_entries) {
147 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", 148 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry",
148 disabled_entry, max_entry_id + 1); 149 disabled_entry, max_entry_id + 1);
149 } 150 }
150 151
151 const gpu::GpuFeatureType kGpuFeatures[] = { 152 const gpu::GpuFeatureType kGpuFeatures[] = {
152 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, 153 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS,
153 gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING, 154 gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING,
154 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION, 155 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION,
155 gpu::GPU_FEATURE_TYPE_WEBGL}; 156 gpu::GPU_FEATURE_TYPE_WEBGL};
156 const std::string kGpuBlacklistFeatureHistogramNames[] = { 157 const std::string kGpuBlacklistFeatureHistogramNames[] = {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 uint32_t displayCount; 228 uint32_t displayCount;
228 CGGetActiveDisplayList(0, NULL, &displayCount); 229 CGGetActiveDisplayList(0, NULL, &displayCount);
229 if (displayCount != manager->GetDisplayCount()) { 230 if (displayCount != manager->GetDisplayCount()) {
230 manager->SetDisplayCount(displayCount); 231 manager->SetDisplayCount(displayCount);
231 display_changed = true; 232 display_changed = true;
232 } 233 }
233 234
234 // Gpu change. 235 // Gpu change.
235 bool gpu_changed = false; 236 bool gpu_changed = false;
236 if (flags & kCGDisplayAddFlag) { 237 if (flags & kCGDisplayAddFlag) {
237 uint32 vendor_id, device_id; 238 uint32_t vendor_id, device_id;
238 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { 239 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) {
239 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); 240 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id);
240 } 241 }
241 } 242 }
242 243
243 if (display_changed || gpu_changed) 244 if (display_changed || gpu_changed)
244 manager->HandleGpuSwitch(); 245 manager->HandleGpuSwitch();
245 } 246 }
246 #endif // OS_MACOSX 247 #endif // OS_MACOSX
247 248
248 // Block all domains' use of 3D APIs for this many milliseconds if 249 // Block all domains' use of 3D APIs for this many milliseconds if
249 // approaching a threshold where system stability might be compromised. 250 // approaching a threshold where system stability might be compromised.
250 const int64 kBlockAllDomainsMs = 10000; 251 const int64_t kBlockAllDomainsMs = 10000;
251 const int kNumResetsWithinDuration = 1; 252 const int kNumResetsWithinDuration = 1;
252 253
253 // Enums for UMA histograms. 254 // Enums for UMA histograms.
254 enum BlockStatusHistogram { 255 enum BlockStatusHistogram {
255 BLOCK_STATUS_NOT_BLOCKED, 256 BLOCK_STATUS_NOT_BLOCKED,
256 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 257 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED,
257 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 258 BLOCK_STATUS_ALL_DOMAINS_BLOCKED,
258 BLOCK_STATUS_MAX 259 BLOCK_STATUS_MAX
259 }; 260 };
260 261
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 GpuDataManagerImpl::UnlockedSession session(owner_); 868 GpuDataManagerImpl::UnlockedSession session(owner_);
868 // Notify observers in the browser process. 869 // Notify observers in the browser process.
869 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); 870 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
870 // Pass the notification to the GPU process to notify observers there. 871 // Pass the notification to the GPU process to notify observers there.
871 GpuProcessHost::SendOnIO( 872 GpuProcessHost::SendOnIO(
872 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 873 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
873 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 874 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
874 new GpuMsg_GpuSwitched); 875 new GpuMsg_GpuSwitched);
875 } 876 }
876 877
877 bool GpuDataManagerImplPrivate::UpdateActiveGpu( 878 bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id,
878 uint32 vendor_id, uint32 device_id) { 879 uint32_t device_id) {
879 if (gpu_info_.gpu.vendor_id == vendor_id && 880 if (gpu_info_.gpu.vendor_id == vendor_id &&
880 gpu_info_.gpu.device_id == device_id) { 881 gpu_info_.gpu.device_id == device_id) {
881 // The primary GPU is active. 882 // The primary GPU is active.
882 if (gpu_info_.gpu.active) 883 if (gpu_info_.gpu.active)
883 return false; 884 return false;
884 gpu_info_.gpu.active = true; 885 gpu_info_.gpu.active = true;
885 for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii) 886 for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii)
886 gpu_info_.secondary_gpus[ii].active = false; 887 gpu_info_.secondary_gpus[ii].active = false;
887 } else { 888 } else {
888 // A secondary GPU is active. 889 // A secondary GPU is active.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1060 }
1060 1061
1061 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { 1062 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() {
1062 preliminary_blacklisted_features_ = blacklisted_features_; 1063 preliminary_blacklisted_features_ = blacklisted_features_;
1063 } 1064 }
1064 1065
1065 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( 1066 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager(
1066 const gpu::GPUInfo& gpu_info) { 1067 const gpu::GPUInfo& gpu_info) {
1067 // The vendor IDs might be 0 on non-PCI devices (like Android), but 1068 // The vendor IDs might be 0 on non-PCI devices (like Android), but
1068 // the length of the vector is all we care about in most cases. 1069 // the length of the vector is all we care about in most cases.
1069 std::vector<uint32> vendor_ids; 1070 std::vector<uint32_t> vendor_ids;
1070 vendor_ids.push_back(gpu_info.gpu.vendor_id); 1071 vendor_ids.push_back(gpu_info.gpu.vendor_id);
1071 for (const auto& device : gpu_info.secondary_gpus) { 1072 for (const auto& device : gpu_info.secondary_gpus) {
1072 vendor_ids.push_back(device.vendor_id); 1073 vendor_ids.push_back(device.vendor_id);
1073 } 1074 }
1074 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); 1075 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids);
1075 1076
1076 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 1077 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
1077 if (gpu_driver_bugs_.count(gpu::FORCE_DISCRETE_GPU) == 1) 1078 if (gpu_driver_bugs_.count(gpu::FORCE_DISCRETE_GPU) == 1)
1078 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 1079 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu();
1079 else if (gpu_driver_bugs_.count(gpu::FORCE_INTEGRATED_GPU) == 1) 1080 else if (gpu_driver_bugs_.count(gpu::FORCE_INTEGRATED_GPU) == 1)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 } 1200 }
1200 } 1201 }
1201 1202
1202 UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1203 UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs",
1203 BLOCK_STATUS_NOT_BLOCKED, 1204 BLOCK_STATUS_NOT_BLOCKED,
1204 BLOCK_STATUS_MAX); 1205 BLOCK_STATUS_MAX);
1205 1206
1206 return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 1207 return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED;
1207 } 1208 }
1208 1209
1209 int64 GpuDataManagerImplPrivate::GetBlockAllDomainsDurationInMs() const { 1210 int64_t GpuDataManagerImplPrivate::GetBlockAllDomainsDurationInMs() const {
1210 return kBlockAllDomainsMs; 1211 return kBlockAllDomainsMs;
1211 } 1212 }
1212 1213
1213 void GpuDataManagerImplPrivate::Notify3DAPIBlocked(const GURL& top_origin_url, 1214 void GpuDataManagerImplPrivate::Notify3DAPIBlocked(const GURL& top_origin_url,
1214 int render_process_id, 1215 int render_process_id,
1215 int render_frame_id, 1216 int render_frame_id,
1216 ThreeDAPIType requester) { 1217 ThreeDAPIType requester) {
1217 GpuDataManagerImpl::UnlockedSession session(owner_); 1218 GpuDataManagerImpl::UnlockedSession session(owner_);
1218 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::DidBlock3DAPIs, 1219 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::DidBlock3DAPIs,
1219 top_origin_url, render_process_id, render_frame_id, 1220 top_origin_url, render_process_id, render_frame_id,
1220 requester); 1221 requester);
1221 } 1222 }
1222 1223
1223 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { 1224 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() {
1224 gpu_process_accessible_ = false; 1225 gpu_process_accessible_ = false;
1225 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 1226 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1226 #if defined(OS_WIN) 1227 #if defined(OS_WIN)
1227 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1228 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1228 #endif 1229 #endif
1229 complete_gpu_info_already_requested_ = true; 1230 complete_gpu_info_already_requested_ = true;
1230 // Some observers might be waiting. 1231 // Some observers might be waiting.
1231 NotifyGpuInfoUpdate(); 1232 NotifyGpuInfoUpdate();
1232 } 1233 }
1233 1234
1234 } // namespace content 1235 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.h ('k') | content/browser/gpu/gpu_data_manager_impl_private_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698