summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.h
diff options
context:
space:
mode:
authorlgarron <lgarron@chromium.org>2014-11-17 17:03:39 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-18 01:04:12 +0000
commit9e6dee2aa4a800e861c8359d3bfdc3c3c10c20f5 (patch)
tree24e32b963d00d4ba21d4bc32e8a6e7e1236b42eb /chrome/browser/app_controller_mac.h
parent1de47c7dc023e612aa55d4576e1092d40fd04801 (diff)
downloadchromium_src-9e6dee2aa4a800e861c8359d3bfdc3c3c10c20f5.zip
chromium_src-9e6dee2aa4a800e861c8359d3bfdc3c3c10c20f5.tar.gz
chromium_src-9e6dee2aa4a800e861c8359d3bfdc3c3c10c20f5.tar.bz2
Cache the bookmarks menu on OSX between profile switches.
Previously, when you switched to a profile, we invalidated the existing bookmarks menu and updated it lazily. Because of the way OSX works, this causes the menu to be recalculated from scratch the first time you press *any* keyboard shortcut afer switching to the profile. On a profile with several hundred bookmarks, this can take several seconds - more than enough to impact casual browsing. In particular, it would appear to the user that various innocent shortcuts (e.g. opening a new tab, copying text, highlighting the location bar) are extremely slow some of the time. Even more annoyingly, if you switched to a profile and then immediately alt-tabbed away from it (for example, to get to a third profile), the lockup would take place when you switched *away* from the profile – even if you didn't perform any actions on the profile! This change caches the bookmarks menu and restores it when a window for the profile gains focus again. That way, the bookmarks menu is updated only when an action directly invalidates it (i.e. adding or changing bookmarks themselves). The accompanying test (BookmarksMenuIsRestoredAfterProfileSwitch) verifies that the menu is restored correctly after switching profile windows and back. Thanks to Robert Sesek for extensive help while writing and debugging this fix, as well as its accompanying test. :-) BUG=429371 TEST=Follow the steps in comment #27 on bug 429371: https://crbug.com/429371#c27 Review URL: https://codereview.chromium.org/733673003 Cr-Commit-Position: refs/heads/master@{#304531}
Diffstat (limited to 'chrome/browser/app_controller_mac.h')
-rw-r--r--chrome/browser/app_controller_mac.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/chrome/browser/app_controller_mac.h b/chrome/browser/app_controller_mac.h
index 8e4eccf..6eb522c 100644
--- a/chrome/browser/app_controller_mac.h
+++ b/chrome/browser/app_controller_mac.h
@@ -49,8 +49,13 @@ class WorkAreaWatcherObserver;
scoped_ptr<AppControllerProfileObserver> profileInfoCacheObserver_;
// Management of the bookmark menu which spans across all windows
- // (and Browser*s).
- scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_;
+ // (and Browser*s). |profileBookmarkMenuBridgeMap_| is a cache that owns one
+ // pointer to a BookmarkMenuBridge for each profile. |bookmarkMenuBridge_| is
+ // a weak pointer that is updated to match the corresponding cache entry
+ // during a profile switch.
+ BookmarkMenuBridge* bookmarkMenuBridge_;
+ std::map<Profile*, BookmarkMenuBridge*> profileBookmarkMenuBridgeMap_;
+
scoped_ptr<HistoryMenuBridge> historyMenuBridge_;
// Controller that manages main menu items for packaged apps.