Index: chrome/common/extensions/extension_action.h |
diff --git a/chrome/common/extensions/extension_action.h b/chrome/common/extensions/extension_action.h |
index 00b0e603f89fc40a1232802d9bc083833b0b3533..60fd3ff531f33f91c711a17246a3bd40d3d612a2 100644 |
--- a/chrome/common/extensions/extension_action.h |
+++ b/chrome/common/extensions/extension_action.h |
@@ -235,6 +235,13 @@ class ExtensionAction { |
void RunIconAnimation(int tab_id); |
private: |
+ class IconAnimationWrapper; |
+ |
+ // Finds the icon animation wrapper for a tab, if any. If the animation for |
+ // this tab has recently completed, also removes up any other dead wrappers |
+ // from the map. |
+ IconAnimationWrapper* GetIconAnimationWrapper(int tab_id) const; |
+ |
// If the icon animation is running on tab |tab_id|, applies it to |
// |orig| and returns the result. Otherwise, just returns |orig|. |
gfx::Image ApplyIconAnimation(int tab_id, const gfx::Image& orig) const; |
@@ -279,8 +286,13 @@ class ExtensionAction { |
std::map<int, SkColor> badge_text_color_; |
std::map<int, bool> visible_; |
- class IconAnimationWrapper; |
- std::map<int, linked_ptr<IconAnimationWrapper> > icon_animation_; |
+ // IconAnimationWrappers own themselves so that even if the Extension and |
+ // ExtensionAction are destroyed on a non-UI thread, the animation will still |
+ // only be touched from the UI thread. When an animation finishes, it deletes |
+ // itself, which causes the WeakPtr in this map to become NULL. |
+ // GetIconAnimationWrapper() removes NULLs to prevent the map from growing |
+ // without bound. |
+ mutable std::map<int, base::WeakPtr<IconAnimationWrapper> > icon_animation_; |
std::string default_icon_path_; |