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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/policy/device_status_collector.h" 5 #include "chrome/browser/policy/device_status_collector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 UpdateReportingSettings(); 385 UpdateReportingSettings();
386 else 386 else
387 NOTREACHED(); 387 NOTREACHED();
388 } 388 }
389 389
390 void DeviceStatusCollector::ScheduleGeolocationUpdateRequest() { 390 void DeviceStatusCollector::ScheduleGeolocationUpdateRequest() {
391 if (geolocation_update_timer_.IsRunning() || geolocation_update_in_progress_) 391 if (geolocation_update_timer_.IsRunning() || geolocation_update_in_progress_)
392 return; 392 return;
393 393
394 if (position_.Validate()) { 394 if (position_.Validate()) {
395 TimeDelta elapsed = Time::Now() - position_.timestamp; 395 TimeDelta elapsed = GetCurrentTime() - position_.timestamp;
396 TimeDelta interval = 396 TimeDelta interval =
397 TimeDelta::FromSeconds(kGeolocationPollIntervalSeconds); 397 TimeDelta::FromSeconds(kGeolocationPollIntervalSeconds);
398 if (elapsed > interval) { 398 if (elapsed > interval) {
399 geolocation_update_in_progress_ = true; 399 geolocation_update_in_progress_ = true;
400 location_update_requester_(base::Bind( 400 location_update_requester_(base::Bind(
401 &DeviceStatusCollector::ReceiveGeolocationUpdate, 401 &DeviceStatusCollector::ReceiveGeolocationUpdate,
402 weak_factory_.GetWeakPtr())); 402 weak_factory_.GetWeakPtr()));
403 } else { 403 } else {
404 geolocation_update_timer_.Start( 404 geolocation_update_timer_.Start(
405 FROM_HERE, 405 FROM_HERE,
(...skipping 30 matching lines...) Expand all
436 location.SetDouble(kSpeed, position.speed); 436 location.SetDouble(kSpeed, position.speed);
437 location.SetString(kTimestamp, 437 location.SetString(kTimestamp,
438 base::Int64ToString(position.timestamp.ToInternalValue())); 438 base::Int64ToString(position.timestamp.ToInternalValue()));
439 local_state_->Set(prefs::kDeviceLocation, location); 439 local_state_->Set(prefs::kDeviceLocation, location);
440 } 440 }
441 441
442 ScheduleGeolocationUpdateRequest(); 442 ScheduleGeolocationUpdateRequest();
443 } 443 }
444 444
445 } // namespace policy 445 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698