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

Side by Side Diff: ash/system/chromeos/session/tray_session_length_limit.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: fixcaller Created 5 years, 3 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
« no previous file with comments | « ash/system/chromeos/session/tray_session_length_limit.h ('k') | ash/system/date/date_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/system/chromeos/session/tray_session_length_limit.h" 5 #include "ash/system/chromeos/session/tray_session_length_limit.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/chromeos/label_tray_view.h" 10 #include "ash/system/chromeos/label_tray_view.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (delegate->GetSessionStartTime(&session_start_time_) && 94 if (delegate->GetSessionStartTime(&session_start_time_) &&
95 delegate->GetSessionLengthLimit(&time_limit_)) { 95 delegate->GetSessionLengthLimit(&time_limit_)) {
96 const base::TimeDelta expiring_soon_threshold( 96 const base::TimeDelta expiring_soon_threshold(
97 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); 97 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes));
98 remaining_session_time_ = std::max( 98 remaining_session_time_ = std::max(
99 time_limit_ - (base::TimeTicks::Now() - session_start_time_), 99 time_limit_ - (base::TimeTicks::Now() - session_start_time_),
100 base::TimeDelta()); 100 base::TimeDelta());
101 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ? 101 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ?
102 LIMIT_EXPIRING_SOON : LIMIT_SET; 102 LIMIT_EXPIRING_SOON : LIMIT_SET;
103 if (!timer_) 103 if (!timer_)
104 timer_.reset(new base::RepeatingTimer<TraySessionLengthLimit>); 104 timer_.reset(new base::RepeatingTimer);
105 if (!timer_->IsRunning()) { 105 if (!timer_->IsRunning()) {
106 timer_->Start(FROM_HERE, 106 timer_->Start(FROM_HERE,
107 base::TimeDelta::FromMilliseconds( 107 base::TimeDelta::FromMilliseconds(
108 kTimerIntervalInMilliseconds), 108 kTimerIntervalInMilliseconds),
109 this, 109 this,
110 &TraySessionLengthLimit::Update); 110 &TraySessionLengthLimit::Update);
111 } 111 }
112 } else { 112 } else {
113 remaining_session_time_ = base::TimeDelta(); 113 remaining_session_time_ = base::TimeDelta();
114 limit_state_ = LIMIT_NONE; 114 limit_state_ = LIMIT_NONE;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { 189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const {
190 return l10n_util::GetStringFUTF16( 190 return l10n_util::GetStringFUTF16(
191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, 191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT,
192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, 192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION,
193 ui::TimeFormat::LENGTH_LONG, 193 ui::TimeFormat::LENGTH_LONG,
194 10, 194 10,
195 remaining_session_time_)); 195 remaining_session_time_));
196 } 196 }
197 197
198 } // namespace ash 198 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/session/tray_session_length_limit.h ('k') | ash/system/date/date_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698