OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/extension_resource.h" | 10 #include "chrome/common/extensions/extension_resource.h" |
11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "content/common/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
14 #include "skia/ext/image_operations.h" | 14 #include "skia/ext/image_operations.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "webkit/glue/image_decoder.h" | 16 #include "webkit/glue/image_decoder.h" |
17 | 17 |
18 ImageLoadingTracker::Observer::~Observer() {} | 18 ImageLoadingTracker::Observer::~Observer() {} |
19 | 19 |
20 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
21 // ImageLoadingTracker::ImageLoader | 21 // ImageLoadingTracker::ImageLoader |
22 | 22 |
23 // A RefCounted class for loading images on the File thread and reporting back | 23 // A RefCounted class for loading images on the File thread and reporting back |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 DISALLOW_COPY_AND_ASSIGN(ImageLoader); | 116 DISALLOW_COPY_AND_ASSIGN(ImageLoader); |
117 }; | 117 }; |
118 | 118 |
119 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
120 // ImageLoadingTracker | 120 // ImageLoadingTracker |
121 | 121 |
122 ImageLoadingTracker::ImageLoadingTracker(Observer* observer) | 122 ImageLoadingTracker::ImageLoadingTracker(Observer* observer) |
123 : observer_(observer), | 123 : observer_(observer), |
124 next_id_(0) { | 124 next_id_(0) { |
125 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 125 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
126 NotificationService::AllSources()); | 126 content::NotificationService::AllSources()); |
127 } | 127 } |
128 | 128 |
129 ImageLoadingTracker::~ImageLoadingTracker() { | 129 ImageLoadingTracker::~ImageLoadingTracker() { |
130 // The loader is created lazily and is NULL if the tracker is destroyed before | 130 // The loader is created lazily and is NULL if the tracker is destroyed before |
131 // any valid image load tasks have been posted. | 131 // any valid image load tasks have been posted. |
132 if (loader_) | 132 if (loader_) |
133 loader_->StopTracking(); | 133 loader_->StopTracking(); |
134 } | 134 } |
135 | 135 |
136 void ImageLoadingTracker::LoadImage(const Extension* extension, | 136 void ImageLoadingTracker::LoadImage(const Extension* extension, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // Remove all entries in the load_map_ referencing the extension. This ensures | 191 // Remove all entries in the load_map_ referencing the extension. This ensures |
192 // we don't attempt to cache the image when the load completes. | 192 // we don't attempt to cache the image when the load completes. |
193 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) { | 193 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) { |
194 if (i->second == extension) { | 194 if (i->second == extension) { |
195 load_map_.erase(i++); | 195 load_map_.erase(i++); |
196 } else { | 196 } else { |
197 ++i; | 197 ++i; |
198 } | 198 } |
199 } | 199 } |
200 } | 200 } |
OLD | NEW |