Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: content/browser/gpu/gpu_data_manager.h

Issue 8390018: Change GpuDataManager to use Observer notifications rather than callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Review fixes Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/tracing_ui.cc ('k') | content/browser/gpu/gpu_data_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_data_manager.h
===================================================================
--- content/browser/gpu/gpu_data_manager.h (revision 107010)
+++ content/browser/gpu/gpu_data_manager.h (working copy)
@@ -9,9 +9,9 @@
#include <set>
#include <string>
-#include "base/callback_old.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
+#include "base/observer_list_threadsafe.h"
#include "base/synchronization/lock.h"
#include "base/task.h"
#include "base/values.h"
@@ -24,6 +24,17 @@
class CONTENT_EXPORT GpuDataManager {
public:
+ // Observers can register themselves via GpuDataManager::AddObserver, and
+ // can un-register with GpuDataManager::RemoveObserver.
+ class Observer {
+ public:
+ // Called for any observers whenever there is a GPU info update.
+ virtual void OnGpuInfoUpdate() = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
// Getter for the singleton. This will return NULL on failure.
static GpuDataManager* GetInstance();
@@ -82,12 +93,15 @@
// Can be called on any thread.
bool GpuAccessAllowed();
- // Add a callback.
- void AddGpuInfoUpdateCallback(Callback0::Type* callback);
+ // Registers |observer|. The thread on which this is called is the thread
+ // on which |observer| will be called back with notifications. |observer|
+ // must not be NULL.
+ void AddObserver(Observer* observer);
- // Remove a callback.
- // Returns true if removed, or false if it was not found.
- bool RemoveGpuInfoUpdateCallback(Callback0::Type* callback);
+ // Unregisters |observer| from receiving notifications. This must be called
+ // on the same thread on which AddObserver() was called. |observer|
+ // must not be NULL.
+ void RemoveObserver(Observer* observer);
// Inserting disable-feature switches into renderer process command-line
// in correspondance to preliminary gpu feature flags.
@@ -157,6 +171,9 @@
std::string use_gl_;
};
+ typedef ObserverListThreadSafe<GpuDataManager::Observer>
+ GpuDataManagerObserverList;
+
friend struct DefaultSingletonTraits<GpuDataManager>;
GpuDataManager();
@@ -172,8 +189,8 @@
// and compute the flags.
void UpdateGpuFeatureFlags();
- // Call all callbacks.
- void RunGpuInfoUpdateCallbacks();
+ // Notify all observers whenever there is a GPU info update.
+ void NotifyGpuInfoUpdate();
// If use-gl switch is osmesa or any, return true.
bool UseGLIsOSMesaOrAny();
@@ -199,14 +216,12 @@
scoped_ptr<GpuBlacklist> gpu_blacklist_;
- // Map of callbacks.
- std::set<Callback0::Type*> gpu_info_update_callbacks_;
+ // Observers.
+ const scoped_refptr<GpuDataManagerObserverList> observer_list_;
ListValue log_messages_;
DISALLOW_COPY_AND_ASSIGN(GpuDataManager);
};
-DISABLE_RUNNABLE_METHOD_REFCOUNT(GpuDataManager);
-
#endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_H_
« no previous file with comments | « chrome/browser/ui/webui/tracing_ui.cc ('k') | content/browser/gpu/gpu_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698