| 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; |
| 25 private_->InitializeForTesting(gpu_blacklist_json, gpu_info); | 29 private_->InitializeForTesting(gpu_blacklist_json, gpu_info); |
| 26 } | 30 } |
| 27 | 31 |
| 28 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { | 32 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { |
| 29 base::AutoLock auto_lock(lock_); | 33 base::AutoLock auto_lock(lock_); |
| 30 return private_->IsFeatureBlacklisted(feature); | 34 return private_->IsFeatureBlacklisted(feature); |
| 31 } | 35 } |
| 32 | 36 |
| 33 bool GpuDataManagerImpl::IsFeatureEnabled(int feature) const { | 37 bool GpuDataManagerImpl::IsFeatureEnabled(int feature) const { |
| 34 base::AutoLock auto_lock(lock_); | 38 base::AutoLock auto_lock(lock_); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 private_->GetDisabledExtensions(disabled_extensions); | 138 private_->GetDisabledExtensions(disabled_extensions); |
| 135 } | 139 } |
| 136 | 140 |
| 137 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { | 141 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 138 base::AutoLock auto_lock(lock_); | 142 base::AutoLock auto_lock(lock_); |
| 139 private_->SetGpuInfo(gpu_info); | 143 private_->SetGpuInfo(gpu_info); |
| 140 } | 144 } |
| 141 | 145 |
| 142 void GpuDataManagerImpl::Initialize() { | 146 void GpuDataManagerImpl::Initialize() { |
| 143 base::AutoLock auto_lock(lock_); | 147 base::AutoLock auto_lock(lock_); |
| 148 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 149 // GpuDataManagerImplPrivate has GpuControlLists, which touches |
| 150 // non-thread-safe GpuControlListEntry RefCount in the lock. |
| 151 base::ScopedAllowCrossThreadRefCountAccess |
| 152 allow_cross_thread_ref_count_access; |
| 144 private_->Initialize(); | 153 private_->Initialize(); |
| 145 } | 154 } |
| 146 | 155 |
| 147 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 156 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 148 base::AutoLock auto_lock(lock_); | 157 base::AutoLock auto_lock(lock_); |
| 158 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 159 // See the comment in Initialize(). |
| 160 base::ScopedAllowCrossThreadRefCountAccess |
| 161 allow_cross_thread_ref_count_access; |
| 149 private_->UpdateGpuInfo(gpu_info); | 162 private_->UpdateGpuInfo(gpu_info); |
| 150 } | 163 } |
| 151 | 164 |
| 152 void GpuDataManagerImpl::UpdateGpuFeatureInfo( | 165 void GpuDataManagerImpl::UpdateGpuFeatureInfo( |
| 153 const gpu::GpuFeatureInfo& gpu_feature_info) { | 166 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 154 base::AutoLock auto_lock(lock_); | 167 base::AutoLock auto_lock(lock_); |
| 155 private_->UpdateGpuFeatureInfo(gpu_feature_info); | 168 private_->UpdateGpuFeatureInfo(gpu_feature_info); |
| 156 } | 169 } |
| 157 | 170 |
| 158 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( | 171 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 257 } |
| 245 | 258 |
| 246 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { | 259 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { |
| 247 base::AutoLock auto_lock(lock_); | 260 base::AutoLock auto_lock(lock_); |
| 248 return private_->GetBlacklistedFeatureCount(); | 261 return private_->GetBlacklistedFeatureCount(); |
| 249 } | 262 } |
| 250 | 263 |
| 251 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, | 264 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, |
| 252 uint32_t device_id) { | 265 uint32_t device_id) { |
| 253 base::AutoLock auto_lock(lock_); | 266 base::AutoLock auto_lock(lock_); |
| 267 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 268 // See the comment in Initialize(). |
| 269 base::ScopedAllowCrossThreadRefCountAccess |
| 270 allow_cross_thread_ref_count_access; |
| 254 return private_->UpdateActiveGpu(vendor_id, device_id); | 271 return private_->UpdateActiveGpu(vendor_id, device_id); |
| 255 } | 272 } |
| 256 | 273 |
| 257 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, | 274 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, |
| 258 int render_process_id, | 275 int render_process_id, |
| 259 int render_frame_id, | 276 int render_frame_id, |
| 260 ThreeDAPIType requester) { | 277 ThreeDAPIType requester) { |
| 261 base::AutoLock auto_lock(lock_); | 278 base::AutoLock auto_lock(lock_); |
| 262 private_->Notify3DAPIBlocked( | 279 private_->Notify3DAPIBlocked( |
| 263 top_origin_url, render_process_id, render_frame_id, requester); | 280 top_origin_url, render_process_id, render_frame_id, requester); |
| 264 } | 281 } |
| 265 | 282 |
| 266 void GpuDataManagerImpl::OnGpuProcessInitFailure() { | 283 void GpuDataManagerImpl::OnGpuProcessInitFailure() { |
| 267 base::AutoLock auto_lock(lock_); | 284 base::AutoLock auto_lock(lock_); |
| 268 private_->OnGpuProcessInitFailure(); | 285 private_->OnGpuProcessInitFailure(); |
| 269 } | 286 } |
| 270 | 287 |
| 271 GpuDataManagerImpl::GpuDataManagerImpl() | 288 GpuDataManagerImpl::GpuDataManagerImpl() |
| 272 : private_(GpuDataManagerImplPrivate::Create(this)) { | 289 : private_(GpuDataManagerImplPrivate::Create(this)) { |
| 273 } | 290 } |
| 274 | 291 |
| 275 GpuDataManagerImpl::~GpuDataManagerImpl() { | 292 GpuDataManagerImpl::~GpuDataManagerImpl() { |
| 276 } | 293 } |
| 277 | 294 |
| 278 } // namespace content | 295 } // namespace content |
| OLD | NEW |