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

Unified Diff: chrome/browser/ui/views/status_bubble_views.cc

Issue 8301022: ui/views: Migrate usages of ScopedRunnableMethodFactory to base::WeakPtrFactory/base::Bind pair. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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/ui/views/status_bubble_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/status_bubble_views.cc
diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc
index 6940c8f70030ae15cfc774ac49fd1d0ba518a83f..bc2482429128f5994112995a969e750dc460f005 100644
--- a/chrome/browser/ui/views/status_bubble_views.cc
+++ b/chrome/browser/ui/views/status_bubble_views.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/bind.h"
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -155,7 +156,7 @@ class StatusBubbleViews::StatusView : public views::Label,
BubbleStage stage_;
BubbleStyle style_;
- ScopedRunnableMethodFactory<StatusBubbleViews::StatusView> timer_factory_;
+ base::WeakPtrFactory<StatusBubbleViews::StatusView> timer_factory_;
// Manager, owns us.
StatusBubble* status_bubble_;
@@ -209,11 +210,13 @@ void StatusBubbleViews::StatusView::Hide() {
}
void StatusBubbleViews::StatusView::StartTimer(int time) {
- if (!timer_factory_.empty())
- timer_factory_.RevokeAll();
+ if (timer_factory_.HasWeakPtrs())
+ timer_factory_.InvalidateWeakPtrs();
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- timer_factory_.NewRunnableMethod(&StatusBubbleViews::StatusView::OnTimer),
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&StatusBubbleViews::StatusView::OnTimer,
+ timer_factory_.GetWeakPtr()),
time);
}
@@ -228,8 +231,8 @@ void StatusBubbleViews::StatusView::OnTimer() {
}
void StatusBubbleViews::StatusView::CancelTimer() {
- if (!timer_factory_.empty())
- timer_factory_.RevokeAll();
+ if (timer_factory_.HasWeakPtrs())
+ timer_factory_.InvalidateWeakPtrs();
}
void StatusBubbleViews::StatusView::RestartTimer(int delay) {
@@ -668,9 +671,11 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::string& languages) {
if (is_expanded_ && !url.is_empty())
ExpandBubble();
else if (original_url_text.length() > url_text_.length())
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- expand_timer_factory_.NewRunnableMethod(
- &StatusBubbleViews::ExpandBubble), kExpandHoverDelay);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&StatusBubbleViews::ExpandBubble,
+ expand_timer_factory_.GetWeakPtr()),
+ kExpandHoverDelay);
}
}
@@ -830,6 +835,6 @@ void StatusBubbleViews::SetBubbleWidth(int width) {
}
void StatusBubbleViews::CancelExpandTimer() {
- if (!expand_timer_factory_.empty())
- expand_timer_factory_.RevokeAll();
+ if (expand_timer_factory_.HasWeakPtrs())
+ expand_timer_factory_.InvalidateWeakPtrs();
}
« no previous file with comments | « chrome/browser/ui/views/status_bubble_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698