| OLD | NEW |
| 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.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 6 | 6 |
| 7 #include "content/browser/gpu/gpu_data_manager_impl_private.h" | 7 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
| 8 #include "gpu/ipc/common/memory_stats.h" | 8 #include "gpu/ipc/common/memory_stats.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 GpuDataManager* GpuDataManager::GetInstance() { | 13 GpuDataManager* GpuDataManager::GetInstance() { |
| 14 return GpuDataManagerImpl::GetInstance(); | 14 return GpuDataManagerImpl::GetInstance(); |
| 15 } | 15 } |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { | 18 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { |
| 19 return base::Singleton<GpuDataManagerImpl>::get(); | 19 return base::Singleton<GpuDataManagerImpl>::get(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void GpuDataManagerImpl::InitializeForTesting( | 22 void GpuDataManagerImpl::InitializeForTesting( |
| 23 const std::string& gpu_blacklist_json, const gpu::GPUInfo& gpu_info) { | 23 const std::string& gpu_blacklist_json, const gpu::GPUInfo& gpu_info) { |
| 24 base::AutoLock auto_lock(lock_); | 24 base::AutoLock auto_lock(lock_); |
| 25 // Relax the cross-thread access restriction to non-thread-safe RefCount. | |
| 26 // See the comment in Initialize(). | |
| 27 base::ScopedAllowCrossThreadRefCountAccess | |
| 28 allow_cross_thread_ref_count_access; | |
| 29 private_->InitializeForTesting(gpu_blacklist_json, gpu_info); | 25 private_->InitializeForTesting(gpu_blacklist_json, gpu_info); |
| 30 } | 26 } |
| 31 | 27 |
| 32 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { | 28 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { |
| 33 base::AutoLock auto_lock(lock_); | 29 base::AutoLock auto_lock(lock_); |
| 34 return private_->IsFeatureBlacklisted(feature); | 30 return private_->IsFeatureBlacklisted(feature); |
| 35 } | 31 } |
| 36 | 32 |
| 37 bool GpuDataManagerImpl::IsFeatureEnabled(int feature) const { | 33 bool GpuDataManagerImpl::IsFeatureEnabled(int feature) const { |
| 38 base::AutoLock auto_lock(lock_); | 34 base::AutoLock auto_lock(lock_); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 private_->GetDisabledExtensions(disabled_extensions); | 139 private_->GetDisabledExtensions(disabled_extensions); |
| 144 } | 140 } |
| 145 | 141 |
| 146 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { | 142 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 147 base::AutoLock auto_lock(lock_); | 143 base::AutoLock auto_lock(lock_); |
| 148 private_->SetGpuInfo(gpu_info); | 144 private_->SetGpuInfo(gpu_info); |
| 149 } | 145 } |
| 150 | 146 |
| 151 void GpuDataManagerImpl::Initialize() { | 147 void GpuDataManagerImpl::Initialize() { |
| 152 base::AutoLock auto_lock(lock_); | 148 base::AutoLock auto_lock(lock_); |
| 153 // Relax the cross-thread access restriction to non-thread-safe RefCount. | |
| 154 // GpuDataManagerImplPrivate has GpuControlLists, which touches | |
| 155 // non-thread-safe GpuControlListEntry RefCount in the lock. | |
| 156 base::ScopedAllowCrossThreadRefCountAccess | |
| 157 allow_cross_thread_ref_count_access; | |
| 158 private_->Initialize(); | 149 private_->Initialize(); |
| 159 } | 150 } |
| 160 | 151 |
| 161 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 152 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 162 base::AutoLock auto_lock(lock_); | 153 base::AutoLock auto_lock(lock_); |
| 163 // Relax the cross-thread access restriction to non-thread-safe RefCount. | |
| 164 // See the comment in Initialize(). | |
| 165 base::ScopedAllowCrossThreadRefCountAccess | |
| 166 allow_cross_thread_ref_count_access; | |
| 167 private_->UpdateGpuInfo(gpu_info); | 154 private_->UpdateGpuInfo(gpu_info); |
| 168 } | 155 } |
| 169 | 156 |
| 170 void GpuDataManagerImpl::UpdateGpuFeatureInfo( | 157 void GpuDataManagerImpl::UpdateGpuFeatureInfo( |
| 171 const gpu::GpuFeatureInfo& gpu_feature_info) { | 158 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 172 base::AutoLock auto_lock(lock_); | 159 base::AutoLock auto_lock(lock_); |
| 173 private_->UpdateGpuFeatureInfo(gpu_feature_info); | 160 private_->UpdateGpuFeatureInfo(gpu_feature_info); |
| 174 } | 161 } |
| 175 | 162 |
| 176 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( | 163 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 249 } |
| 263 | 250 |
| 264 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { | 251 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { |
| 265 base::AutoLock auto_lock(lock_); | 252 base::AutoLock auto_lock(lock_); |
| 266 return private_->GetBlacklistedFeatureCount(); | 253 return private_->GetBlacklistedFeatureCount(); |
| 267 } | 254 } |
| 268 | 255 |
| 269 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, | 256 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, |
| 270 uint32_t device_id) { | 257 uint32_t device_id) { |
| 271 base::AutoLock auto_lock(lock_); | 258 base::AutoLock auto_lock(lock_); |
| 272 // Relax the cross-thread access restriction to non-thread-safe RefCount. | |
| 273 // See the comment in Initialize(). | |
| 274 base::ScopedAllowCrossThreadRefCountAccess | |
| 275 allow_cross_thread_ref_count_access; | |
| 276 return private_->UpdateActiveGpu(vendor_id, device_id); | 259 return private_->UpdateActiveGpu(vendor_id, device_id); |
| 277 } | 260 } |
| 278 | 261 |
| 279 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, | 262 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, |
| 280 int render_process_id, | 263 int render_process_id, |
| 281 int render_frame_id, | 264 int render_frame_id, |
| 282 ThreeDAPIType requester) { | 265 ThreeDAPIType requester) { |
| 283 base::AutoLock auto_lock(lock_); | 266 base::AutoLock auto_lock(lock_); |
| 284 private_->Notify3DAPIBlocked( | 267 private_->Notify3DAPIBlocked( |
| 285 top_origin_url, render_process_id, render_frame_id, requester); | 268 top_origin_url, render_process_id, render_frame_id, requester); |
| 286 } | 269 } |
| 287 | 270 |
| 288 void GpuDataManagerImpl::OnGpuProcessInitFailure() { | 271 void GpuDataManagerImpl::OnGpuProcessInitFailure() { |
| 289 base::AutoLock auto_lock(lock_); | 272 base::AutoLock auto_lock(lock_); |
| 290 private_->OnGpuProcessInitFailure(); | 273 private_->OnGpuProcessInitFailure(); |
| 291 } | 274 } |
| 292 | 275 |
| 293 GpuDataManagerImpl::GpuDataManagerImpl() | 276 GpuDataManagerImpl::GpuDataManagerImpl() |
| 294 : private_(GpuDataManagerImplPrivate::Create(this)) { | 277 : private_(GpuDataManagerImplPrivate::Create(this)) { |
| 295 } | 278 } |
| 296 | 279 |
| 297 GpuDataManagerImpl::~GpuDataManagerImpl() { | 280 GpuDataManagerImpl::~GpuDataManagerImpl() { |
| 298 } | 281 } |
| 299 | 282 |
| 300 } // namespace content | 283 } // namespace content |
| OLD | NEW |