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

Side by Side Diff: ui/message_center/message_center_impl.cc

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: . Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/message_center/message_center_impl.h" 5 #include "ui/message_center/message_center_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 //////////////////////////////////////////////////////////////////////////////// 334 ////////////////////////////////////////////////////////////////////////////////
335 // PopupTimer 335 // PopupTimer
336 336
337 PopupTimer::PopupTimer(const std::string& id, 337 PopupTimer::PopupTimer(const std::string& id,
338 base::TimeDelta timeout, 338 base::TimeDelta timeout,
339 base::WeakPtr<PopupTimersController> controller) 339 base::WeakPtr<PopupTimersController> controller)
340 : id_(id), 340 : id_(id),
341 timeout_(timeout), 341 timeout_(timeout),
342 timer_controller_(controller), 342 timer_controller_(controller),
343 timer_(new base::OneShotTimer<PopupTimersController>) {} 343 timer_(new base::OneShotTimer) {}
344 344
345 PopupTimer::~PopupTimer() { 345 PopupTimer::~PopupTimer() {
346 if (!timer_) 346 if (!timer_)
347 return; 347 return;
348 348
349 if (timer_->IsRunning()) 349 if (timer_->IsRunning())
350 timer_->Stop(); 350 timer_->Stop();
351 } 351 }
352 352
353 void PopupTimer::Start() { 353 void PopupTimer::Start() {
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 const base::TimeDelta& expires_in) { 971 const base::TimeDelta& expires_in) {
972 if (quiet_mode_timer_) { 972 if (quiet_mode_timer_) {
973 // Note that the capital Reset() is the method to restart the timer, not 973 // Note that the capital Reset() is the method to restart the timer, not
974 // scoped_ptr::reset(). 974 // scoped_ptr::reset().
975 quiet_mode_timer_->Reset(); 975 quiet_mode_timer_->Reset();
976 } else { 976 } else {
977 notification_list_->SetQuietMode(true); 977 notification_list_->SetQuietMode(true);
978 FOR_EACH_OBSERVER( 978 FOR_EACH_OBSERVER(
979 MessageCenterObserver, observer_list_, OnQuietModeChanged(true)); 979 MessageCenterObserver, observer_list_, OnQuietModeChanged(true));
980 980
981 quiet_mode_timer_.reset(new base::OneShotTimer<MessageCenterImpl>); 981 quiet_mode_timer_.reset(new base::OneShotTimer);
982 quiet_mode_timer_->Start( 982 quiet_mode_timer_->Start(
983 FROM_HERE, 983 FROM_HERE,
984 expires_in, 984 expires_in,
985 base::Bind( 985 base::Bind(
986 &MessageCenterImpl::SetQuietMode, base::Unretained(this), false)); 986 &MessageCenterImpl::SetQuietMode, base::Unretained(this), false));
987 } 987 }
988 } 988 }
989 989
990 void MessageCenterImpl::RestartPopupTimers() { 990 void MessageCenterImpl::RestartPopupTimers() {
991 if (popup_timers_controller_) 991 if (popup_timers_controller_)
992 popup_timers_controller_->StartAll(); 992 popup_timers_controller_->StartAll();
993 } 993 }
994 994
995 void MessageCenterImpl::PausePopupTimers() { 995 void MessageCenterImpl::PausePopupTimers() {
996 if (popup_timers_controller_) 996 if (popup_timers_controller_)
997 popup_timers_controller_->PauseAll(); 997 popup_timers_controller_->PauseAll();
998 } 998 }
999 999
1000 void MessageCenterImpl::DisableTimersForTest() { 1000 void MessageCenterImpl::DisableTimersForTest() {
1001 popup_timers_controller_.reset(); 1001 popup_timers_controller_.reset();
1002 } 1002 }
1003 1003
1004 } // namespace message_center 1004 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698