| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 private_->GetDisabledExtensions(disabled_extensions); | 149 private_->GetDisabledExtensions(disabled_extensions); |
| 146 } | 150 } |
| 147 | 151 |
| 148 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { | 152 void GpuDataManagerImpl::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 149 base::AutoLock auto_lock(lock_); | 153 base::AutoLock auto_lock(lock_); |
| 150 private_->SetGpuInfo(gpu_info); | 154 private_->SetGpuInfo(gpu_info); |
| 151 } | 155 } |
| 152 | 156 |
| 153 void GpuDataManagerImpl::Initialize() { | 157 void GpuDataManagerImpl::Initialize() { |
| 154 base::AutoLock auto_lock(lock_); | 158 base::AutoLock auto_lock(lock_); |
| 159 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 160 // GpuDataManagerImplPrivate has GpuControlLists, which touches |
| 161 // non-thread-safe GpuControlListEntry RefCount in the lock. |
| 162 base::ScopedAllowCrossThreadRefCountAccess |
| 163 allow_cross_thread_ref_count_access; |
| 155 private_->Initialize(); | 164 private_->Initialize(); |
| 156 } | 165 } |
| 157 | 166 |
| 158 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 167 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 159 base::AutoLock auto_lock(lock_); | 168 base::AutoLock auto_lock(lock_); |
| 169 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 170 // See the comment in Initialize(). |
| 171 base::ScopedAllowCrossThreadRefCountAccess |
| 172 allow_cross_thread_ref_count_access; |
| 160 private_->UpdateGpuInfo(gpu_info); | 173 private_->UpdateGpuInfo(gpu_info); |
| 161 } | 174 } |
| 162 | 175 |
| 163 void GpuDataManagerImpl::UpdateGpuFeatureInfo( | 176 void GpuDataManagerImpl::UpdateGpuFeatureInfo( |
| 164 const gpu::GpuFeatureInfo& gpu_feature_info) { | 177 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 165 base::AutoLock auto_lock(lock_); | 178 base::AutoLock auto_lock(lock_); |
| 166 private_->UpdateGpuFeatureInfo(gpu_feature_info); | 179 private_->UpdateGpuFeatureInfo(gpu_feature_info); |
| 167 } | 180 } |
| 168 | 181 |
| 169 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( | 182 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 268 } |
| 256 | 269 |
| 257 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { | 270 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { |
| 258 base::AutoLock auto_lock(lock_); | 271 base::AutoLock auto_lock(lock_); |
| 259 return private_->GetBlacklistedFeatureCount(); | 272 return private_->GetBlacklistedFeatureCount(); |
| 260 } | 273 } |
| 261 | 274 |
| 262 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, | 275 bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id, |
| 263 uint32_t device_id) { | 276 uint32_t device_id) { |
| 264 base::AutoLock auto_lock(lock_); | 277 base::AutoLock auto_lock(lock_); |
| 278 // Relax the cross-thread access restriction to non-thread-safe RefCount. |
| 279 // See the comment in Initialize(). |
| 280 base::ScopedAllowCrossThreadRefCountAccess |
| 281 allow_cross_thread_ref_count_access; |
| 265 return private_->UpdateActiveGpu(vendor_id, device_id); | 282 return private_->UpdateActiveGpu(vendor_id, device_id); |
| 266 } | 283 } |
| 267 | 284 |
| 268 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, | 285 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& top_origin_url, |
| 269 int render_process_id, | 286 int render_process_id, |
| 270 int render_frame_id, | 287 int render_frame_id, |
| 271 ThreeDAPIType requester) { | 288 ThreeDAPIType requester) { |
| 272 base::AutoLock auto_lock(lock_); | 289 base::AutoLock auto_lock(lock_); |
| 273 private_->Notify3DAPIBlocked( | 290 private_->Notify3DAPIBlocked( |
| 274 top_origin_url, render_process_id, render_frame_id, requester); | 291 top_origin_url, render_process_id, render_frame_id, requester); |
| 275 } | 292 } |
| 276 | 293 |
| 277 void GpuDataManagerImpl::OnGpuProcessInitFailure() { | 294 void GpuDataManagerImpl::OnGpuProcessInitFailure() { |
| 278 base::AutoLock auto_lock(lock_); | 295 base::AutoLock auto_lock(lock_); |
| 279 private_->OnGpuProcessInitFailure(); | 296 private_->OnGpuProcessInitFailure(); |
| 280 } | 297 } |
| 281 | 298 |
| 282 GpuDataManagerImpl::GpuDataManagerImpl() | 299 GpuDataManagerImpl::GpuDataManagerImpl() |
| 283 : private_(GpuDataManagerImplPrivate::Create(this)) { | 300 : private_(GpuDataManagerImplPrivate::Create(this)) { |
| 284 } | 301 } |
| 285 | 302 |
| 286 GpuDataManagerImpl::~GpuDataManagerImpl() { | 303 GpuDataManagerImpl::~GpuDataManagerImpl() { |
| 287 } | 304 } |
| 288 | 305 |
| 289 } // namespace content | 306 } // namespace content |
| OLD | NEW |