This source file includes following definitions.
- IsFeatureAllowed
- callback_
- CheckGPUFeatureAvailability
- OnGpuInfoUpdate
#include "chrome/browser/gpu/gpu_feature_checker.h"
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
namespace {
bool IsFeatureAllowed(content::GpuDataManager* manager,
gpu::GpuFeatureType feature) {
return (manager->GpuAccessAllowed(NULL) &&
!manager->IsFeatureBlacklisted(feature));
}
}
GPUFeatureChecker::GPUFeatureChecker(gpu::GpuFeatureType feature,
FeatureAvailableCallback callback)
: feature_(feature),
callback_(callback) {
}
GPUFeatureChecker::~GPUFeatureChecker() {
}
void GPUFeatureChecker::CheckGPUFeatureAvailability() {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
bool finalized = true;
#if defined(OS_LINUX)
finalized = false;
#endif
content::GpuDataManager* manager = content::GpuDataManager::GetInstance();
if (manager->IsCompleteGpuInfoAvailable())
finalized = true;
bool feature_allowed = IsFeatureAllowed(manager, feature_);
if (!feature_allowed)
finalized = true;
if (finalized) {
callback_.Run(feature_allowed);
} else {
AddRef();
manager->AddObserver(this);
manager->RequestCompleteGpuInfoIfNeeded();
}
}
void GPUFeatureChecker::OnGpuInfoUpdate() {
content::GpuDataManager* manager = content::GpuDataManager::GetInstance();
manager->RemoveObserver(this);
bool feature_allowed = IsFeatureAllowed(manager, feature_);
callback_.Run(feature_allowed);
Release();
}