Commit b342453f authored by tzik's avatar tzik Committed by Commit Bot

Replace base::Timer with behavior-specific timers in ash/ and chromeos/

This CL replaces base::Timer with its subclasses.
As base::Timer changes its behavior subject to its construction time
flags, that makes hard to see the actual timer behavior, especially
it's unclear when a timer is injected from other components.
Also, that OnceCallback support of base::Timer is hard to implement on
the dynamically determined invocation pattern.

Bug: 850247
Change-Id: Ic99f2456dbb1b477ebb8f320b6a472d5a0e4c6bf
Reviewed-on: https://chromium-review.googlesource.com/1128663
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573598}
parent 0be5a3a1
...@@ -105,10 +105,10 @@ void AutoclickControllerCommon::CancelAutoclick() { ...@@ -105,10 +105,10 @@ void AutoclickControllerCommon::CancelAutoclick() {
} }
void AutoclickControllerCommon::InitClickTimer() { void AutoclickControllerCommon::InitClickTimer() {
autoclick_timer_.reset(new base::Timer( autoclick_timer_.reset(new base::RetainingOneShotTimer(
FROM_HERE, delay_, base::Bind(&AutoclickControllerCommon::DoAutoclick, FROM_HERE, delay_,
base::Unretained(this)), base::Bind(&AutoclickControllerCommon::DoAutoclick,
false)); base::Unretained(this))));
} }
void AutoclickControllerCommon::DoAutoclick() { void AutoclickControllerCommon::DoAutoclick() {
......
...@@ -48,7 +48,7 @@ class AutoclickControllerCommon { ...@@ -48,7 +48,7 @@ class AutoclickControllerCommon {
base::TimeDelta delay_; base::TimeDelta delay_;
int mouse_event_flags_; int mouse_event_flags_;
std::unique_ptr<base::Timer> autoclick_timer_; std::unique_ptr<base::RetainingOneShotTimer> autoclick_timer_;
AutoclickControllerCommonDelegate* delegate_; AutoclickControllerCommonDelegate* delegate_;
views::Widget* widget_; views::Widget* widget_;
// The position in screen coordinates used to determine // The position in screen coordinates used to determine
......
...@@ -67,12 +67,11 @@ CursorView::CursorView(aura::Window* container, ...@@ -67,12 +67,11 @@ CursorView::CursorView(aura::Window* container,
{base::TaskPriority::USER_BLOCKING, {base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})),
new_location_(initial_location), new_location_(initial_location),
stationary_timer_(new base::Timer( stationary_timer_(
FROM_HERE, FROM_HERE,
base::TimeDelta::FromMilliseconds(kStationaryDelayMs), base::TimeDelta::FromMilliseconds(kStationaryDelayMs),
base::BindRepeating(&CursorView::StationaryOnPaintThread, base::BindRepeating(&CursorView::StationaryOnPaintThread,
base::Unretained(this)), base::Unretained(this))),
/*is_repeating=*/false)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(ui_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(ui_sequence_checker_);
...@@ -159,7 +158,7 @@ void CursorView::OnTimerTick() { ...@@ -159,7 +158,7 @@ void CursorView::OnTimerTick() {
// Restart stationary timer if pointer location changed. // Restart stationary timer if pointer location changed.
if (location_ != old_location) if (location_ != old_location)
stationary_timer_->Reset(); stationary_timer_.Reset();
base::TimeDelta interval = time_source_->Interval(); base::TimeDelta interval = time_source_->Interval();
// Compute velocity unless this is the first tick. // Compute velocity unless this is the first tick.
...@@ -255,7 +254,7 @@ void CursorView::OnTimerTick() { ...@@ -255,7 +254,7 @@ void CursorView::OnTimerTick() {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(update_surface_callback_, cursor_rect_, damage_rect, base::BindOnce(update_surface_callback_, cursor_rect_, damage_rect,
/*auto_refresh=*/stationary_timer_->IsRunning())); /*auto_refresh=*/stationary_timer_.IsRunning()));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -264,7 +263,7 @@ void CursorView::OnTimerTick() { ...@@ -264,7 +263,7 @@ void CursorView::OnTimerTick() {
void CursorView::StationaryOnPaintThread() { void CursorView::StationaryOnPaintThread() {
DCHECK_CALLED_ON_VALID_SEQUENCE(paint_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(paint_sequence_checker_);
stationary_timer_->Stop(); stationary_timer_.Stop();
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, base::BindOnce(update_surface_callback_, cursor_rect_, FROM_HERE, base::BindOnce(update_surface_callback_, cursor_rect_,
/*damage_rect=*/gfx::Rect(), /*damage_rect=*/gfx::Rect(),
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "ash/components/fast_ink/fast_ink_view.h" #include "ash/components/fast_ink/fast_ink_view.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/timer/timer.h"
#include "components/viz/common/frame_sinks/delay_based_time_source.h" #include "components/viz/common/frame_sinks/delay_based_time_source.h"
#include "ui/events/ozone/chromeos/cursor_controller.h" #include "ui/events/ozone/chromeos/cursor_controller.h"
...@@ -78,7 +79,7 @@ class CursorView : public fast_ink::FastInkView, ...@@ -78,7 +79,7 @@ class CursorView : public fast_ink::FastInkView,
SkMatrix motion_blur_matrix_; SkMatrix motion_blur_matrix_;
SkMatrix motion_blur_inverse_matrix_; SkMatrix motion_blur_inverse_matrix_;
std::unique_ptr<viz::DelayBasedTimeSource> time_source_; std::unique_ptr<viz::DelayBasedTimeSource> time_source_;
std::unique_ptr<base::Timer> stationary_timer_; base::RetainingOneShotTimer stationary_timer_;
base::RepeatingCallback<void(const gfx::Rect&, const gfx::Rect&, bool)> base::RepeatingCallback<void(const gfx::Rect&, const gfx::Rect&, bool)>
update_surface_callback_; update_surface_callback_;
SEQUENCE_CHECKER(paint_sequence_checker_); SEQUENCE_CHECKER(paint_sequence_checker_);
......
...@@ -164,12 +164,10 @@ LaserPointerView::LaserPointerView(base::TimeDelta life_duration, ...@@ -164,12 +164,10 @@ LaserPointerView::LaserPointerView(base::TimeDelta life_duration,
laser_points_(life_duration), laser_points_(life_duration),
predicted_laser_points_(life_duration), predicted_laser_points_(life_duration),
presentation_delay_(presentation_delay), presentation_delay_(presentation_delay),
stationary_timer_( stationary_timer_(FROM_HERE,
new base::Timer(FROM_HERE, stationary_point_delay,
stationary_point_delay, base::BindRepeating(&LaserPointerView::UpdateTime,
base::BindRepeating(&LaserPointerView::UpdateTime, base::Unretained(this))),
base::Unretained(this)),
/*is_repeating=*/true)),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
LaserPointerView::~LaserPointerView() = default; LaserPointerView::~LaserPointerView() = default;
...@@ -186,7 +184,7 @@ void LaserPointerView::AddNewPoint(const gfx::PointF& new_point, ...@@ -186,7 +184,7 @@ void LaserPointerView::AddNewPoint(const gfx::PointF& new_point,
: 0); : 0);
AddPoint(new_point, new_time); AddPoint(new_point, new_time);
stationary_point_location_ = new_point; stationary_point_location_ = new_point;
stationary_timer_->Reset(); stationary_timer_.Reset();
} }
void LaserPointerView::FadeOut(base::OnceClosure done) { void LaserPointerView::FadeOut(base::OnceClosure done) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "ash/components/fast_ink/fast_ink_points.h" #include "ash/components/fast_ink/fast_ink_points.h"
#include "ash/components/fast_ink/fast_ink_view.h" #include "ash/components/fast_ink/fast_ink_view.h"
#include "base/timer/timer.h"
namespace ash { namespace ash {
...@@ -42,7 +43,7 @@ class LaserPointerView : public fast_ink::FastInkView { ...@@ -42,7 +43,7 @@ class LaserPointerView : public fast_ink::FastInkView {
const base::TimeDelta presentation_delay_; const base::TimeDelta presentation_delay_;
// Timer which will add a new stationary point when the stylus stops moving. // Timer which will add a new stationary point when the stylus stops moving.
// This will remove points that are too old. // This will remove points that are too old.
std::unique_ptr<base::Timer> stationary_timer_; base::RepeatingTimer stationary_timer_;
gfx::PointF stationary_point_location_; gfx::PointF stationary_point_location_;
// A callback for when the fadeout is complete. // A callback for when the fadeout is complete.
base::OnceClosure fadeout_done_; base::OnceClosure fadeout_done_;
......
...@@ -249,8 +249,8 @@ class LoginPinView::BackspacePinButton : public BasePinButton { ...@@ -249,8 +249,8 @@ class LoginPinView::BackspacePinButton : public BasePinButton {
~BackspacePinButton() override = default; ~BackspacePinButton() override = default;
void SetTimersForTesting(std::unique_ptr<base::Timer> delay_timer, void SetTimersForTesting(std::unique_ptr<base::OneShotTimer> delay_timer,
std::unique_ptr<base::Timer> repeat_timer) { std::unique_ptr<base::RepeatingTimer> repeat_timer) {
delay_timer_ = std::move(delay_timer); delay_timer_ = std::move(delay_timer);
repeat_timer_ = std::move(repeat_timer); repeat_timer_ = std::move(repeat_timer);
} }
...@@ -341,8 +341,8 @@ class LoginPinView::BackspacePinButton : public BasePinButton { ...@@ -341,8 +341,8 @@ class LoginPinView::BackspacePinButton : public BasePinButton {
} }
bool is_held_ = false; bool is_held_ = false;
std::unique_ptr<base::Timer> delay_timer_; std::unique_ptr<base::OneShotTimer> delay_timer_;
std::unique_ptr<base::Timer> repeat_timer_; std::unique_ptr<base::RepeatingTimer> repeat_timer_;
views::ImageView* image_ = nullptr; views::ImageView* image_ = nullptr;
...@@ -362,8 +362,8 @@ views::View* LoginPinView::TestApi::GetBackspaceButton() const { ...@@ -362,8 +362,8 @@ views::View* LoginPinView::TestApi::GetBackspaceButton() const {
} }
void LoginPinView::TestApi::SetBackspaceTimers( void LoginPinView::TestApi::SetBackspaceTimers(
std::unique_ptr<base::Timer> delay_timer, std::unique_ptr<base::OneShotTimer> delay_timer,
std::unique_ptr<base::Timer> repeat_timer) { std::unique_ptr<base::RepeatingTimer> repeat_timer) {
view_->backspace_->SetTimersForTesting(std::move(delay_timer), view_->backspace_->SetTimersForTesting(std::move(delay_timer),
std::move(repeat_timer)); std::move(repeat_timer));
} }
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include "ui/views/view.h" #include "ui/views/view.h"
namespace base { namespace base {
class Timer; class OneShotTimer;
class RepeatingTimer;
} // namespace base } // namespace base
namespace ash { namespace ash {
...@@ -58,8 +59,8 @@ class ASH_EXPORT LoginPinView : public NonAccessibleView { ...@@ -58,8 +59,8 @@ class ASH_EXPORT LoginPinView : public NonAccessibleView {
// Sets the timers that are used for backspace auto-submit. |delay_timer| is // Sets the timers that are used for backspace auto-submit. |delay_timer| is
// the initial delay before an auto-submit, and |repeat_timer| fires // the initial delay before an auto-submit, and |repeat_timer| fires
// whenever a new backspace event should run after the initial delay. // whenever a new backspace event should run after the initial delay.
void SetBackspaceTimers(std::unique_ptr<base::Timer> delay_timer, void SetBackspaceTimers(std::unique_ptr<base::OneShotTimer> delay_timer,
std::unique_ptr<base::Timer> repeat_timer); std::unique_ptr<base::RepeatingTimer> repeat_timer);
private: private:
LoginPinView* const view_; LoginPinView* const view_;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "chromeos/network/network_state_handler_observer.h" #include "chromeos/network/network_state_handler_observer.h"
namespace base { namespace base {
class Timer; class OneShotTimer;
} }
namespace ash { namespace ash {
...@@ -41,7 +41,7 @@ class ASH_EXPORT AutoConnectNotifier ...@@ -41,7 +41,7 @@ class ASH_EXPORT AutoConnectNotifier
// chromeos::AutoConnectHandler::Observer: // chromeos::AutoConnectHandler::Observer:
void OnAutoConnectedInitiated(int auto_connect_reasons) override; void OnAutoConnectedInitiated(int auto_connect_reasons) override;
void set_timer_for_testing(std::unique_ptr<base::Timer> test_timer) { void set_timer_for_testing(std::unique_ptr<base::OneShotTimer> test_timer) {
timer_ = std::move(test_timer); timer_ = std::move(test_timer);
} }
...@@ -51,7 +51,7 @@ class ASH_EXPORT AutoConnectNotifier ...@@ -51,7 +51,7 @@ class ASH_EXPORT AutoConnectNotifier
void DisplayNotification(); void DisplayNotification();
bool has_user_explicitly_requested_connection_ = false; bool has_user_explicitly_requested_connection_ = false;
std::unique_ptr<base::Timer> timer_; std::unique_ptr<base::OneShotTimer> timer_;
DISALLOW_COPY_AND_ASSIGN(AutoConnectNotifier); DISALLOW_COPY_AND_ASSIGN(AutoConnectNotifier);
}; };
......
...@@ -119,8 +119,7 @@ class LogoutConfirmationController::LastWindowClosedObserver ...@@ -119,8 +119,7 @@ class LogoutConfirmationController::LastWindowClosedObserver
LogoutConfirmationController::LogoutConfirmationController() LogoutConfirmationController::LogoutConfirmationController()
: clock_(base::DefaultTickClock::GetInstance()), : clock_(base::DefaultTickClock::GetInstance()),
logout_closure_(base::Bind(&SignOut)), logout_closure_(base::Bind(&SignOut)) {
logout_timer_(false, false) {
if (Shell::HasInstance()) // Null in testing::Test. if (Shell::HasInstance()) // Null in testing::Test.
Shell::Get()->session_controller()->AddObserver(this); Shell::Get()->session_controller()->AddObserver(this);
} }
......
...@@ -70,7 +70,7 @@ class ASH_EXPORT LogoutConfirmationController : public SessionObserver { ...@@ -70,7 +70,7 @@ class ASH_EXPORT LogoutConfirmationController : public SessionObserver {
base::TimeTicks logout_time_; base::TimeTicks logout_time_;
LogoutConfirmationDialog* dialog_ = nullptr; // Owned by the Views hierarchy. LogoutConfirmationDialog* dialog_ = nullptr; // Owned by the Views hierarchy.
base::Timer logout_timer_; base::OneShotTimer logout_timer_;
DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController); DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController);
}; };
......
...@@ -62,12 +62,11 @@ void HighlighterControllerClient::ConnectToHighlighterController() { ...@@ -62,12 +62,11 @@ void HighlighterControllerClient::ConnectToHighlighterController() {
void HighlighterControllerClient::HandleSelection(const gfx::Rect& rect) { void HighlighterControllerClient::HandleSelection(const gfx::Rect& rect) {
// Delay the actual voice interaction service invocation for better // Delay the actual voice interaction service invocation for better
// visual synchronization with the metalayer animation. // visual synchronization with the metalayer animation.
delay_timer_ = std::make_unique<base::Timer>( delay_timer_ = std::make_unique<base::OneShotTimer>();
delay_timer_->Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(kSelectionReportDelayMs), FROM_HERE, base::TimeDelta::FromMilliseconds(kSelectionReportDelayMs),
base::Bind(&HighlighterControllerClient::ReportSelection, base::Bind(&HighlighterControllerClient::ReportSelection,
base::Unretained(this), rect), base::Unretained(this), rect));
false /* is_repeating */);
delay_timer_->Reset();
} }
void HighlighterControllerClient::HandleEnabledStateChange(bool enabled) { void HighlighterControllerClient::HandleEnabledStateChange(bool enabled) {
......
...@@ -16,7 +16,7 @@ class Rect; ...@@ -16,7 +16,7 @@ class Rect;
} // namespace gfx } // namespace gfx
namespace base { namespace base {
class Timer; class OneShotTimer;
} // namespace base } // namespace base
namespace service_manager { namespace service_manager {
...@@ -73,7 +73,7 @@ class HighlighterControllerClient ...@@ -73,7 +73,7 @@ class HighlighterControllerClient
ArcVoiceInteractionFrameworkService* service_; ArcVoiceInteractionFrameworkService* service_;
std::unique_ptr<base::Timer> delay_timer_; std::unique_ptr<base::OneShotTimer> delay_timer_;
DISALLOW_COPY_AND_ASSIGN(HighlighterControllerClient); DISALLOW_COPY_AND_ASSIGN(HighlighterControllerClient);
}; };
......
...@@ -262,8 +262,7 @@ void PlatformVerificationFlow::OnAttestationPrepared( ...@@ -262,8 +262,7 @@ void PlatformVerificationFlow::OnAttestationPrepared(
void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context,
const AccountId& account_id, const AccountId& account_id,
bool force_new_key) { bool force_new_key) {
std::unique_ptr<base::Timer> timer(new base::Timer(false, // Don't retain. std::unique_ptr<base::OneShotTimer> timer(new base::OneShotTimer());
false)); // Don't repeat.
base::Closure timeout_callback = base::Bind( base::Closure timeout_callback = base::Bind(
&PlatformVerificationFlow::OnCertificateTimeout, &PlatformVerificationFlow::OnCertificateTimeout,
this, this,
...@@ -281,7 +280,7 @@ void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, ...@@ -281,7 +280,7 @@ void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context,
void PlatformVerificationFlow::OnCertificateReady( void PlatformVerificationFlow::OnCertificateReady(
const ChallengeContext& context, const ChallengeContext& context,
const AccountId& account_id, const AccountId& account_id,
std::unique_ptr<base::Timer> timer, std::unique_ptr<base::OneShotTimer> timer,
AttestationStatus operation_status, AttestationStatus operation_status,
const std::string& certificate_chain) { const std::string& certificate_chain) {
// Log failure before checking the timer so all failures are logged, even if // Log failure before checking the timer so all failures are logged, even if
......
...@@ -199,7 +199,7 @@ class PlatformVerificationFlow ...@@ -199,7 +199,7 @@ class PlatformVerificationFlow
// not invoked. // not invoked.
void OnCertificateReady(const ChallengeContext& context, void OnCertificateReady(const ChallengeContext& context,
const AccountId& account_id, const AccountId& account_id,
std::unique_ptr<base::Timer> timer, std::unique_ptr<base::OneShotTimer> timer,
AttestationStatus operation_status, AttestationStatus operation_status,
const std::string& certificate_chain); const std::string& certificate_chain);
......
...@@ -24,12 +24,12 @@ const int kGetCertificatesTimeoutInMinutes = 5; ...@@ -24,12 +24,12 @@ const int kGetCertificatesTimeoutInMinutes = 5;
// Holds state for a single certificate request. // Holds state for a single certificate request.
struct CertificateRequests::CertificateRequestState { struct CertificateRequests::CertificateRequestState {
CertificateRequestState() : timeout(false, false) {} CertificateRequestState() {}
~CertificateRequestState() {} ~CertificateRequestState() {}
// Extensions that are too slow are eventually dropped from a request. // Extensions that are too slow are eventually dropped from a request.
base::Timer timeout; base::OneShotTimer timeout;
// Extensions that this request is still waiting for. // Extensions that this request is still waiting for.
std::set<std::string> pending_extensions; std::set<std::string> pending_extensions;
......
...@@ -212,11 +212,10 @@ void UserImageScreen::Show() { ...@@ -212,11 +212,10 @@ void UserImageScreen::Show() {
return; return;
} }
sync_observer->AddObserver(this); sync_observer->AddObserver(this);
sync_timer_.reset(new base::Timer( sync_timer_.reset(new base::OneShotTimer());
sync_timer_->Start(
FROM_HERE, base::TimeDelta::FromSeconds(kSyncTimeoutSeconds), FROM_HERE, base::TimeDelta::FromSeconds(kSyncTimeoutSeconds),
base::Bind(&UserImageScreen::OnSyncTimeout, base::Unretained(this)), base::Bind(&UserImageScreen::OnSyncTimeout, base::Unretained(this)));
false));
sync_timer_->Reset();
} }
} }
CameraPresenceNotifier::GetInstance()->AddObserver(this); CameraPresenceNotifier::GetInstance()->AddObserver(this);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
namespace base { namespace base {
class Timer; class OneShotTimer;
class Value; class Value;
} // namespace base } // namespace base
...@@ -148,7 +148,7 @@ class UserImageScreen : public BaseScreen, ...@@ -148,7 +148,7 @@ class UserImageScreen : public BaseScreen,
bool user_has_selected_image_ = false; bool user_has_selected_image_ = false;
// Timer used for waiting for user image sync. // Timer used for waiting for user image sync.
std::unique_ptr<base::Timer> sync_timer_; std::unique_ptr<base::OneShotTimer> sync_timer_;
// The time when we started wait for user image sync. // The time when we started wait for user image sync.
base::Time sync_waiting_start_time_; base::Time sync_waiting_start_time_;
......
...@@ -62,7 +62,7 @@ constexpr size_t kTasksSize = arraysize(kTestTasks); ...@@ -62,7 +62,7 @@ constexpr size_t kTasksSize = arraysize(kTestTasks);
class DummyTaskManager : public task_manager::TestTaskManager { class DummyTaskManager : public task_manager::TestTaskManager {
public: public:
DummyTaskManager() { DummyTaskManager() {
set_timer_for_testing(std::make_unique<base::MockOneShotTimer>()); set_timer_for_testing(std::make_unique<base::MockRepeatingTimer>());
} }
~DummyTaskManager() override {} ~DummyTaskManager() override {}
......
...@@ -679,7 +679,7 @@ bool TetherService::HandleFeatureStateMetricIfUninitialized() { ...@@ -679,7 +679,7 @@ bool TetherService::HandleFeatureStateMetricIfUninitialized() {
void TetherService::SetTestDoubles( void TetherService::SetTestDoubles(
std::unique_ptr<chromeos::tether::NotificationPresenter> std::unique_ptr<chromeos::tether::NotificationPresenter>
notification_presenter, notification_presenter,
std::unique_ptr<base::Timer> timer) { std::unique_ptr<base::OneShotTimer> timer) {
notification_presenter_ = std::move(notification_presenter); notification_presenter_ = std::move(notification_presenter);
timer_ = std::move(timer); timer_ = std::move(timer);
} }
...@@ -238,7 +238,7 @@ class TetherService : public KeyedService, ...@@ -238,7 +238,7 @@ class TetherService : public KeyedService,
void SetTestDoubles(std::unique_ptr<chromeos::tether::NotificationPresenter> void SetTestDoubles(std::unique_ptr<chromeos::tether::NotificationPresenter>
notification_presenter, notification_presenter,
std::unique_ptr<base::Timer> timer); std::unique_ptr<base::OneShotTimer> timer);
// Whether the service has been shut down. // Whether the service has been shut down.
bool shut_down_ = false; bool shut_down_ = false;
...@@ -283,7 +283,7 @@ class TetherService : public KeyedService, ...@@ -283,7 +283,7 @@ class TetherService : public KeyedService,
PrefChangeRegistrar registrar_; PrefChangeRegistrar registrar_;
scoped_refptr<device::BluetoothAdapter> adapter_; scoped_refptr<device::BluetoothAdapter> adapter_;
std::unique_ptr<base::Timer> timer_; std::unique_ptr<base::OneShotTimer> timer_;
base::WeakPtrFactory<TetherService> weak_ptr_factory_; base::WeakPtrFactory<TetherService> weak_ptr_factory_;
......
...@@ -96,12 +96,11 @@ UserSwitchAnimatorChromeOS::UserSwitchAnimatorChromeOS( ...@@ -96,12 +96,11 @@ UserSwitchAnimatorChromeOS::UserSwitchAnimatorChromeOS(
if (!animation_speed_ms_) { if (!animation_speed_ms_) {
FinalizeAnimation(); FinalizeAnimation();
} else { } else {
user_changed_animation_timer_.reset(new base::Timer( user_changed_animation_timer_.reset(new base::RepeatingTimer());
user_changed_animation_timer_->Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(animation_speed_ms_), FROM_HERE, base::TimeDelta::FromMilliseconds(animation_speed_ms_),
base::Bind(&UserSwitchAnimatorChromeOS::AdvanceUserTransitionAnimation, base::Bind(&UserSwitchAnimatorChromeOS::AdvanceUserTransitionAnimation,
base::Unretained(this)), base::Unretained(this)));
true));
user_changed_animation_timer_->Reset();
} }
} }
......
...@@ -112,7 +112,7 @@ class UserSwitchAnimatorChromeOS { ...@@ -112,7 +112,7 @@ class UserSwitchAnimatorChromeOS {
// A timer which watches to executes the second part of a "user changed" // A timer which watches to executes the second part of a "user changed"
// animation. Note that this timer exists only during such an animation. // animation. Note that this timer exists only during such an animation.
std::unique_ptr<base::Timer> user_changed_animation_timer_; std::unique_ptr<base::RepeatingTimer> user_changed_animation_timer_;
// For unit tests: Check which wallpaper was set. // For unit tests: Check which wallpaper was set.
std::string wallpaper_user_id_for_test_; std::string wallpaper_user_id_for_test_;
......
...@@ -85,7 +85,6 @@ TabScrubber::TabScrubber() ...@@ -85,7 +85,6 @@ TabScrubber::TabScrubber()
swipe_y_(-1), swipe_y_(-1),
swipe_direction_(LEFT), swipe_direction_(LEFT),
highlighted_tab_(-1), highlighted_tab_(-1),
activate_timer_(true, false),
activation_delay_(kActivationDelayMS), activation_delay_(kActivationDelayMS),
use_default_activation_delay_(true), use_default_activation_delay_(true),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
......
...@@ -96,7 +96,7 @@ class TabScrubber : public ui::EventHandler, ...@@ -96,7 +96,7 @@ class TabScrubber : public ui::EventHandler,
// The index of the tab that is currently highlighted. // The index of the tab that is currently highlighted.
int highlighted_tab_; int highlighted_tab_;
// Timer to control a delayed activation of the |highlighted_tab_|. // Timer to control a delayed activation of the |highlighted_tab_|.
base::Timer activate_timer_; base::RetainingOneShotTimer activate_timer_;
// Time to wait in ms before newly selected tab becomes active. // Time to wait in ms before newly selected tab becomes active.
int activation_delay_; int activation_delay_;
// Set if activation_delay had been explicitly set. // Set if activation_delay had been explicitly set.
......
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