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( | |
129 const Extension* extension, | |
130 const ExtensionResource& resource, | |
131 int& resource_id); | |
Finnur
2012/04/11 10:03:09
nit: Indentation.
dgozman
2012/04/11 14:48:13
Done.
| |
132 | |
125 // content::NotificationObserver method. If an extension is uninstalled while | 133 // content::NotificationObserver method. If an extension is uninstalled while |
126 // we're waiting for the image we remove the entry from load_map_. | 134 // we're waiting for the image we remove the entry from load_map_. |
127 virtual void Observe(int type, | 135 virtual void Observe(int type, |
128 const content::NotificationSource& source, | 136 const content::NotificationSource& source, |
129 const content::NotificationDetails& details) OVERRIDE; | 137 const content::NotificationDetails& details) OVERRIDE; |
130 | 138 |
131 // The view that is waiting for the image to load. | 139 // The view that is waiting for the image to load. |
132 Observer* observer_; | 140 Observer* observer_; |
133 | 141 |
134 // ID to use for next image requested. This is an ever increasing integer. | 142 // ID to use for next image requested. This is an ever increasing integer. |
135 int next_id_; | 143 int next_id_; |
136 | 144 |
137 // The object responsible for loading the image on the File thread. | 145 // The object responsible for loading the image on the File thread. |
138 scoped_refptr<ImageLoader> loader_; | 146 scoped_refptr<ImageLoader> loader_; |
139 | 147 |
140 // Information for each LoadImage request is cached here. The integer | 148 // Information for each LoadImage request is cached here. The integer |
141 // identifies the id assigned to the request. | 149 // identifies the id assigned to the request. |
142 LoadMap load_map_; | 150 LoadMap load_map_; |
143 | 151 |
144 content::NotificationRegistrar registrar_; | 152 content::NotificationRegistrar registrar_; |
145 | 153 |
146 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); | 154 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); |
147 }; | 155 }; |
148 | 156 |
149 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 157 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
OLD | NEW |