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

Unified Diff: chrome/browser/policy/device_status_collector.cc

Issue 11271024: Fix DeviceStatusCollectorTest.MaxStoredPeriods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/device_status_collector.cc
diff --git a/chrome/browser/policy/device_status_collector.cc b/chrome/browser/policy/device_status_collector.cc
index 4505c5546a1af6816a6d0c9b242be129c0476d7a..151b1c59b17e143ec622fd56791a2ca63b4e3dc5 100644
--- a/chrome/browser/policy/device_status_collector.cc
+++ b/chrome/browser/policy/device_status_collector.cc
@@ -93,7 +93,18 @@ DeviceStatusCollector::DeviceStatusCollector(
report_version_info_(false),
report_activity_times_(false),
report_boot_mode_(false),
- report_location_(false) {
+ report_location_(false) {}
+
+DeviceStatusCollector::~DeviceStatusCollector() {
+ cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceVersionInfo,
+ this);
+ cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceActivityTimes,
+ this);
+ cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceBootMode, this);
+ cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceLocation, this);
+}
+
+void DeviceStatusCollector::Init() {
if (!location_update_requester_)
location_update_requester_ = &content::RequestLocationUpdate;
idle_poll_timer_.Start(FROM_HERE,
@@ -144,15 +155,6 @@ DeviceStatusCollector::DeviceStatusCollector(
&tracker_);
}
-DeviceStatusCollector::~DeviceStatusCollector() {
- cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceVersionInfo,
- this);
- cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceActivityTimes,
- this);
- cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceBootMode, this);
- cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceLocation, this);
-}
-
// static
void DeviceStatusCollector::RegisterPrefs(PrefService* local_state) {
local_state->RegisterDictionaryPref(prefs::kDeviceActivityTimes,
@@ -269,11 +271,12 @@ void DeviceStatusCollector::IdleStateCallback(IdleState state) {
// interval of activity.
int active_seconds = (now - last_idle_check_).InSeconds();
if (active_seconds < 0 ||
- active_seconds >= static_cast<int>((2 * kIdlePollIntervalSeconds)))
+ active_seconds >= static_cast<int>((2 * kIdlePollIntervalSeconds))) {
AddActivePeriod(now - TimeDelta::FromSeconds(kIdlePollIntervalSeconds),
now);
- else
+ } else {
AddActivePeriod(last_idle_check_, now);
+ }
PruneStoredActivityPeriods(now);
}
@@ -390,7 +393,7 @@ void DeviceStatusCollector::ScheduleGeolocationUpdateRequest() {
return;
if (position_.Validate()) {
- TimeDelta elapsed = Time::Now() - position_.timestamp;
+ TimeDelta elapsed = GetCurrentTime() - position_.timestamp;
jar (doing other things) 2012/11/16 20:29:23 The old code used Time::Now(), which is not a mono
Ryan Sleevi 2012/11/16 22:20:48 I have to agree with Jim here. I think conflating
Joao da Silva 2012/11/20 09:10:52 It's the same; GetCurrentTime() is a virtual that
TimeDelta interval =
TimeDelta::FromSeconds(kGeolocationPollIntervalSeconds);
if (elapsed > interval) {

Powered by Google App Engine
This is Rietveld 408576698