diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 16:00:34 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 16:00:34 +0000 |
commit | 699e1cd56df7b6f775601c80e99d26f83162a412 (patch) | |
tree | 22d80a14e0ddd552731daac0be3aa2e6dc8bd9ec /chrome/browser/views/browser_actions_container.cc | |
parent | bfae5e6625d0b3cd38d1b7481a12f6a177a2fbde (diff) | |
download | chromium_src-699e1cd56df7b6f775601c80e99d26f83162a412.zip chromium_src-699e1cd56df7b6f775601c80e99d26f83162a412.tar.gz chromium_src-699e1cd56df7b6f775601c80e99d26f83162a412.tar.bz2 |
Eliminate all UI thread decoding of extension images.
Except one, that is. We have one location we need to
take a look at (I've added a comment). This changelist
converts UI usage of DecodeImage on the UI thread to
a revamped and simplified ImageLoadingTracker class.
I plan on adding to GetFilePath a DCHECK for the File
thread but decided to do so in another changelist,
since it has a high likelyhood of flushing something
out and be backed out because of that. This started
out as issue 38521 (make infobar use cached icons)
but grew in scope to just eliminate all UI thread
access to DecodeImage and GetFilePath.
BUG=http://crbug.com/38521
TEST=None (extensions should work as before)
Review URL: http://codereview.chromium.org/1075006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/browser_actions_container.cc')
-rw-r--r-- | chrome/browser/views/browser_actions_container.cc | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index 0f3eff7..088b0ed 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -98,7 +98,7 @@ BrowserActionButton::BrowserActionButton(Extension* extension, : ALLOW_THIS_IN_INITIALIZER_LIST(MenuButton(this, L"", NULL, false)), browser_action_(extension->browser_action()), extension_(extension), - tracker_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), showing_context_menu_(false), panel_(panel) { set_alignment(TextButton::ALIGN_CENTER); @@ -120,16 +120,12 @@ BrowserActionButton::BrowserActionButton(Extension* extension, // will crash. But since we know that ImageLoadingTracker is asynchronous, // this should be OK. And doing this in the constructor means that we don't // have to protect against it getting done multiple times. - tracker_ = new ImageLoadingTracker(this, 1); - tracker_->PostLoadImageTask( - extension->GetResource(relative_path), - gfx::Size(Extension::kBrowserActionIconMaxSize, - Extension::kBrowserActionIconMaxSize)); + tracker_.LoadImage(extension->GetResource(relative_path), + gfx::Size(Extension::kBrowserActionIconMaxSize, + Extension::kBrowserActionIconMaxSize)); } BrowserActionButton::~BrowserActionButton() { - if (tracker_) - tracker_->StopTrackingImageLoad(); } gfx::Insets BrowserActionButton::GetInsets() const { @@ -142,12 +138,11 @@ void BrowserActionButton::ButtonPressed(views::Button* sender, panel_->OnBrowserActionExecuted(this, false); // inspect_with_devtools } -void BrowserActionButton::OnImageLoaded(SkBitmap* image, size_t index) { +void BrowserActionButton::OnImageLoaded( + SkBitmap* image, ExtensionResource resource, int index) { if (image) default_icon_ = *image; - tracker_ = NULL; // The tracker object will delete itself when we return. - // Call back to UpdateState() because a more specific icon might have been set // while the load was outstanding. UpdateState(); @@ -207,7 +202,7 @@ GURL BrowserActionButton::GetPopupUrl() { bool BrowserActionButton::Activate() { if (IsPopup()) { - panel_->OnBrowserActionExecuted(this, false); // inspect_with_devtools + panel_->OnBrowserActionExecuted(this, false); // |inspect_with_devtools|. // TODO(erikkay): Run a nested modal loop while the mouse is down to // enable menu-like drag-select behavior. @@ -511,7 +506,7 @@ void BrowserActionsContainer::HidePopup() { void BrowserActionsContainer::TestExecuteBrowserAction(int index) { BrowserActionButton* button = browser_action_views_[index]->button(); - OnBrowserActionExecuted(button, false); // inspect_with_devtools + OnBrowserActionExecuted(button, false); // |inspect_with_devtools|. } void BrowserActionsContainer::TestSetIconVisibilityCount(size_t icons) { @@ -1114,7 +1109,7 @@ void BrowserActionsContainer::NotifyMenuDeleted( void BrowserActionsContainer::InspectPopup( ExtensionAction* action) { OnBrowserActionExecuted(GetBrowserActionView(action)->button(), - true); // inspect_with_devtools + true); // |inspect_with_devtools|. } void BrowserActionsContainer::ExtensionPopupClosed(ExtensionPopup* popup) { |