Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9526)

Unified Diff: chrome/common/extensions/extension_action.h

Issue 10823142: Fix a race condition when an IconAnimation is still running at browser shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment tweak. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_;

Powered by Google App Engine
This is Rietveld 408576698