| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 public: | 31 public: |
| 32 // Get the single instance of this class. | 32 // Get the single instance of this class. |
| 33 static AXAuraObjCache* GetInstance(); | 33 static AXAuraObjCache* GetInstance(); |
| 34 | 34 |
| 35 // Get or create an entry in the cache based on an Aura view. | 35 // Get or create an entry in the cache based on an Aura view. |
| 36 AXAuraObjWrapper* GetOrCreate(View* view); | 36 AXAuraObjWrapper* GetOrCreate(View* view); |
| 37 AXAuraObjWrapper* GetOrCreate(Widget* widget); | 37 AXAuraObjWrapper* GetOrCreate(Widget* widget); |
| 38 AXAuraObjWrapper* GetOrCreate(aura::Window* window); | 38 AXAuraObjWrapper* GetOrCreate(aura::Window* window); |
| 39 | 39 |
| 40 // Gets an id given an Aura view. | 40 // Gets an id given an Aura view. |
| 41 int32_t GetID(View* view) const; | 41 int32_t GetID(View* view); |
| 42 int32_t GetID(Widget* widget) const; | 42 int32_t GetID(Widget* widget); |
| 43 int32_t GetID(aura::Window* window) const; | 43 int32_t GetID(aura::Window* window); |
| 44 | 44 |
| 45 // Gets the next unique id for this cache. Useful for non-Aura view backed | 45 // Gets the next unique id for this cache. Useful for non-Aura view backed |
| 46 // views. | 46 // views. |
| 47 int32_t GetNextID() { return current_id_++; } | 47 int32_t GetNextID() { return current_id_++; } |
| 48 | 48 |
| 49 // Removes an entry from this cache based on an Aura view. | 49 // Removes an entry from this cache based on an Aura view. |
| 50 void Remove(View* view); | 50 void Remove(View* view); |
| 51 void Remove(Widget* widget); | 51 void Remove(Widget* widget); |
| 52 void Remove(aura::Window* window); | 52 void Remove(aura::Window* window); |
| 53 | 53 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 AXAuraObjCache(); | 72 AXAuraObjCache(); |
| 73 virtual ~AXAuraObjCache(); | 73 virtual ~AXAuraObjCache(); |
| 74 | 74 |
| 75 template <typename AuraViewWrapper, typename AuraView> | 75 template <typename AuraViewWrapper, typename AuraView> |
| 76 AXAuraObjWrapper* CreateInternal( | 76 AXAuraObjWrapper* CreateInternal( |
| 77 AuraView* aura_view, | 77 AuraView* aura_view, |
| 78 std::map<AuraView*, int32_t>& aura_view_to_id_map); | 78 std::map<AuraView*, int32_t>& aura_view_to_id_map); |
| 79 | 79 |
| 80 template <typename AuraView> | 80 template <typename AuraView> |
| 81 int32_t GetIDInternal( | 81 int32_t GetIDInternal(AuraView* aura_view, |
| 82 AuraView* aura_view, | 82 std::map<AuraView*, int32_t>& aura_view_to_id_map); |
| 83 const std::map<AuraView*, int32_t>& aura_view_to_id_map) const; | |
| 84 | 83 |
| 85 template <typename AuraView> | 84 template <typename AuraView> |
| 86 void RemoveInternal(AuraView* aura_view, | 85 void RemoveInternal(AuraView* aura_view, |
| 87 std::map<AuraView*, int32_t>& aura_view_to_id_map); | 86 std::map<AuraView*, int32_t>& aura_view_to_id_map); |
| 88 | 87 |
| 89 std::map<views::View*, int32_t> view_to_id_map_; | 88 std::map<views::View*, int32_t> view_to_id_map_; |
| 90 std::map<views::Widget*, int32_t> widget_to_id_map_; | 89 std::map<views::Widget*, int32_t> widget_to_id_map_; |
| 91 std::map<aura::Window*, int32_t> window_to_id_map_; | 90 std::map<aura::Window*, int32_t> window_to_id_map_; |
| 92 | 91 |
| 93 std::map<int32_t, AXAuraObjWrapper*> cache_; | 92 std::map<int32_t, AXAuraObjWrapper*> cache_; |
| 94 int32_t current_id_; | 93 int32_t current_id_; |
| 95 | 94 |
| 96 // True immediately when entering this object's destructor. | 95 // True immediately when entering this object's destructor. |
| 97 bool is_destroying_; | 96 bool is_destroying_; |
| 98 | 97 |
| 99 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); | 98 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 } // namespace views | 101 } // namespace views |
| 103 | 102 |
| 104 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 103 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
| OLD | NEW |