Commit 60d3eac0 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert ui/message_center away from base::Bind/base::Callback

base::Bind/base::Callback are deprecated in favor of either
base::BindOnce/base::OnceCallback or base::BindRepeating/
base::RepeatingCallback (depending on whether the callback
is invoked once or multiple time).

Convert all uses of base::Bind/base::Callback in ui/message_center
to the recommended methods/types.

Bug: 1007852
Change-Id: I98daa048c8729aaa3d42b35e69d562178c04ab95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831859
Commit-Queue: Peter Beverloo <peter@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701079}
parent a99504bc
...@@ -460,11 +460,9 @@ void MessageCenterImpl::EnterQuietModeWithExpire( ...@@ -460,11 +460,9 @@ void MessageCenterImpl::EnterQuietModeWithExpire(
observer.OnQuietModeChanged(true); observer.OnQuietModeChanged(true);
quiet_mode_timer_ = std::make_unique<base::OneShotTimer>(); quiet_mode_timer_ = std::make_unique<base::OneShotTimer>();
quiet_mode_timer_->Start( quiet_mode_timer_->Start(FROM_HERE, expires_in,
FROM_HERE, base::BindOnce(&MessageCenterImpl::SetQuietMode,
expires_in, base::Unretained(this), false));
base::Bind(
&MessageCenterImpl::SetQuietMode, base::Unretained(this), false));
} }
} }
......
...@@ -166,7 +166,7 @@ class MessageCenterImplTest : public testing::Test { ...@@ -166,7 +166,7 @@ class MessageCenterImplTest : public testing::Test {
} }
base::RunLoop* run_loop() const { return run_loop_.get(); } base::RunLoop* run_loop() const { return run_loop_.get(); }
base::Closure closure() const { return closure_; } base::RepeatingClosure closure() const { return closure_; }
protected: protected:
std::unique_ptr<Notification> CreateSimpleNotification( std::unique_ptr<Notification> CreateSimpleNotification(
...@@ -217,7 +217,7 @@ class MessageCenterImplTest : public testing::Test { ...@@ -217,7 +217,7 @@ class MessageCenterImplTest : public testing::Test {
MessageCenter* message_center_; MessageCenter* message_center_;
std::unique_ptr<base::MessageLoop> loop_; std::unique_ptr<base::MessageLoop> loop_;
std::unique_ptr<base::RunLoop> run_loop_; std::unique_ptr<base::RunLoop> run_loop_;
base::Closure closure_; base::RepeatingClosure closure_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterImplTest); DISALLOW_COPY_AND_ASSIGN(MessageCenterImplTest);
}; };
...@@ -316,7 +316,7 @@ namespace internal { ...@@ -316,7 +316,7 @@ namespace internal {
class MockPopupTimersController : public PopupTimersController { class MockPopupTimersController : public PopupTimersController {
public: public:
MockPopupTimersController(MessageCenter* message_center, MockPopupTimersController(MessageCenter* message_center,
base::Closure quit_closure) base::RepeatingClosure quit_closure)
: PopupTimersController(message_center), : PopupTimersController(message_center),
timer_finished_(0), timer_finished_(0),
quit_closure_(quit_closure) {} quit_closure_(quit_closure) {}
...@@ -334,7 +334,7 @@ class MockPopupTimersController : public PopupTimersController { ...@@ -334,7 +334,7 @@ class MockPopupTimersController : public PopupTimersController {
private: private:
int timer_finished_; int timer_finished_;
std::string last_id_; std::string last_id_;
base::Closure quit_closure_; base::RepeatingClosure quit_closure_;
}; };
TEST_F(MessageCenterImplTest, PopupTimersEmptyController) { TEST_F(MessageCenterImplTest, PopupTimersEmptyController) {
......
...@@ -30,9 +30,8 @@ void PopupTimer::Start() { ...@@ -30,9 +30,8 @@ void PopupTimer::Start() {
timeout_ <= passed_ ? base::TimeDelta() : timeout_ - passed_; timeout_ <= passed_ ? base::TimeDelta() : timeout_ - passed_;
start_time_ = base::Time::Now(); start_time_ = base::Time::Now();
timer_->Start( timer_->Start(FROM_HERE, timeout_to_close,
FROM_HERE, timeout_to_close, base::BindOnce(&Delegate::TimerFinished, timer_delegate_, id_));
base::Bind(&Delegate::TimerFinished, timer_delegate_, id_));
} }
void PopupTimer::Pause() { void PopupTimer::Pause() {
......
...@@ -34,16 +34,16 @@ class NotificationDelegateTest : public testing::Test { ...@@ -34,16 +34,16 @@ class NotificationDelegateTest : public testing::Test {
TEST_F(NotificationDelegateTest, ClickDelegate) { TEST_F(NotificationDelegateTest, ClickDelegate) {
auto delegate = base::MakeRefCounted<HandleNotificationClickDelegate>( auto delegate = base::MakeRefCounted<HandleNotificationClickDelegate>(
base::Bind(&NotificationDelegateTest::BodyClickCallback, base::BindRepeating(&NotificationDelegateTest::BodyClickCallback,
base::Unretained(this))); base::Unretained(this)));
delegate->Click(base::nullopt, base::nullopt); delegate->Click(base::nullopt, base::nullopt);
EXPECT_EQ(1, callback_count_); EXPECT_EQ(1, callback_count_);
} }
TEST_F(NotificationDelegateTest, NullClickDelegate) { TEST_F(NotificationDelegateTest, NullClickDelegate) {
auto delegate = auto delegate = base::MakeRefCounted<HandleNotificationClickDelegate>(
base::MakeRefCounted<HandleNotificationClickDelegate>(base::Closure()); base::RepeatingClosure());
delegate->Click(base::nullopt, base::nullopt); delegate->Click(base::nullopt, base::nullopt);
EXPECT_EQ(0, callback_count_); EXPECT_EQ(0, callback_count_);
...@@ -51,8 +51,8 @@ TEST_F(NotificationDelegateTest, NullClickDelegate) { ...@@ -51,8 +51,8 @@ TEST_F(NotificationDelegateTest, NullClickDelegate) {
TEST_F(NotificationDelegateTest, ButtonClickDelegate) { TEST_F(NotificationDelegateTest, ButtonClickDelegate) {
auto delegate = base::MakeRefCounted<HandleNotificationClickDelegate>( auto delegate = base::MakeRefCounted<HandleNotificationClickDelegate>(
base::Bind(&NotificationDelegateTest::ButtonClickCallback, base::BindRepeating(&NotificationDelegateTest::ButtonClickCallback,
base::Unretained(this))); base::Unretained(this)));
delegate->Click(base::nullopt, base::nullopt); delegate->Click(base::nullopt, base::nullopt);
EXPECT_EQ(1, callback_count_); EXPECT_EQ(1, callback_count_);
......
...@@ -25,8 +25,9 @@ class MESSAGE_CENTER_EXPORT MessageViewFactory { ...@@ -25,8 +25,9 @@ class MESSAGE_CENTER_EXPORT MessageViewFactory {
public: public:
// A function that creates MessageView for a NOTIFICATION_TYPE_CUSTOM // A function that creates MessageView for a NOTIFICATION_TYPE_CUSTOM
// notification. // notification.
typedef base::Callback<std::unique_ptr<MessageView>(const Notification&)> using CustomMessageViewFactoryFunction =
CustomMessageViewFactoryFunction; base::RepeatingCallback<std::unique_ptr<MessageView>(
const Notification&)>;
static MessageView* Create(const Notification& notification); static MessageView* Create(const Notification& notification);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment