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 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 5 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void AXAuraObjCache::Remove(int32 id) { | 69 void AXAuraObjCache::Remove(int32 id) { |
70 AXAuraObjWrapper* obj = Get(id); | 70 AXAuraObjWrapper* obj = Get(id); |
71 | 71 |
72 if (id == -1 || !obj) | 72 if (id == -1 || !obj) |
73 return; | 73 return; |
74 | 74 |
75 cache_.erase(id); | 75 cache_.erase(id); |
76 delete obj; | 76 delete obj; |
77 } | 77 } |
78 | 78 |
79 AXAuraObjCache::AXAuraObjCache() : current_id_(1), is_destroying_(false) { | 79 AXAuraObjCache::AXAuraObjCache() : current_id_(1) { |
80 } | 80 } |
81 | 81 |
82 AXAuraObjCache::~AXAuraObjCache() { | 82 AXAuraObjCache::~AXAuraObjCache() { |
83 is_destroying_ = true; | |
84 STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end()); | 83 STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end()); |
85 cache_.clear(); | 84 cache_.clear(); |
86 } | 85 } |
87 | 86 |
88 template <typename AuraViewWrapper, typename AuraView> | 87 template <typename AuraViewWrapper, typename AuraView> |
89 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( | 88 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( |
90 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { | 89 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { |
91 if (!aura_view) | 90 if (!aura_view) |
92 return NULL; | 91 return NULL; |
93 | 92 |
(...skipping 28 matching lines...) Expand all Loading... |
122 void AXAuraObjCache::RemoveInternal( | 121 void AXAuraObjCache::RemoveInternal( |
123 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { | 122 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { |
124 int32 id = GetID(aura_view); | 123 int32 id = GetID(aura_view); |
125 if (id == -1) | 124 if (id == -1) |
126 return; | 125 return; |
127 aura_view_to_id_map.erase(aura_view); | 126 aura_view_to_id_map.erase(aura_view); |
128 Remove(id); | 127 Remove(id); |
129 } | 128 } |
130 | 129 |
131 } // namespace views | 130 } // namespace views |
OLD | NEW |