OLD | NEW |
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 #ifndef UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 5 #ifndef UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void Remove(View* view); | 45 void Remove(View* view); |
46 void Remove(Widget* widget); | 46 void Remove(Widget* widget); |
47 void Remove(aura::Window* window); | 47 void Remove(aura::Window* window); |
48 | 48 |
49 // Lookup a cached entry based on an id. | 49 // Lookup a cached entry based on an id. |
50 AXAuraObjWrapper* Get(int32 id); | 50 AXAuraObjWrapper* Get(int32 id); |
51 | 51 |
52 // Remove a cached entry based on an id. | 52 // Remove a cached entry based on an id. |
53 void Remove(int32 id); | 53 void Remove(int32 id); |
54 | 54 |
| 55 // Indicates if this object's currently being destroyed. |
| 56 bool is_destroying() { return is_destroying_; } |
| 57 |
55 private: | 58 private: |
56 friend struct DefaultSingletonTraits<AXAuraObjCache>; | 59 friend struct DefaultSingletonTraits<AXAuraObjCache>; |
57 | 60 |
58 AXAuraObjCache(); | 61 AXAuraObjCache(); |
59 virtual ~AXAuraObjCache(); | 62 virtual ~AXAuraObjCache(); |
60 | 63 |
61 template <typename AuraViewWrapper, typename AuraView> | 64 template <typename AuraViewWrapper, typename AuraView> |
62 AXAuraObjWrapper* CreateInternal( | 65 AXAuraObjWrapper* CreateInternal( |
63 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); | 66 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); |
64 | 67 |
65 template<typename AuraView> int32 GetIDInternal( | 68 template<typename AuraView> int32 GetIDInternal( |
66 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); | 69 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); |
67 | 70 |
68 template<typename AuraView> void RemoveInternal( | 71 template<typename AuraView> void RemoveInternal( |
69 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); | 72 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map); |
70 | 73 |
71 std::map<views::View*, int32> view_to_id_map_; | 74 std::map<views::View*, int32> view_to_id_map_; |
72 std::map<views::Widget*, int32> widget_to_id_map_; | 75 std::map<views::Widget*, int32> widget_to_id_map_; |
73 std::map<aura::Window*, int32> window_to_id_map_; | 76 std::map<aura::Window*, int32> window_to_id_map_; |
74 | 77 |
75 std::map<int32, AXAuraObjWrapper*> cache_; | 78 std::map<int32, AXAuraObjWrapper*> cache_; |
76 int32 current_id_; | 79 int32 current_id_; |
77 | 80 |
| 81 // True immediately when entering this object's destructor. |
| 82 bool is_destroying_; |
| 83 |
78 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); | 84 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); |
79 }; | 85 }; |
80 | 86 |
81 } // namespace views | 87 } // namespace views |
82 | 88 |
83 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 89 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
OLD | NEW |