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

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

Issue 264046: Update browser actions api to be like new design doc. (Closed)
Patch Set: rebase 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
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 #include "chrome/browser/extensions/image_loading_tracker.h" 5 #include "chrome/browser/extensions/image_loading_tracker.h"
6 6
7 #include "app/gfx/favicon_size.h" 7 #include "app/gfx/favicon_size.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 20 matching lines...) Expand all
31 // identifier for the image that we pass back to the caller. 31 // identifier for the image that we pass back to the caller.
32 LoadImageTask(ImageLoadingTracker* tracker, 32 LoadImageTask(ImageLoadingTracker* tracker,
33 const ExtensionResource& resource, 33 const ExtensionResource& resource,
34 size_t index) 34 size_t index)
35 : callback_loop_(MessageLoop::current()), 35 : callback_loop_(MessageLoop::current()),
36 tracker_(tracker), 36 tracker_(tracker),
37 resource_(resource), 37 resource_(resource),
38 index_(index) {} 38 index_(index) {}
39 39
40 void ReportBack(SkBitmap* image) { 40 void ReportBack(SkBitmap* image) {
41 DCHECK(image);
42 callback_loop_->PostTask(FROM_HERE, NewRunnableMethod(tracker_, 41 callback_loop_->PostTask(FROM_HERE, NewRunnableMethod(tracker_,
43 &ImageLoadingTracker::OnImageLoaded, 42 &ImageLoadingTracker::OnImageLoaded,
44 image, 43 image,
45 index_)); 44 index_));
46 } 45 }
47 46
48 virtual void Run() { 47 virtual void Run() {
49 // Read the file from disk. 48 // Read the file from disk.
50 std::string file_contents; 49 std::string file_contents;
51 FilePath path = resource_.GetFilePath(); 50 FilePath path = resource_.GetFilePath();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 //////////////////////////////////////////////////////////////////////////////// 95 ////////////////////////////////////////////////////////////////////////////////
97 // ImageLoadingTracker 96 // ImageLoadingTracker
98 97
99 void ImageLoadingTracker::PostLoadImageTask(const ExtensionResource& resource) { 98 void ImageLoadingTracker::PostLoadImageTask(const ExtensionResource& resource) {
100 MessageLoop* file_loop = g_browser_process->file_thread()->message_loop(); 99 MessageLoop* file_loop = g_browser_process->file_thread()->message_loop();
101 file_loop->PostTask(FROM_HERE, new LoadImageTask(this, resource, 100 file_loop->PostTask(FROM_HERE, new LoadImageTask(this, resource,
102 posted_count_++)); 101 posted_count_++));
103 } 102 }
104 103
105 void ImageLoadingTracker::OnImageLoaded(SkBitmap* image, size_t index) { 104 void ImageLoadingTracker::OnImageLoaded(SkBitmap* image, size_t index) {
106 if (image == NULL) {
107 NOTREACHED() << "Image failed to decode.";
108 image = new SkBitmap();
109 }
110 if (observer_) 105 if (observer_)
111 observer_->OnImageLoaded(image, index); 106 observer_->OnImageLoaded(image, index);
112 delete image; 107
108 if (image)
109 delete image;
110
113 if (--image_count_ == 0) 111 if (--image_count_ == 0)
114 Release(); // We are no longer needed. 112 Release(); // We are no longer needed.
115 } 113 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/gtk/browser_actions_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698