Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
ash: Fix regression where system tray clock wasn't updated.
Browse files Browse the repository at this point in the history
I suspect that I broke this in r134585.

BUG=126155
TEST=manual: clock is updated after UI job starts


Review URL: http://codereview.chromium.org/10352022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135265 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
derat@chromium.org committed May 4, 2012
1 parent f716c1d commit e20440e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions ash/system/date/date_view.cc
Expand Up @@ -60,10 +60,16 @@ BaseDateTimeView::~BaseDateTimeView() {

void BaseDateTimeView::UpdateText() {
base::Time now = base::Time::Now();
gfx::Size old_size = GetPreferredSize();
UpdateTextInternal(now);
SchedulePaint();
SetTimer(now);
}

BaseDateTimeView::BaseDateTimeView() {
SetTimer(base::Time::Now());
}

void BaseDateTimeView::SetTimer(const base::Time& now) {
// Try to set the timer to go off at the next change of the minute. We don't
// want to have the timer go off more than necessary since that will cause
// the CPU to wake up and consume power.
Expand All @@ -86,9 +92,6 @@ void BaseDateTimeView::UpdateText() {
this, &BaseDateTimeView::UpdateText);
}

BaseDateTimeView::BaseDateTimeView() {
}

void BaseDateTimeView::ChildPreferredSizeChanged(views::View* child) {
views::View::PreferredSizeChanged();
if (GetWidget())
Expand Down
6 changes: 5 additions & 1 deletion ash/system/date/date_view.h
Expand Up @@ -25,20 +25,24 @@ class BaseDateTimeView : public ActionableView {
public:
virtual ~BaseDateTimeView();

// Updates the displayed text for the current time.
// Updates the displayed text for the current time and calls SetTimer().
void UpdateText();

protected:
BaseDateTimeView();

private:
// Starts |timer_| to schedule the next update.
void SetTimer(const base::Time& now);

// Updates labels to display the current time.
virtual void UpdateTextInternal(const base::Time& now) = 0;

// Overridden from views::View.
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
virtual void OnLocaleChanged() OVERRIDE;

// Invokes UpdateText() when the displayed time should change.
base::OneShotTimer<BaseDateTimeView> timer_;

DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView);
Expand Down

0 comments on commit e20440e

Please sign in to comment.