| 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 #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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // is posted back to this method on the original thread. This method then | 79 // is posted back to this method on the original thread. This method then |
| 80 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if | 80 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if |
| 81 // it was the last image in the list. The |original_size| should be the size | 81 // it was the last image in the list. The |original_size| should be the size |
| 82 // of the image before any resizing was done. | 82 // of the image before any resizing was done. |
| 83 // |image| may be null if the file failed to decode. | 83 // |image| may be null if the file failed to decode. |
| 84 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 84 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
| 85 const gfx::Size& original_size, int id); | 85 const gfx::Size& original_size, int id); |
| 86 | 86 |
| 87 // NotificationObserver method. If an extension is uninstalled while we're | 87 // NotificationObserver method. If an extension is uninstalled while we're |
| 88 // waiting for the image we remove the entry from load_map_. | 88 // waiting for the image we remove the entry from load_map_. |
| 89 virtual void Observe(NotificationType type, | 89 virtual void Observe(int type, |
| 90 const NotificationSource& source, | 90 const NotificationSource& source, |
| 91 const NotificationDetails& details); | 91 const NotificationDetails& details); |
| 92 | 92 |
| 93 // The view that is waiting for the image to load. | 93 // The view that is waiting for the image to load. |
| 94 Observer* observer_; | 94 Observer* observer_; |
| 95 | 95 |
| 96 // ID to use for next image requested. This is an ever increasing integer. | 96 // ID to use for next image requested. This is an ever increasing integer. |
| 97 int next_id_; | 97 int next_id_; |
| 98 | 98 |
| 99 // The object responsible for loading the image on the File thread. | 99 // The object responsible for loading the image on the File thread. |
| 100 scoped_refptr<ImageLoader> loader_; | 100 scoped_refptr<ImageLoader> loader_; |
| 101 | 101 |
| 102 // If LoadImage is told to cache the result an entry is added here. The | 102 // If LoadImage is told to cache the result an entry is added here. The |
| 103 // integer identifies the id assigned to the request. If the extension is | 103 // integer identifies the id assigned to the request. If the extension is |
| 104 // deleted while fetching the image the entry is removed from the map. | 104 // deleted while fetching the image the entry is removed from the map. |
| 105 LoadMap load_map_; | 105 LoadMap load_map_; |
| 106 | 106 |
| 107 NotificationRegistrar registrar_; | 107 NotificationRegistrar registrar_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); | 109 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
| OLD | NEW |