OLD | NEW |
1 // Copyright (c) 2009 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 #include "ui/gfx/gtk_native_view_id_manager.h" | 5 #include "ui/gfx/gtk_native_view_id_manager.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 perm_xid_to_info_.insert(std::make_pair(*output, info)); | 122 perm_xid_to_info_.insert(std::make_pair(*output, info)); |
123 | 123 |
124 if (!ret.second) { | 124 if (!ret.second) { |
125 DCHECK(ret.first->second.widget == widget); | 125 DCHECK(ret.first->second.widget == widget); |
126 ret.first->second.ref_count++; | 126 ret.first->second.ref_count++; |
127 } | 127 } |
128 | 128 |
129 return true; | 129 return true; |
130 } | 130 } |
131 | 131 |
| 132 bool GtkNativeViewManager::AddRefPermanentXID(XID xid) { |
| 133 base::AutoLock locked(lock_); |
| 134 |
| 135 std::map<XID, PermanentXIDInfo>::iterator i = |
| 136 perm_xid_to_info_.find(xid); |
| 137 |
| 138 if (i == perm_xid_to_info_.end()) |
| 139 return false; |
| 140 |
| 141 i->second.ref_count++; |
| 142 |
| 143 return true; |
| 144 } |
| 145 |
132 void GtkNativeViewManager::ReleasePermanentXID(XID xid) { | 146 void GtkNativeViewManager::ReleasePermanentXID(XID xid) { |
133 base::AutoLock locked(lock_); | 147 base::AutoLock locked(lock_); |
134 | 148 |
135 std::map<XID, PermanentXIDInfo>::iterator i = | 149 std::map<XID, PermanentXIDInfo>::iterator i = |
136 perm_xid_to_info_.find(xid); | 150 perm_xid_to_info_.find(xid); |
137 | 151 |
138 if (i == perm_xid_to_info_.end()) | 152 if (i == perm_xid_to_info_.end()) |
139 return; | 153 return; |
140 | 154 |
141 if (i->second.ref_count > 1) { | 155 if (i->second.ref_count > 1) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 228 |
215 if (k != perm_xid_to_info_.end()) | 229 if (k != perm_xid_to_info_.end()) |
216 k->second.widget = NULL; | 230 k->second.widget = NULL; |
217 } | 231 } |
218 | 232 |
219 native_view_to_id_.erase(i); | 233 native_view_to_id_.erase(i); |
220 id_to_info_.erase(j); | 234 id_to_info_.erase(j); |
221 } | 235 } |
222 | 236 |
223 // ----------------------------------------------------------------------------- | 237 // ----------------------------------------------------------------------------- |
OLD | NEW |