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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 info->extension->SetCachedImage(image_info.resource, | 365 info->extension->SetCachedImage(image_info.resource, |
366 bitmap ? *bitmap : SkBitmap(), | 366 bitmap ? *bitmap : SkBitmap(), |
367 original_size); | 367 original_size); |
368 } | 368 } |
369 | 369 |
370 // If all pending bitmaps are done then report back. | 370 // If all pending bitmaps are done then report back. |
371 if (info->pending_count == 0) { | 371 if (info->pending_count == 0) { |
372 gfx::Image image; | 372 gfx::Image image; |
373 std::string extension_id = info->extension_id; | 373 std::string extension_id = info->extension_id; |
374 | 374 |
375 if (!info->image_skia.isNull()) | 375 if (!info->image_skia.isNull()) { |
| 376 info->image_skia.MakeThreadSafe(); |
376 image = gfx::Image(info->image_skia); | 377 image = gfx::Image(info->image_skia); |
| 378 } |
377 | 379 |
378 load_map_.erase(load_map_it); | 380 load_map_.erase(load_map_it); |
379 | 381 |
380 // ImageLoadingTracker might be deleted after the callback so don't do | 382 // ImageLoadingTracker might be deleted after the callback so don't do |
381 // anything after this statement. | 383 // anything after this statement. |
382 observer_->OnImageLoaded(image, extension_id, id); | 384 observer_->OnImageLoaded(image, extension_id, id); |
383 } | 385 } |
384 } | 386 } |
385 | 387 |
386 void ImageLoadingTracker::Observe(int type, | 388 void ImageLoadingTracker::Observe(int type, |
387 const content::NotificationSource& source, | 389 const content::NotificationSource& source, |
388 const content::NotificationDetails& details) { | 390 const content::NotificationDetails& details) { |
389 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); | 391 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); |
390 | 392 |
391 const Extension* extension = | 393 const Extension* extension = |
392 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; | 394 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
393 | 395 |
394 // Remove reference to this extension from all pending load entries. This | 396 // Remove reference to this extension from all pending load entries. This |
395 // ensures we don't attempt to cache the bitmap when the load completes. | 397 // ensures we don't attempt to cache the bitmap when the load completes. |
396 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { | 398 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { |
397 PendingLoadInfo* info = &i->second; | 399 PendingLoadInfo* info = &i->second; |
398 if (info->extension == extension) { | 400 if (info->extension == extension) { |
399 info->extension = NULL; | 401 info->extension = NULL; |
400 info->cache = DONT_CACHE; | 402 info->cache = DONT_CACHE; |
401 } | 403 } |
402 } | 404 } |
403 } | 405 } |
OLD | NEW |