Chromium Code Reviews| Index: content/browser/gpu/gpu_data_manager.cc |
| =================================================================== |
| --- content/browser/gpu/gpu_data_manager.cc (revision 107010) |
| +++ content/browser/gpu/gpu_data_manager.cc (working copy) |
| @@ -8,6 +8,8 @@ |
| #include <CoreGraphics/CGDisplayConfiguration.h> |
| #endif |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| #include "base/metrics/histogram.h" |
| #include "base/stringprintf.h" |
| @@ -187,7 +189,8 @@ |
| } |
| GpuDataManager::GpuDataManager() |
| - : complete_gpu_info_already_requested_(false) { |
| + : complete_gpu_info_already_requested_(false), |
| + observer_list_(new GpuDataManagerObserverList) { |
| Initialize(); |
| } |
| @@ -239,7 +242,7 @@ |
| return; |
| } |
| - RunGpuInfoUpdateCallbacks(); |
| + NotifyGpuInfoUpdate(); |
| { |
| base::AutoLock auto_lock(gpu_info_lock_); |
| @@ -410,20 +413,12 @@ |
| return (gpu_feature_flags_.flags() & mask) == 0; |
| } |
| -void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - gpu_info_update_callbacks_.insert(callback); |
| +void GpuDataManager::AddObserver(Observer* observer) { |
| + observer_list_->AddObserver(observer); |
| } |
| -bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - std::set<Callback0::Type*>::iterator i = |
| - gpu_info_update_callbacks_.find(callback); |
| - if (i != gpu_info_update_callbacks_.end()) { |
| - gpu_info_update_callbacks_.erase(i); |
| - return true; |
| - } |
| - return false; |
| +void GpuDataManager::RemoveObserver(Observer* observer) { |
| + observer_list_->RemoveObserver(observer); |
| } |
| void GpuDataManager::AppendRendererCommandLine( |
| @@ -570,23 +565,16 @@ |
| return info; |
| } |
| -void GpuDataManager::RunGpuInfoUpdateCallbacks() { |
| - if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| - NewRunnableMethod(this, &GpuDataManager::RunGpuInfoUpdateCallbacks)); |
| - return; |
| - } |
| - |
| - std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin(); |
| - for (; i != gpu_info_update_callbacks_.end(); ++i) { |
| - (*i)->Run(); |
| - } |
| +void GpuDataManager::NotifyGpuInfoUpdate() { |
| + observer_list_->Notify(&GpuDataManager::Observer::OnGpuInfoUpdate); |
| } |
| void GpuDataManager::UpdateGpuFeatureFlags() { |
| if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| - NewRunnableMethod(this, &GpuDataManager::UpdateGpuFeatureFlags)); |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(&GpuDataManager::UpdateGpuFeatureFlags, |
| + base::Unretained(this))); |
|
James Hawkins
2011/10/25 23:36:52
Is base::Unretained() really needed here? The con
csilv
2011/10/26 00:02:47
So, in the original implementation NewRunnableMeth
James Hawkins
2011/10/26 00:21:29
Gotcha.
|
| return; |
| } |
| @@ -605,7 +593,7 @@ |
| } |
| // Notify clients that GpuInfo state has changed |
| - RunGpuInfoUpdateCallbacks(); |
| + NotifyGpuInfoUpdate(); |
| uint32 flags = gpu_feature_flags_.flags(); |
| uint32 max_entry_id = gpu_blacklist->max_entry_id(); |