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

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

Issue 286001: Allow slightly larger browser and page action icons. (Closed)
Patch Set: erikkay comments Created 11 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/extensions/image_loading_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 7
8 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
9 9
10 class ExtensionResource; 10 class ExtensionResource;
11 class SkBitmap; 11 class SkBitmap;
12 12
13 namespace gfx {
14 class Size;
15 }
16
13 // The views need to load their icons asynchronously but might be deleted before 17 // The views need to load their icons asynchronously but might be deleted before
14 // the images have loaded. This class stays alive while the request is in 18 // the images have loaded. This class stays alive while the request is in
15 // progress (manages its own lifetime) and keeps track of whether the view still 19 // progress (manages its own lifetime) and keeps track of whether the view still
16 // cares about the icon loading. 20 // cares about the icon loading.
17 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving 21 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving
18 // back to chrome/browser/ if other subsystems want to use it. 22 // back to chrome/browser/ if other subsystems want to use it.
19 class ImageLoadingTracker 23 class ImageLoadingTracker
20 : public base::RefCountedThreadSafe<ImageLoadingTracker> { 24 : public base::RefCountedThreadSafe<ImageLoadingTracker> {
21 public: 25 public:
22 class Observer { 26 class Observer {
(...skipping 14 matching lines...) Expand all
37 41
38 // If there are remaining images to be loaded, the observing object should 42 // If there are remaining images to be loaded, the observing object should
39 // call this method on its destruction, so that the tracker will not attempt 43 // call this method on its destruction, so that the tracker will not attempt
40 // to make any more callbacks to it. 44 // to make any more callbacks to it.
41 void StopTrackingImageLoad() { 45 void StopTrackingImageLoad() {
42 observer_ = NULL; 46 observer_ = NULL;
43 } 47 }
44 48
45 // Specify image resource to load. This method must be called a number of 49 // Specify image resource to load. This method must be called a number of
46 // times equal to the |image_count| arugment to the constructor. Calling it 50 // times equal to the |image_count| arugment to the constructor. Calling it
47 // any more or less than that is an error. 51 // any more or less than that is an error. If the loaded image is larger than
48 void PostLoadImageTask(const ExtensionResource& resource); 52 // |max_size| it will be resized to those dimensions.
53 void PostLoadImageTask(const ExtensionResource& resource,
54 const gfx::Size& max_size);
49 55
50 private: 56 private:
51 class LoadImageTask; 57 class LoadImageTask;
52 58
53 // When an image has finished loaded and scaled on the file thread, it is 59 // When an image has finished loaded and scaled on the file thread, it is
54 // posted back to this method on the original thread. This method then calls 60 // posted back to this method on the original thread. This method then calls
55 // the observer's OnImageLoaded and deletes the ImageLoadingTracker if it was 61 // the observer's OnImageLoaded and deletes the ImageLoadingTracker if it was
56 // the last image in the list. 62 // the last image in the list.
57 // |image| may be null if the file failed to decode. 63 // |image| may be null if the file failed to decode.
58 void OnImageLoaded(SkBitmap* image, size_t index); 64 void OnImageLoaded(SkBitmap* image, size_t index);
59 65
60 // The view that is waiting for the image to load. 66 // The view that is waiting for the image to load.
61 Observer* observer_; 67 Observer* observer_;
62 68
63 // The number of images this ImageTracker should keep track of. This is 69 // The number of images this ImageTracker should keep track of. This is
64 // decremented as each image finishes loading, and the tracker will delete 70 // decremented as each image finishes loading, and the tracker will delete
65 // itself when it reaches zero. 71 // itself when it reaches zero.
66 size_t image_count_; 72 size_t image_count_;
67 73
68 // The number of tasks that have been posted so far. 74 // The number of tasks that have been posted so far.
69 size_t posted_count_; 75 size_t posted_count_;
70 76
71 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); 77 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker);
72 }; 78 };
73 79
74 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ 80 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/image_loading_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698