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

Unified Diff: ui/accessibility/platform/ax_platform_node.cc

Issue 2988753002: Revert of Migrate BrowserAccessibility windows unique id handling to AXPlatformNodeWin. (Closed)
Patch Set: Created 3 years, 5 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 | « ui/accessibility/platform/ax_platform_node.h ('k') | ui/accessibility/platform/ax_platform_node_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/ax_platform_node.cc
diff --git a/ui/accessibility/platform/ax_platform_node.cc b/ui/accessibility/platform/ax_platform_node.cc
index b35ecb956006ba35656cb0d34f457399f9c042c8..93a374abbacd9dd610e47b1aa8d1dd64803fbe17 100644
--- a/ui/accessibility/platform/ax_platform_node.cc
+++ b/ui/accessibility/platform/ax_platform_node.cc
@@ -9,15 +9,39 @@
#include "build/build_config.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
+#include "ui/accessibility/platform/ax_platform_unique_id.h"
namespace ui {
-AXPlatformNode::AXPlatformNode() {}
+namespace {
+
+using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>;
+// Map from each AXPlatformNode's unique id to its instance.
+base::LazyInstance<UniqueIdMap>::DestructorAtExit g_unique_id_map =
+ LAZY_INSTANCE_INITIALIZER;
+}
+
+AXPlatformNode::AXPlatformNode() : unique_id_(GetNextAXPlatformNodeUniqueId()) {
+ g_unique_id_map.Get()[unique_id_] = this;
+}
AXPlatformNode::~AXPlatformNode() {
+ if (unique_id_)
+ g_unique_id_map.Get().erase(unique_id_);
}
void AXPlatformNode::Destroy() {
+ g_unique_id_map.Get().erase(unique_id_);
+ unique_id_ = 0;
+}
+
+AXPlatformNode* AXPlatformNode::GetFromUniqueId(int32_t unique_id) {
+ UniqueIdMap* unique_ids = g_unique_id_map.Pointer();
+ auto iter = unique_ids->find(unique_id);
+ if (iter != unique_ids->end())
+ return iter->second;
+
+ return nullptr;
}
} // namespace ui
« no previous file with comments | « ui/accessibility/platform/ax_platform_node.h ('k') | ui/accessibility/platform/ax_platform_node_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698