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

Unified Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 173445: Cache GTMTheme across windows to avoid re-creating it every time we create a ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 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/browser/cocoa/browser_window_controller.mm
===================================================================
--- chrome/browser/cocoa/browser_window_controller.mm (revision 24242)
+++ chrome/browser/cocoa/browser_window_controller.mm (working copy)
@@ -1202,7 +1202,16 @@
@implementation GTMTheme (BrowserThemeProviderInitialization)
+ (GTMTheme *)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider
isOffTheRecord:(BOOL)isOffTheRecord {
- GTMTheme *theme = [[[GTMTheme alloc] init] autorelease];
+ // First check if it's in the cache.
+ typedef std::pair<std::string, BOOL> ThemeKey;
+ static std::map<ThemeKey, GTMTheme*> cache;
Mark Mentovai 2009/08/26 01:25:49 I think that every place we have a static that lea
pink (ping after 24hrs) 2009/08/26 14:55:56 Done.
+ ThemeKey key(provider->GetThemeID(), isOffTheRecord);
+ GTMTheme* theme = cache[key];
+ if (theme)
+ return theme;
+
+ theme = [[GTMTheme alloc] init]; // "Leak" it in the cache.
+ cache[key] = theme;
if (isOffTheRecord) {
NSColor* incognitoColor = [NSColor colorWithCalibratedRed:83/255.0
green:108.0/255.0
« no previous file with comments | « no previous file | chrome/browser/cocoa/gradient_button_cell.h » ('j') | chrome/browser/cocoa/gradient_button_cell.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698