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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 1008333002: Move time constants to base::Time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments#3 Created 5 years, 9 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 | « base/time/time.h ('k') | chrome/browser/ui/webui/options/clear_browser_data_handler.cc » ('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 (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/chromeos/policy/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <limits> 8 #include <limits>
9 #include <sys/statvfs.h> 9 #include <sys/statvfs.h>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // How many days in the future to store active periods for. 64 // How many days in the future to store active periods for.
65 const unsigned int kMaxStoredFutureActivityDays = 2; 65 const unsigned int kMaxStoredFutureActivityDays = 2;
66 66
67 // How often, in seconds, to update the device location. 67 // How often, in seconds, to update the device location.
68 const unsigned int kGeolocationPollIntervalSeconds = 30 * 60; 68 const unsigned int kGeolocationPollIntervalSeconds = 30 * 60;
69 69
70 // How often, in seconds, to sample the hardware state. 70 // How often, in seconds, to sample the hardware state.
71 static const unsigned int kHardwareStatusSampleIntervalSeconds = 120; 71 static const unsigned int kHardwareStatusSampleIntervalSeconds = 120;
72 72
73 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000;
74
75 // Keys for the geolocation status dictionary in local state. 73 // Keys for the geolocation status dictionary in local state.
76 const char kLatitude[] = "latitude"; 74 const char kLatitude[] = "latitude";
77 const char kLongitude[] = "longitude"; 75 const char kLongitude[] = "longitude";
78 const char kAltitude[] = "altitude"; 76 const char kAltitude[] = "altitude";
79 const char kAccuracy[] = "accuracy"; 77 const char kAccuracy[] = "accuracy";
80 const char kAltitudeAccuracy[] = "altitude_accuracy"; 78 const char kAltitudeAccuracy[] = "altitude_accuracy";
81 const char kHeading[] = "heading"; 79 const char kHeading[] = "heading";
82 const char kSpeed[] = "speed"; 80 const char kSpeed[] = "speed";
83 const char kTimestamp[] = "timestamp"; 81 const char kTimestamp[] = "timestamp";
84 82
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 base::DictionaryValue* activity_times = update.Get(); 509 base::DictionaryValue* activity_times = update.Get();
512 510
513 for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd(); 511 for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd();
514 it.Advance()) { 512 it.Advance()) {
515 int64 start_timestamp; 513 int64 start_timestamp;
516 int activity_milliseconds; 514 int activity_milliseconds;
517 if (base::StringToInt64(it.key(), &start_timestamp) && 515 if (base::StringToInt64(it.key(), &start_timestamp) &&
518 it.value().GetAsInteger(&activity_milliseconds)) { 516 it.value().GetAsInteger(&activity_milliseconds)) {
519 // This is correct even when there are leap seconds, because when a leap 517 // This is correct even when there are leap seconds, because when a leap
520 // second occurs, two consecutive seconds have the same timestamp. 518 // second occurs, two consecutive seconds have the same timestamp.
521 int64 end_timestamp = start_timestamp + kMillisecondsPerDay; 519 int64 end_timestamp = start_timestamp + Time::kMillisecondsPerDay;
522 520
523 em::ActiveTimePeriod* active_period = request->add_active_period(); 521 em::ActiveTimePeriod* active_period = request->add_active_period();
524 em::TimePeriod* period = active_period->mutable_time_period(); 522 em::TimePeriod* period = active_period->mutable_time_period();
525 period->set_start_timestamp(start_timestamp); 523 period->set_start_timestamp(start_timestamp);
526 period->set_end_timestamp(end_timestamp); 524 period->set_end_timestamp(end_timestamp);
527 active_period->set_active_duration(activity_milliseconds); 525 active_period->set_active_duration(activity_milliseconds);
528 if (start_timestamp >= last_reported_day_) { 526 if (start_timestamp >= last_reported_day_) {
529 last_reported_day_ = start_timestamp; 527 last_reported_day_ = start_timestamp;
530 duration_for_last_reported_day_ = activity_milliseconds; 528 duration_for_last_reported_day_ = activity_milliseconds;
531 } 529 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 ScheduleGeolocationUpdateRequest(); 870 ScheduleGeolocationUpdateRequest();
873 } 871 }
874 872
875 void DeviceStatusCollector::ReceiveVolumeInfo( 873 void DeviceStatusCollector::ReceiveVolumeInfo(
876 const std::vector<em::VolumeInfo>& info) { 874 const std::vector<em::VolumeInfo>& info) {
877 if (report_hardware_status_) 875 if (report_hardware_status_)
878 volume_info_ = info; 876 volume_info_ = info;
879 } 877 }
880 878
881 } // namespace policy 879 } // namespace policy
OLDNEW
« no previous file with comments | « base/time/time.h ('k') | chrome/browser/ui/webui/options/clear_browser_data_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698