Permalink
Browse files

ash: Fix regression where system tray clock wasn't updated.

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
derat@chromium.org committed May 4, 2012
1 parent f716c1d commit e20440e3b4fb6095680d9103a5b6824a35ae995e
Showing with 12 additions and 5 deletions.
  1. +7 −4 ash/system/date/date_view.cc
  2. +5 −1 ash/system/date/date_view.h
@@ -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.
@@ -86,9 +92,6 @@ void BaseDateTimeView::UpdateText() {
this, &BaseDateTimeView::UpdateText);
}
-BaseDateTimeView::BaseDateTimeView() {
-}
-
void BaseDateTimeView::ChildPreferredSizeChanged(views::View* child) {
views::View::PreferredSizeChanged();
if (GetWidget())
@@ -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);

0 comments on commit e20440e

Please sign in to comment.