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

Unified Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 2919953002: Revert of Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: Created 3 years, 7 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/browser/themes/browser_theme_pack.h ('k') | chrome/browser/themes/browser_theme_pack_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/browser_theme_pack.cc
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 4f3da00892f7a834b1cd3985999ea460ed09c584..a352c67826141a741a3250a9ad50002f8f22b15d 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -546,13 +546,13 @@
}
// static
-void BrowserThemePack::BuildFromExtension(
- const extensions::Extension* extension,
- scoped_refptr<BrowserThemePack> pack) {
+scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
+ const Extension* extension) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(extension);
DCHECK(extension->is_theme());
- DCHECK(!pack->is_valid());
-
+
+ scoped_refptr<BrowserThemePack> pack(new BrowserThemePack);
pack->BuildHeader(extension);
pack->BuildTintsFromJSON(extensions::ThemeInfo::GetTints(extension));
pack->BuildColorsFromJSON(extensions::ThemeInfo::GetColors(extension));
@@ -567,14 +567,14 @@
&file_paths);
pack->BuildSourceImagesArray(file_paths);
- if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_))
- return;
-
- pack->CreateImages(&pack->images_);
+ if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_))
+ return NULL;
+
+ pack->CreateImages(&pack->images_on_ui_thread_);
// Make sure the |images_on_file_thread_| has bitmaps for supported
// scale factors before passing to FILE thread.
- pack->images_on_file_thread_ = pack->images_;
+ pack->images_on_file_thread_ = pack->images_on_ui_thread_;
for (ImageCache::iterator it = pack->images_on_file_thread_.begin();
it != pack->images_on_file_thread_.end(); ++it) {
gfx::ImageSkia* image_skia =
@@ -582,13 +582,13 @@
image_skia->MakeThreadSafe();
}
- // Set ThemeImageSource on |images_| to resample the source
+ // Set ThemeImageSource on |images_on_ui_thread_| to resample the source
// image if a caller of BrowserThemePack::GetImageNamed() requests an
// ImageSkiaRep for a scale factor not specified by the theme author.
// Callers of BrowserThemePack::GetImageNamed() to be able to retrieve
// ImageSkiaReps for all supported scale factors.
- for (ImageCache::iterator it = pack->images_.begin();
- it != pack->images_.end(); ++it) {
+ for (ImageCache::iterator it = pack->images_on_ui_thread_.begin();
+ it != pack->images_on_ui_thread_.end(); ++it) {
const gfx::ImageSkia source_image_skia = it->second.AsImageSkia();
ThemeImageSource* source = new ThemeImageSource(source_image_skia);
// image_skia takes ownership of source.
@@ -603,7 +603,7 @@
}
// The BrowserThemePack is now in a consistent state.
- pack->is_valid_ = true;
+ return pack;
}
// static
@@ -671,7 +671,6 @@
<< "from those supported by platform.";
return NULL;
}
- pack->is_valid_ = true;
return pack;
}
@@ -682,13 +681,6 @@
return true;
return false;
-}
-
-BrowserThemePack::BrowserThemePack() : CustomThemeSupplier(EXTENSION) {
- scale_factors_ = ui::GetSupportedScaleFactors();
- // On Windows HiDPI SCALE_FACTOR_100P may not be supported by default.
- if (!base::ContainsValue(scale_factors_, ui::SCALE_FACTOR_100P))
- scale_factors_.push_back(ui::SCALE_FACTOR_100P);
}
bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const {
@@ -779,8 +771,8 @@
return gfx::Image();
// Check if the image is cached.
- ImageCache::const_iterator image_iter = images_.find(prs_id);
- if (image_iter != images_.end())
+ ImageCache::const_iterator image_iter = images_on_ui_thread_.find(prs_id);
+ if (image_iter != images_on_ui_thread_.end())
return image_iter->second;
ThemeImagePngSource::PngMap png_map;
@@ -794,7 +786,7 @@
gfx::ImageSkia image_skia(new ThemeImagePngSource(png_map), 1.0f);
// |image_skia| takes ownership of ThemeImagePngSource.
gfx::Image ret = gfx::Image(image_skia);
- images_[prs_id] = ret;
+ images_on_ui_thread_[prs_id] = ret;
return ret;
}
@@ -837,6 +829,19 @@
}
// private:
+
+BrowserThemePack::BrowserThemePack()
+ : CustomThemeSupplier(EXTENSION),
+ header_(NULL),
+ tints_(NULL),
+ colors_(NULL),
+ display_properties_(NULL),
+ source_images_(NULL) {
+ scale_factors_ = ui::GetSupportedScaleFactors();
+ // On Windows HiDPI SCALE_FACTOR_100P may not be supported by default.
+ if (!base::ContainsValue(scale_factors_, ui::SCALE_FACTOR_100P))
+ scale_factors_.push_back(ui::SCALE_FACTOR_100P);
+}
void BrowserThemePack::BuildHeader(const Extension* extension) {
header_ = new BrowserThemePackHeader;
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/browser/themes/browser_theme_pack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698