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

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

Issue 1771033003: gfx::Image: Added thread checker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove UpdateShortcutWorker changes; instead just disable thread checking. Created 3 years, 5 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/themes/browser_theme_pack.cc
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 8b72d3c7d82487ad3c957f0f456df4682ffe917a..7227d64ae1ec4539ac674ea551bdc79180bdfe01 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -537,6 +537,8 @@ class TabBackgroundImageSource: public gfx::CanvasImageSource {
} // namespace
BrowserThemePack::~BrowserThemePack() {
+ DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+
if (!data_pack_.get()) {
delete header_;
delete [] tints_;
@@ -544,6 +546,20 @@ BrowserThemePack::~BrowserThemePack() {
delete [] display_properties_;
delete [] source_images_;
}
+
+ // |images_| will trigger the thread-checker as the images were built on the
+ // UI thread and we are on the FILE thread. As a special case, it is safe to
+ // delete them on the FILE thread because there are no remaining references to
+ // this BrowserThemePack from the UI thread. Explicitly detach all the images
+ // from the UI thread to suppress the error.
+ for (auto image : images_)
+ image.second.DetachFromThread();
+
+ // For the same reason, detach all of the |images_on_file_thread_| from
+ // whatever thread they are attached to. (Note that |images_on_file_thread_|
+ // is usually accessed on the FILE thread, but not always.)
+ for (auto image : images_on_file_thread_)
+ image.second.DetachFromThread();
}
// static
@@ -594,6 +610,9 @@ void BrowserThemePack::BuildFromExtension(
ThemeImageSource* source = new ThemeImageSource(source_image_skia);
// image_skia takes ownership of source.
gfx::ImageSkia image_skia(source, source_image_skia.size());
+ // From now on, it->second will only be stored in |images_on_file_thread_|,
+ // so detach it from the UI thread.
+ it->second.DetachFromThread();
it->second = gfx::Image(image_skia);
}
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/browser/web_applications/update_shortcut_worker_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698