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

Unified Diff: ui/base/resource/resource_bundle_mac.mm

Issue 2699323002: Restrict cross-thread access to gfx::Image and gfx::Font in ResourceBundle (Closed)
Patch Set: rebase Created 3 years, 10 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 | « ui/base/resource/resource_bundle_ios.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle_mac.mm
diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm
index 2dbe9ea26d63a34c08c34a6aa5f861b286f98eb4..b63fd314880cabc1415cd45f26ab53297a207e82 100644
--- a/ui/base/resource/resource_bundle_mac.mm
+++ b/ui/base/resource/resource_bundle_mac.mm
@@ -90,18 +90,18 @@ base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale,
}
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
+ DCHECK(sequence_checker_.CalledOnValidSequence());
// Check to see if the image is already in the cache.
- {
- base::AutoLock lock(*images_and_fonts_lock_);
- if (images_.count(resource_id)) {
- if (!images_[resource_id].HasRepresentation(gfx::Image::kImageRepCocoa)) {
- DLOG(WARNING) << "ResourceBundle::GetNativeImageNamed() is returning a"
+ auto found = images_.find(resource_id);
+ if (found != images_.end()) {
+ if (!found->second.HasRepresentation(gfx::Image::kImageRepCocoa)) {
+ DLOG(WARNING)
+ << "ResourceBundle::GetNativeImageNamed() is returning a"
<< " cached gfx::Image that isn't backed by an NSImage. The image"
<< " will be converted, rather than going through the NSImage loader."
<< " resource_id = " << resource_id;
- }
- return images_[resource_id];
}
+ return found->second;
}
gfx::Image image;
@@ -160,7 +160,7 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
image = gfx::Image(ns_image.release());
}
- base::AutoLock lock(*images_and_fonts_lock_);
+ DCHECK(sequence_checker_.CalledOnValidSequence());
// Another thread raced the load and has already cached the image.
if (images_.count(resource_id))
« no previous file with comments | « ui/base/resource/resource_bundle_ios.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698