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

Side by Side Diff: chrome/browser/extensions/image_loading_tracker.cc

Issue 5968009: Change extension unload notification to indicate updates.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h" 7 #include "base/file_util.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.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"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 }; 116 };
117 117
118 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
119 // ImageLoadingTracker 119 // ImageLoadingTracker
120 120
121 ImageLoadingTracker::ImageLoadingTracker(Observer* observer) 121 ImageLoadingTracker::ImageLoadingTracker(Observer* observer)
122 : observer_(observer), 122 : observer_(observer),
123 next_id_(0) { 123 next_id_(0) {
124 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 124 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
125 NotificationService::AllSources()); 125 NotificationService::AllSources());
126 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED,
127 NotificationService::AllSources());
128 } 126 }
129 127
130 ImageLoadingTracker::~ImageLoadingTracker() { 128 ImageLoadingTracker::~ImageLoadingTracker() {
131 // The loader is created lazily and is NULL if the tracker is destroyed before 129 // The loader is created lazily and is NULL if the tracker is destroyed before
132 // any valid image load tasks have been posted. 130 // any valid image load tasks have been posted.
133 if (loader_) 131 if (loader_)
134 loader_->StopTracking(); 132 loader_->StopTracking();
135 } 133 }
136 134
137 void ImageLoadingTracker::LoadImage(const Extension* extension, 135 void ImageLoadingTracker::LoadImage(const Extension* extension,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 original_size); 175 original_size);
178 load_map_.erase(i); 176 load_map_.erase(i);
179 } 177 }
180 178
181 observer_->OnImageLoaded(image, resource, id); 179 observer_->OnImageLoaded(image, resource, id);
182 } 180 }
183 181
184 void ImageLoadingTracker::Observe(NotificationType type, 182 void ImageLoadingTracker::Observe(NotificationType type,
185 const NotificationSource& source, 183 const NotificationSource& source,
186 const NotificationDetails& details) { 184 const NotificationDetails& details) {
187 DCHECK(type == NotificationType::EXTENSION_UNLOADED || 185 DCHECK(type == NotificationType::EXTENSION_UNLOADED);
188 type == NotificationType::EXTENSION_UNLOADED_DISABLED);
189 186
190 const Extension* extension = Details<const Extension>(details).ptr(); 187 const Extension* extension =
188 Details<UnloadedExtensionInfo>(details)->extension;
191 189
192 // Remove all entries in the load_map_ referencing the extension. This ensures 190 // Remove all entries in the load_map_ referencing the extension. This ensures
193 // we don't attempt to cache the image when the load completes. 191 // we don't attempt to cache the image when the load completes.
194 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) { 192 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) {
195 if (i->second == extension) { 193 if (i->second == extension) {
196 load_map_.erase(i++); 194 load_map_.erase(i++);
197 } else { 195 } else {
198 ++i; 196 ++i;
199 } 197 }
200 } 198 }
201 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698