summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/controls/menu/native_menu_win.cc9
-rw-r--r--views/controls/menu/native_menu_win.h3
-rw-r--r--views/controls/table/group_table_view.cc15
-rw-r--r--views/controls/table/group_table_view.h11
-rw-r--r--views/mouse_watcher.cc12
5 files changed, 27 insertions, 23 deletions
diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc
index fd82353..9cb765a 100644
--- a/views/controls/menu/native_menu_win.cc
+++ b/views/controls/menu/native_menu_win.cc
@@ -6,6 +6,7 @@
#include <Windowsx.h>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/stl_util.h"
@@ -421,7 +422,7 @@ void NativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) {
HWND hwnd = host_window_->hwnd();
menu_to_select_ = NULL;
position_to_select_ = -1;
- menu_to_select_factory_.RevokeAll();
+ menu_to_select_factory_.InvalidateWeakPtrs();
bool destroyed = false;
destroyed_flag_ = &destroyed;
model_->MenuWillShow();
@@ -437,11 +438,11 @@ void NativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) {
// the delegate can cause destruction leaving the stack in a weird
// state. Instead post a task, then notify. This mirrors what WM_MENUCOMMAND
// does.
- menu_to_select_factory_.RevokeAll();
+ menu_to_select_factory_.InvalidateWeakPtrs();
MessageLoop::current()->PostTask(
FROM_HERE,
- menu_to_select_factory_.NewRunnableMethod(
- &NativeMenuWin::DelayedSelect));
+ base::Bind(&NativeMenuWin::DelayedSelect,
+ menu_to_select_factory_.GetWeakPtr()));
menu_action_ = MENU_ACTION_SELECTED;
}
// Send MenuClosed after we schedule the select, otherwise MenuClosed is
diff --git a/views/controls/menu/native_menu_win.h b/views/controls/menu/native_menu_win.h
index 7419196..6f32505 100644
--- a/views/controls/menu/native_menu_win.h
+++ b/views/controls/menu/native_menu_win.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "ui/base/models/simple_menu_model.h"
@@ -142,7 +143,7 @@ class VIEWS_EXPORT NativeMenuWin : public MenuWrapper {
// See comment in MenuMessageHook for details on these.
NativeMenuWin* menu_to_select_;
int position_to_select_;
- ScopedRunnableMethodFactory<NativeMenuWin> menu_to_select_factory_;
+ base::WeakPtrFactory<NativeMenuWin> menu_to_select_factory_;
// If we're a submenu, this is our parent.
NativeMenuWin* parent_;
diff --git a/views/controls/table/group_table_view.cc b/views/controls/table/group_table_view.cc
index 00f6d37..3f8a1be 100644
--- a/views/controls/table/group_table_view.cc
+++ b/views/controls/table/group_table_view.cc
@@ -4,15 +4,15 @@
#include "views/controls/table/group_table_view.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "ui/gfx/canvas.h"
namespace views {
-static const COLORREF kSeparatorLineColor = RGB(208, 208, 208);
-static const int kSeparatorLineThickness = 1;
+const COLORREF kSeparatorLineColor = RGB(208, 208, 208);
+const int kSeparatorLineThickness = 1;
const char GroupTableView::kViewClassName[] = "views/GroupTableView";
@@ -159,10 +159,11 @@ void GroupTableView::OnSelectedStateChanged() {
// items. For that reason, we post a task to be performed later, after all
// selection messages have been processed. In the meantime we just ignore all
// selection notifications.
- if (sync_selection_factory_.empty()) {
- MessageLoop::current()->PostTask(FROM_HERE,
- sync_selection_factory_.NewRunnableMethod(
- &GroupTableView::SyncSelection));
+ if (!sync_selection_factory_.HasWeakPtrs()) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&GroupTableView::SyncSelection,
+ sync_selection_factory_.GetWeakPtr()));
}
TableView::OnSelectedStateChanged();
}
diff --git a/views/controls/table/group_table_view.h b/views/controls/table/group_table_view.h
index f54c03a..586fb80 100644
--- a/views/controls/table/group_table_view.h
+++ b/views/controls/table/group_table_view.h
@@ -6,14 +6,10 @@
#define VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_H_
#pragma once
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "ui/base/models/table_model.h"
#include "views/controls/table/table_view.h"
-// The GroupTableView adds grouping to the TableView class.
-// It allows to have groups of rows that act as a single row from the selection
-// perspective. Groups are visually separated by a horizontal line.
-
namespace views {
struct GroupRange {
@@ -29,6 +25,9 @@ class GroupTableModel : public ui::TableModel {
virtual void GetGroupRangeForItem(int item, GroupRange* range) = 0;
};
+// GroupTableView adds grouping to the TableView class.
+// It allows to have groups of rows that act as a single row from the selection
+// perspective. Groups are visually separated by a horizontal line.
class VIEWS_EXPORT GroupTableView : public TableView {
public:
// The view class name.
@@ -75,7 +74,7 @@ class VIEWS_EXPORT GroupTableView : public TableView {
bool draw_group_separators_;
// A factory to make the selection consistent among groups.
- ScopedRunnableMethodFactory<GroupTableView> sync_selection_factory_;
+ base::WeakPtrFactory<GroupTableView> sync_selection_factory_;
// Maps from model row to start of group.
std::map<int,int> model_index_to_range_start_map_;
diff --git a/views/mouse_watcher.cc b/views/mouse_watcher.cc
index 5daab25..3166f90 100644
--- a/views/mouse_watcher.cc
+++ b/views/mouse_watcher.cc
@@ -4,7 +4,9 @@
#include "views/mouse_watcher.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/task.h"
#include "ui/gfx/screen.h"
@@ -140,18 +142,18 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
if (!in_view || (check_window && !IsMouseOverWindow())) {
// Mouse moved outside the view's zone, start a timer to notify the
// listener.
- if (notify_listener_factory_.empty()) {
+ if (!notify_listener_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- notify_listener_factory_.NewRunnableMethod(
- &Observer::NotifyListener),
+ base::Bind(&Observer::NotifyListener,
+ notify_listener_factory_.GetWeakPtr()),
!in_view ? kNotifyListenerTimeMs :
mouse_watcher_->notify_on_exit_time_ms_);
}
} else {
// Mouse moved quickly out of the view and then into it again, so cancel
// the timer.
- notify_listener_factory_.RevokeAll();
+ notify_listener_factory_.InvalidateWeakPtrs();
}
}
@@ -164,7 +166,7 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
MouseWatcher* mouse_watcher_;
// A factory that is used to construct a delayed callback to the listener.
- ScopedRunnableMethodFactory<Observer> notify_listener_factory_;
+ base::WeakPtrFactory<Observer> notify_listener_factory_;
DISALLOW_COPY_AND_ASSIGN(Observer);
};