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 #ifndef CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 | 115 |
116 // When an image has finished loaded and been resized on the file thread, it | 116 // When an image has finished loaded and been resized on the file thread, it |
117 // is posted back to this method on the original thread. This method then | 117 // is posted back to this method on the original thread. This method then |
118 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if | 118 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if |
119 // it was the last image in the list. The |original_size| should be the size | 119 // it was the last image in the list. The |original_size| should be the size |
120 // of the image before any resizing was done. | 120 // of the image before any resizing was done. |
121 // |image| may be null if the file failed to decode. | 121 // |image| may be null if the file failed to decode. |
122 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 122 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
123 const gfx::Size& original_size, int id, bool should_cache); | 123 const gfx::Size& original_size, int id, bool should_cache); |
124 | 124 |
125 // Checks whether image is a component extension resource. Returns false | |
126 // if a given |resource| does not have a corresponding image in bundled | |
127 // resources. Otherwise fills |resource_id|. | |
128 bool IsComponentExtensionResource(const Extension* extension, | |
129 const ExtensionResource& resource, | |
130 int& resource_id) const; | |
131 | |
125 // content::NotificationObserver method. If an extension is uninstalled while | 132 // content::NotificationObserver method. If an extension is uninstalled while |
126 // we're waiting for the image we remove the entry from load_map_. | 133 // we're waiting for the image we remove the entry from load_map_. |
127 virtual void Observe(int type, | 134 virtual void Observe(int type, |
128 const content::NotificationSource& source, | 135 const content::NotificationSource& source, |
129 const content::NotificationDetails& details) OVERRIDE; | 136 const content::NotificationDetails& details) OVERRIDE; |
130 | 137 |
131 // The view that is waiting for the image to load. | 138 // The view that is waiting for the image to load. |
132 Observer* observer_; | 139 Observer* observer_; |
133 | 140 |
134 // ID to use for next image requested. This is an ever increasing integer. | 141 // ID to use for next image requested. This is an ever increasing integer. |
135 int next_id_; | 142 int next_id_; |
136 | 143 |
137 // The object responsible for loading the image on the File thread. | 144 // The object responsible for loading the image on the File thread. |
138 scoped_refptr<ImageLoader> loader_; | 145 scoped_refptr<ImageLoader> loader_; |
139 | 146 |
140 // Information for each LoadImage request is cached here. The integer | 147 // Information for each LoadImage request is cached here. The integer |
141 // identifies the id assigned to the request. | 148 // identifies the id assigned to the request. |
142 LoadMap load_map_; | 149 LoadMap load_map_; |
143 | 150 |
144 content::NotificationRegistrar registrar_; | 151 content::NotificationRegistrar registrar_; |
145 | 152 |
153 friend class ImageLoadingTrackerTest; | |
Finnur
2012/04/11 17:38:13
FRIEND_TEST_ALL_PREFIXES instead?
dgozman
2012/04/12 11:47:24
Done.
| |
154 | |
146 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); | 155 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); |
147 }; | 156 }; |
148 | 157 |
149 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 158 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
OLD | NEW |