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

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: Fix nits. 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
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/extension_action.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/extension_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698