diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 14:37:48 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 14:37:48 +0000 |
commit | 05f0f84db4862d970c79839450be35d67ce7d052 (patch) | |
tree | 1ea1af795f6e5214870ba5ff463316b558e2e0ad /ui/gfx/gtk_native_view_id_manager.h | |
parent | 9eb95ae5a4a3fc8d2fad6bc2f84820c9c3d8fb12 (diff) | |
download | chromium_src-05f0f84db4862d970c79839450be35d67ce7d052.zip chromium_src-05f0f84db4862d970c79839450be35d67ce7d052.tar.gz chromium_src-05f0f84db4862d970c79839450be35d67ce7d052.tar.bz2 |
Revert 90395 - Remove the lock in GtkNativeViewManager.
Since removing the X11 background thread, this class is now only
used from the UI thread.
Review URL: http://codereview.chromium.org/7187026
TBR=tony@chromium.org
Review URL: http://codereview.chromium.org/7235020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gtk_native_view_id_manager.h')
-rw-r--r-- | ui/gfx/gtk_native_view_id_manager.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ui/gfx/gtk_native_view_id_manager.h b/ui/gfx/gtk_native_view_id_manager.h index aad39ad..2a651a0 100644 --- a/ui/gfx/gtk_native_view_id_manager.h +++ b/ui/gfx/gtk_native_view_id_manager.h @@ -10,7 +10,6 @@ #include "base/memory/singleton.h" #include "base/synchronization/lock.h" -#include "base/threading/non_thread_safe.h" #include "ui/gfx/native_widget_types.h" typedef unsigned long XID; @@ -29,13 +28,15 @@ struct _GtkPreserveWindow; // // Thus, we have this object. It produces random NativeViewIds from GtkWidget // pointers and observes the various signals from the widget for when an X -// window is created, destroyed etc. Thus it provides a mapping from -// NativeViewIds to the current XID for that widget. -class GtkNativeViewManager : public base::NonThreadSafe { +// window is created, destroyed etc. Thus it provides a thread safe mapping +// from NativeViewIds to the current XID for that widget. +class GtkNativeViewManager { public: // Returns the singleton instance. static GtkNativeViewManager* GetInstance(); + // Must be called from the UI thread: + // // Return a NativeViewId for the given widget and attach to the various // signals emitted by that widget. The NativeViewId is pseudo-randomly // allocated so that a compromised renderer trying to guess values will fail @@ -43,6 +44,8 @@ class GtkNativeViewManager : public base::NonThreadSafe { // lifetime of the GtkWidget. gfx::NativeViewId GetIdForWidget(gfx::NativeView widget); + // May be called from any thread: + // // xid: (output) the resulting X window ID, or 0 // id: a value previously returned from GetIdForWidget // returns: true if |id| is a valid id, false otherwise. @@ -51,9 +54,14 @@ class GtkNativeViewManager : public base::NonThreadSafe { // |*xid| is set to 0. bool GetXIDForId(XID* xid, gfx::NativeViewId id); + // May be called from the UI thread: + // // Same as GetXIDForId except it returns the NativeView (GtkWidget*). bool GetNativeViewForId(gfx::NativeView* xid, gfx::NativeViewId id); + // Must be called from the UI thread because we may need the associated + // widget to create a window. + // // Keeping the XID permanent requires a bit of overhead, so it must // be explicitly requested. // @@ -62,10 +70,14 @@ class GtkNativeViewManager : public base::NonThreadSafe { // returns: true if |id| is a valid id, false otherwise. bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id); + // Can be called from any thread. // Will return false if the given XID isn't permanent or has already been // released. bool AddRefPermanentXID(XID xid); + // Must be called from the UI thread because we may need to access a + // GtkWidget or destroy a GdkWindow. + // // If the widget associated with the XID is still alive, allow the widget // to destroy the associated XID when it wants. Otherwise, destroy the // GdkWindow associated with the XID. @@ -91,6 +103,9 @@ class GtkNativeViewManager : public base::NonThreadSafe { gfx::NativeViewId GetWidgetId(gfx::NativeView id); + // protects native_view_to_id_ and id_to_info_ + base::Lock lock_; + // If asked for an id for the same widget twice, we want to return the same // id. So this records the current mapping. std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_; |