summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 02:38:06 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 02:38:06 +0000
commit0c18444442389baf8aae14953e8d22943807cffc (patch)
treed048588e47d42e8712d37156d1ae1ac1f986f20d /chrome
parent861fcd5d715f0590e75eddfb1bacb0ac356c8026 (diff)
downloadchromium_src-0c18444442389baf8aae14953e8d22943807cffc.zip
chromium_src-0c18444442389baf8aae14953e8d22943807cffc.tar.gz
chromium_src-0c18444442389baf8aae14953e8d22943807cffc.tar.bz2
Don't DCHECK when removing items from the download shelf.
BUG=20186 Review URL: http://codereview.chromium.org/173407 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc16
-rw-r--r--chrome/browser/gtk/download_item_gtk.h5
2 files changed, 19 insertions, 2 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 5399528..30beda8 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -90,6 +90,10 @@ class DownloadShelfContextMenuGtk : public DownloadShelfContextMenu,
~DownloadShelfContextMenuGtk() {
}
+ GtkWidget* widget() {
+ return menu_->widget();
+ }
+
void Popup(GtkWidget* widget, GdkEvent* event) {
// Create the menu if we have not created it yet or we created it for
// an in-progress download that has since completed.
@@ -192,7 +196,8 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf,
dangerous_prompt_(NULL),
dangerous_label_(NULL),
icon_(NULL),
- creation_time_(base::Time::Now()) {
+ creation_time_(base::Time::Now()),
+ method_factory_(this) {
LoadIcon();
body_.Own(gtk_button_new());
@@ -372,7 +377,10 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
switch (download->state()) {
case DownloadItem::REMOVING:
- parent_shelf_->RemoveDownloadItem(this); // This will delete us!
+ // Delete ourselves asychronously so that if we were deleted from the
+ // context menu, its ref holders have a chance to let go.
+ MessageLoop::current()->PostTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(&DownloadItemGtk::RemoveThis));
return;
case DownloadItem::CANCELLED:
StopDownloadProgress();
@@ -411,6 +419,10 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
UpdateStatusLabel(status_label_, status_text_);
}
+void DownloadItemGtk::RemoveThis() {
+ parent_shelf_->RemoveDownloadItem(this);
+}
+
void DownloadItemGtk::AnimationProgressed(const Animation* animation) {
if (animation == complete_animation_.get()) {
gtk_widget_queue_draw(progress_area_.get());
diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h
index 4557695..1ec6319 100644
--- a/chrome/browser/gtk/download_item_gtk.h
+++ b/chrome/browser/gtk/download_item_gtk.h
@@ -84,6 +84,9 @@ class DownloadItemGtk : public DownloadItem::Observer,
// Sets the components of the danger warning.
void UpdateDangerWarning();
+ // Remove ourselves from the parent download shelf. This will delete us.
+ void RemoveThis();
+
static void InitNineBoxes();
// Draws everything in GTK rendering mode.
@@ -211,6 +214,8 @@ class DownloadItemGtk : public DownloadItem::Observer,
// The time at which we were insantiated.
base::Time creation_time_;
+ ScopedRunnableMethodFactory<DownloadItemGtk> method_factory_;
+
// For canceling an in progress icon request.
CancelableRequestConsumerT<int, 0> icon_consumer_;
};