OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 5 #ifndef UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
6 #define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 6 #define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // widget to create a window. | 65 // widget to create a window. |
66 // | 66 // |
67 // Keeping the XID permanent requires a bit of overhead, so it must | 67 // Keeping the XID permanent requires a bit of overhead, so it must |
68 // be explicitly requested. | 68 // be explicitly requested. |
69 // | 69 // |
70 // xid: (output) the resulting X window | 70 // xid: (output) the resulting X window |
71 // id: a value previously returned from GetIdForWidget | 71 // id: a value previously returned from GetIdForWidget |
72 // returns: true if |id| is a valid id, false otherwise. | 72 // returns: true if |id| is a valid id, false otherwise. |
73 bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id); | 73 bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id); |
74 | 74 |
| 75 // Can be called from any thread. |
| 76 // Will return false if the given XID isn't permanent or has already been |
| 77 // released. |
| 78 bool AddRefPermanentXID(XID xid); |
| 79 |
75 // Must be called from the UI thread because we may need to access a | 80 // Must be called from the UI thread because we may need to access a |
76 // GtkWidget or destroy a GdkWindow. | 81 // GtkWidget or destroy a GdkWindow. |
77 // | 82 // |
78 // If the widget associated with the XID is still alive, allow the widget | 83 // If the widget associated with the XID is still alive, allow the widget |
79 // to destroy the associated XID when it wants. Otherwise, destroy the | 84 // to destroy the associated XID when it wants. Otherwise, destroy the |
80 // GdkWindow associated with the XID. | 85 // GdkWindow associated with the XID. |
81 void ReleasePermanentXID(XID xid); | 86 void ReleasePermanentXID(XID xid); |
82 | 87 |
83 // These are actually private functions, but need to be called from statics. | 88 // These are actually private functions, but need to be called from statics. |
84 void OnRealize(gfx::NativeView widget); | 89 void OnRealize(gfx::NativeView widget); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // | 137 // |
133 // An XID will map to NULL, if there is an outstanding reference but the | 138 // An XID will map to NULL, if there is an outstanding reference but the |
134 // widget was destroyed. In this case, the destruction of the X window | 139 // widget was destroyed. In this case, the destruction of the X window |
135 // is deferred to the dropping of all references. | 140 // is deferred to the dropping of all references. |
136 std::map<XID, PermanentXIDInfo> perm_xid_to_info_; | 141 std::map<XID, PermanentXIDInfo> perm_xid_to_info_; |
137 | 142 |
138 DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager); | 143 DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager); |
139 }; | 144 }; |
140 | 145 |
141 #endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 146 #endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
OLD | NEW |