OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
| 6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "ui/views/views_export.h" |
| 12 |
| 13 template <typename T> struct DefaultSingletonTraits; |
| 14 |
| 15 namespace aura { |
| 16 class Window; |
| 17 } // namespace aura |
| 18 |
| 19 namespace views { |
| 20 |
| 21 class AXAuraObjWrapper; |
| 22 class View; |
| 23 class Widget; |
| 24 |
| 25 class VIEWS_EXPORT AXAuraObjCache { |
| 26 public: |
| 27 // Get the single instance of this class. |
| 28 static AXAuraObjCache* GetInstance(); |
| 29 |
| 30 AXAuraObjWrapper* GetOrCreate(View* view); |
| 31 AXAuraObjWrapper* GetOrCreate(Widget* widget); |
| 32 AXAuraObjWrapper* GetOrCreate(aura::Window* window); |
| 33 |
| 34 int32 GetID(View* view); |
| 35 int32 GetID(Widget* widget); |
| 36 int32 GetID(aura::Window* window); |
| 37 |
| 38 void Remove(View* view); |
| 39 void Remove(Widget* widget); |
| 40 void Remove(aura::Window* window); |
| 41 |
| 42 AXAuraObjWrapper* Get(int32 id); |
| 43 void Remove(int32 id); |
| 44 |
| 45 private: |
| 46 friend struct DefaultSingletonTraits<AXAuraObjCache>; |
| 47 |
| 48 AXAuraObjCache() : current_id_(1) {} |
| 49 virtual ~AXAuraObjCache() {} |
| 50 |
| 51 std::map<views::View*, int32> view_to_id_map_; |
| 52 std::map<views::Widget*, int32> widget_to_id_map_; |
| 53 std::map<aura::Window*, int32> window_to_id_map_; |
| 54 |
| 55 std::map<int32, AXAuraObjWrapper*> cache_; |
| 56 int32 current_id_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); |
| 59 }; |
| 60 |
| 61 } // namespace views |
| 62 |
| 63 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
OLD | NEW |