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

Unified Diff: chrome/browser/extensions/image_loading_tracker.cc

Issue 345023: Get rid of MessageLoop* caching in extensions code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_ui.cc ('k') | chrome/browser/extensions/pack_extension_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/image_loading_tracker.cc
===================================================================
--- chrome/browser/extensions/image_loading_tracker.cc (revision 30521)
+++ chrome/browser/extensions/image_loading_tracker.cc (working copy)
@@ -11,7 +11,7 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "base/thread.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/common/extensions/extension_resource.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -22,7 +22,7 @@
// The LoadImageTask is for asynchronously loading the image on the file thread.
// If the image is successfully loaded and decoded it will report back on the
-// |callback_loop| to let the caller know the image is done loading.
+// calling thread to let the caller know the image is done loading.
class ImageLoadingTracker::LoadImageTask : public Task {
public:
// Constructor for the LoadImageTask class. |tracker| is the object that
@@ -35,17 +35,18 @@
const ExtensionResource& resource,
const gfx::Size& max_size,
size_t index)
- : callback_loop_(MessageLoop::current()),
- tracker_(tracker),
+ : tracker_(tracker),
resource_(resource),
max_size_(max_size),
- index_(index) {}
+ index_(index) {
+ CHECK(ChromeThread::GetCurrentThreadIdentifier(&callback_thread_id_));
+ }
void ReportBack(SkBitmap* image) {
- callback_loop_->PostTask(FROM_HERE, NewRunnableMethod(tracker_,
- &ImageLoadingTracker::OnImageLoaded,
- image,
- index_));
+ ChromeThread::PostTask(
+ callback_thread_id_, FROM_HERE,
+ NewRunnableMethod(
+ tracker_, &ImageLoadingTracker::OnImageLoaded, image, index_));
}
virtual void Run() {
@@ -80,8 +81,8 @@
}
private:
- // The message loop that we need to call back on to report that we are done.
- MessageLoop* callback_loop_;
+ // The thread that we need to call back on to report that we are done.
+ ChromeThread::ID callback_thread_id_;
// The object that is waiting for us to respond back.
ImageLoadingTracker* tracker_;
@@ -101,9 +102,9 @@
void ImageLoadingTracker::PostLoadImageTask(const ExtensionResource& resource,
const gfx::Size& max_size) {
- MessageLoop* file_loop = g_browser_process->file_thread()->message_loop();
- file_loop->PostTask(FROM_HERE, new LoadImageTask(this, resource, max_size,
- posted_count_++));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ new LoadImageTask(this, resource, max_size, posted_count_++));
}
void ImageLoadingTracker::OnImageLoaded(SkBitmap* image, size_t index) {
« no previous file with comments | « chrome/browser/extensions/extensions_ui.cc ('k') | chrome/browser/extensions/pack_extension_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698