OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 orientation:UIImageOrientationUp]); | 156 orientation:UIImageOrientationUp]); |
157 } | 157 } |
158 | 158 |
159 if (!ui_image.get()) { | 159 if (!ui_image.get()) { |
160 LOG(WARNING) << "Unable to load image with id " << resource_id; | 160 LOG(WARNING) << "Unable to load image with id " << resource_id; |
161 NOTREACHED(); // Want to assert in debug mode. | 161 NOTREACHED(); // Want to assert in debug mode. |
162 return GetEmptyImage(); | 162 return GetEmptyImage(); |
163 } | 163 } |
164 | 164 |
165 // The gfx::Image takes ownership. | 165 // The gfx::Image takes ownership. |
166 image = gfx::Image(ui_image.release()); | 166 image = gfx::Image(ui_image, base::scoped_policy::RETAIN); |
167 } | 167 } |
168 | 168 |
169 base::AutoLock lock(*images_and_fonts_lock_); | 169 base::AutoLock lock(*images_and_fonts_lock_); |
170 | 170 |
171 // Another thread raced the load and has already cached the image. | 171 // Another thread raced the load and has already cached the image. |
172 if (images_.count(resource_id)) | 172 if (images_.count(resource_id)) |
173 return images_[resource_id]; | 173 return images_[resource_id]; |
174 | 174 |
175 images_[resource_id] = image; | 175 images_[resource_id] = image; |
176 return images_[resource_id]; | 176 return images_[resource_id]; |
177 } | 177 } |
178 | 178 |
179 } // namespace ui | 179 } // namespace ui |
OLD | NEW |