diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 19:00:18 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 19:00:18 +0000 |
commit | 49a3e5b02b1e1ef4d8518b50a41129215c616116 (patch) | |
tree | fde8623a4a6152f1dc7c2806d307daed9c069d8a /chrome/browser/browser_theme_provider.h | |
parent | 79c07dd57719c06a1ba5ec28e45d3d767b3a9dc6 (diff) | |
download | chromium_src-49a3e5b02b1e1ef4d8518b50a41129215c616116.zip chromium_src-49a3e5b02b1e1ef4d8518b50a41129215c616116.tar.gz chromium_src-49a3e5b02b1e1ef4d8518b50a41129215c616116.tar.bz2 |
Change disk access on theme install from UI to File thread.
BUG= http://crbug.com/17696
TEST= none
Review URL: http://codereview.chromium.org/222025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider.h')
-rw-r--r-- | chrome/browser/browser_theme_provider.h | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h index e2059a8..d6c20b6 100644 --- a/chrome/browser/browser_theme_provider.h +++ b/chrome/browser/browser_theme_provider.h @@ -13,12 +13,14 @@ #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/basictypes.h" +#include "base/lock.h" #include "base/non_thread_safe.h" #include "base/ref_counted.h" class Extension; class Profile; class DictionaryValue; +class PrefService; class BrowserThemeProvider : public NonThreadSafe, public ThemeProvider { @@ -203,6 +205,20 @@ class BrowserThemeProvider : public NonThreadSafe, // Parse tiling values from something like "no-repeat" into a Tiling value. static int StringToTiling(const std::string &tiling); + // Lock on write to themed_image_cache_ in UI thread; lock on all cache + // access in File thread. This allows the File thread and UI thread to + // both read themed images at the same time, while preventing simultaneous + // File thread read and UI thread write. + static Lock themed_image_cache_lock_; + + // Save the images to be written to disk, mapping file path to id. + typedef std::map<FilePath, int> ImagesDiskCache; + + // Cached images. We cache all retrieved and generated bitmaps and keep + // track of the pointers. We own these and will delete them when we're done + // using them. + typedef std::map<int, SkBitmap*> ImageCache; + protected: // Sets an individual color value. void SetColor(const char* id, const SkColor& color); @@ -297,7 +313,7 @@ class BrowserThemeProvider : public NonThreadSafe, void SetDisplayPropertyData(DictionaryValue* display_properties); // Create any images that aren't pregenerated (e.g. background tab images). - SkBitmap* GenerateBitmap(int id); + SkBitmap* GenerateTabBackgroundBitmap(int id); // Save our data - when saving images we need the original dictionary // from the extension because it contains the text ids that we want to save. @@ -316,7 +332,7 @@ class BrowserThemeProvider : public NonThreadSafe, void ClearCaches(); // Encode image at image_cache_[id] as PNG and write to disk. - bool WriteImagesToDisk(); + void WriteImagesToDisk(); // Do we have a custom frame image or custom tints? bool ShouldTintFrames(); @@ -326,11 +342,14 @@ class BrowserThemeProvider : public NonThreadSafe, GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled); #endif - // Cached images. We cache all retrieved and generated bitmaps and keep - // track of the pointers. We own these and will delete them when we're done - // using them. - typedef std::map<int, SkBitmap*> ImageCache; ImageCache image_cache_; + + // Keep images generated for theme cache in their own place, so we can lock + // them on WRITE from UI thread and READ from file thread. Read from UI + // thread will be allowed unlocked, because no other thread has write + // access to the cache. + ImageCache themed_image_cache_; + #if defined(OS_LINUX) typedef std::map<int, GdkPixbuf*> GdkPixbufMap; GdkPixbufMap gdk_pixbufs_; @@ -341,8 +360,6 @@ class BrowserThemeProvider : public NonThreadSafe, NSColorMap nscolor_cache_; #endif - // Save the images to be written to disk, mapping file path to id. - typedef std::map<FilePath, int> ImagesDiskCache; ImagesDiskCache images_disk_cache_; ResourceBundle& rb_; |