summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/nsimage_cache.h
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 20:59:32 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 20:59:32 +0000
commit655345e0991a974109e0f2656f6e00afbe8d9e59 (patch)
tree7fcca7714b4957f9efed3496e863c4f15b48941a /chrome/browser/cocoa/nsimage_cache.h
parent5ce8cbcbf65f801bc7f52cc035027d0eb907add5 (diff)
downloadchromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.zip
chromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.tar.gz
chromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.tar.bz2
Added an helper namespace that provides fetches images from the app bundle and caches them, line NSImage imageNamed: but lets us control the bundle that's checked.
Unittest for the helper. Updated the current places that use +[NSImage imageNamed:] to use our cache helper. BUG=none TEST=All the ui images still load. Review URL: http://codereview.chromium.org/149393 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/nsimage_cache.h')
-rw-r--r--chrome/browser/cocoa/nsimage_cache.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/nsimage_cache.h b/chrome/browser/cocoa/nsimage_cache.h
new file mode 100644
index 0000000..2d2511e
--- /dev/null
+++ b/chrome/browser/cocoa/nsimage_cache.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_IMAGE_CACHE_H_
+#define CHROME_BROWSER_COCOA_IMAGE_CACHE_H_
+
+#import <Cocoa/Cocoa.h>
+
+namespace nsimage_cache {
+
+// Returns an autoreleased image from the main app bundle
+// (mac_util::MainAppBundle()) with the given name, and keeps it in memory so
+// future fetches are fast.
+// NOTE:
+// - This should only be called on the main thread.
+// - The caller should retain the image if they want to keep it around, as
+// the cache could have limit on size/lifetime, etc.
+NSImage *ImageNamed(NSString* name);
+
+// Clears the cache.
+void Clear(void);
+
+}
+
+#endif // CHROME_BROWSER_COCOA_IMAGE_CACHE_H_