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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/accessibility/platform/ax_platform_node.h" 5 #include "ui/accessibility/platform/ax_platform_node.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
11 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 11 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
12 #include "ui/accessibility/platform/ax_platform_unique_id.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 AXPlatformNode::AXPlatformNode() {} 16 namespace {
17
18 using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>;
19 // Map from each AXPlatformNode's unique id to its instance.
20 base::LazyInstance<UniqueIdMap>::DestructorAtExit g_unique_id_map =
21 LAZY_INSTANCE_INITIALIZER;
22 }
23
24 AXPlatformNode::AXPlatformNode() : unique_id_(GetNextAXPlatformNodeUniqueId()) {
25 g_unique_id_map.Get()[unique_id_] = this;
26 }
16 27
17 AXPlatformNode::~AXPlatformNode() { 28 AXPlatformNode::~AXPlatformNode() {
29 if (unique_id_)
30 g_unique_id_map.Get().erase(unique_id_);
18 } 31 }
19 32
20 void AXPlatformNode::Destroy() { 33 void AXPlatformNode::Destroy() {
34 g_unique_id_map.Get().erase(unique_id_);
35 unique_id_ = 0;
36 }
37
38 AXPlatformNode* AXPlatformNode::GetFromUniqueId(int32_t unique_id) {
39 UniqueIdMap* unique_ids = g_unique_id_map.Pointer();
40 auto iter = unique_ids->find(unique_id);
41 if (iter != unique_ids->end())
42 return iter->second;
43
44 return nullptr;
21 } 45 }
22 46
23 } // namespace ui 47 } // namespace ui
OLDNEW
« 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