OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/extensions/image_loading_tracker.h" | 5 #include "chrome/browser/extensions/image_loading_tracker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 PendingLoadInfo* info = &load_map_it->second; | 304 PendingLoadInfo* info = &load_map_it->second; |
305 | 305 |
306 // Save the pending results. | 306 // Save the pending results. |
307 DCHECK(info->pending_count > 0); | 307 DCHECK(info->pending_count > 0); |
308 info->pending_count--; | 308 info->pending_count--; |
309 if (image) | 309 if (image) |
310 info->bitmaps.push_back(*image); | 310 info->bitmaps.push_back(*image); |
311 | 311 |
312 // Add to the extension's image cache if requested. | 312 // Add to the extension's image cache if requested. |
313 DCHECK(info->cache != CACHE || info->extension); | 313 DCHECK(info->cache != CACHE || info->extension); |
314 if (should_cache && info->cache == CACHE && | 314 if (should_cache && info->cache == CACHE && !resource.empty() && |
315 !info->extension->HasCachedImage(resource, original_size)) { | 315 !info->extension->HasCachedImage(resource, original_size)) { |
316 info->extension->SetCachedImage(resource, image ? *image : SkBitmap(), | 316 info->extension->SetCachedImage(resource, image ? *image : SkBitmap(), |
317 original_size); | 317 original_size); |
318 } | 318 } |
319 | 319 |
320 // If all pending images are done then report back. | 320 // If all pending images are done then report back. |
321 if (info->pending_count == 0) { | 321 if (info->pending_count == 0) { |
322 gfx::Image image; | 322 gfx::Image image; |
323 std::string extension_id = info->extension_id; | 323 std::string extension_id = info->extension_id; |
324 | 324 |
(...skipping 27 matching lines...) Expand all Loading... |
352 // Remove reference to this extension from all pending load entries. This | 352 // Remove reference to this extension from all pending load entries. This |
353 // ensures we don't attempt to cache the image when the load completes. | 353 // ensures we don't attempt to cache the image when the load completes. |
354 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { | 354 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { |
355 PendingLoadInfo* info = &i->second; | 355 PendingLoadInfo* info = &i->second; |
356 if (info->extension == extension) { | 356 if (info->extension == extension) { |
357 info->extension = NULL; | 357 info->extension = NULL; |
358 info->cache = DONT_CACHE; | 358 info->cache = DONT_CACHE; |
359 } | 359 } |
360 } | 360 } |
361 } | 361 } |
OLD | NEW |