OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_list.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/task/cancelable_task_tracker.h" | 16 #include "base/task/cancelable_task_tracker.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "chrome/browser/chromeos/version_loader.h" | 20 #include "chrome/browser/chromeos/version_loader.h" |
21 #include "chrome/browser/idle.h" | 21 #include "chrome/browser/idle.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // The number of days in the past to store device activity. | 86 // The number of days in the past to store device activity. |
87 // This is kept in case device status uploads fail for a number of days. | 87 // This is kept in case device status uploads fail for a number of days. |
88 unsigned int max_stored_past_activity_days_; | 88 unsigned int max_stored_past_activity_days_; |
89 | 89 |
90 // The number of days in the future to store device activity. | 90 // The number of days in the future to store device activity. |
91 // When changing the system time and/or timezones, it's possible to record | 91 // When changing the system time and/or timezones, it's possible to record |
92 // activity time that is slightly in the future. | 92 // activity time that is slightly in the future. |
93 unsigned int max_stored_future_activity_days_; | 93 unsigned int max_stored_future_activity_days_; |
94 | 94 |
95 private: | 95 private: |
96 // A helper class to manage receiving geolocation callbacks on the IO | |
97 // thread. | |
98 class Context : public base::RefCountedThreadSafe<Context> { | |
99 public: | |
100 Context(); | |
101 | |
102 void GetLocationUpdate( | |
103 const content::GeolocationProvider::LocationUpdateCallback& callback); | |
104 | |
105 private: | |
106 friend class base::RefCountedThreadSafe<Context>; | |
107 | |
108 ~Context(); | |
109 | |
110 void GetLocationUpdateInternal(); | |
111 void OnLocationUpdate(const content::Geoposition& geoposition); | |
112 void CallCollector(const content::Geoposition& geoposition); | |
113 | |
114 // The callback which this class registers with | |
115 // content::GeolocationProvider. | |
116 content::GeolocationProvider::LocationUpdateCallback our_callback_; | |
117 | |
118 // The callback passed in to GetLocationUpdate. | |
119 content::GeolocationProvider::LocationUpdateCallback owner_callback_; | |
120 }; | |
121 | |
122 // Prevents the local store of activity periods from growing too large by | 96 // Prevents the local store of activity periods from growing too large by |
123 // removing entries that are outside the reporting window. | 97 // removing entries that are outside the reporting window. |
124 void PruneStoredActivityPeriods(base::Time base_time); | 98 void PruneStoredActivityPeriods(base::Time base_time); |
125 | 99 |
126 // Trims the store activity periods to only retain data within the | 100 // Trims the store activity periods to only retain data within the |
127 // [|min_day_key|, |max_day_key|). The record for |min_day_key| will be | 101 // [|min_day_key|, |max_day_key|). The record for |min_day_key| will be |
128 // adjusted by subtracting |min_day_trim_duration|. | 102 // adjusted by subtracting |min_day_trim_duration|. |
129 void TrimStoredActivityPeriods(int64 min_day_key, | 103 void TrimStoredActivityPeriods(int64 min_day_key, |
130 int min_day_trim_duration, | 104 int min_day_trim_duration, |
131 int64 max_day_key); | 105 int64 max_day_key); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 chromeos::system::StatisticsProvider* statistics_provider_; | 164 chromeos::system::StatisticsProvider* statistics_provider_; |
191 | 165 |
192 chromeos::CrosSettings* cros_settings_; | 166 chromeos::CrosSettings* cros_settings_; |
193 | 167 |
194 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; | 168 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; |
195 | 169 |
196 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 170 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
197 // way to mock geolocation exists. | 171 // way to mock geolocation exists. |
198 LocationUpdateRequester location_update_requester_; | 172 LocationUpdateRequester location_update_requester_; |
199 | 173 |
| 174 scoped_ptr<content::GeolocationProvider::Subscription> |
| 175 geolocation_subscription_; |
| 176 |
200 // Cached values of the reporting settings from the device policy. | 177 // Cached values of the reporting settings from the device policy. |
201 bool report_version_info_; | 178 bool report_version_info_; |
202 bool report_activity_times_; | 179 bool report_activity_times_; |
203 bool report_boot_mode_; | 180 bool report_boot_mode_; |
204 bool report_location_; | 181 bool report_location_; |
205 bool report_network_interfaces_; | 182 bool report_network_interfaces_; |
206 bool report_users_; | 183 bool report_users_; |
207 | 184 |
208 scoped_refptr<Context> context_; | |
209 | |
210 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 185 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
211 version_info_subscription_; | 186 version_info_subscription_; |
212 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 187 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
213 activity_times_subscription_; | 188 activity_times_subscription_; |
214 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 189 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
215 boot_mode_subscription_; | 190 boot_mode_subscription_; |
216 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 191 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
217 location_subscription_; | 192 location_subscription_; |
218 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 193 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
219 network_interfaces_subscription_; | 194 network_interfaces_subscription_; |
220 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 195 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
221 users_subscription_; | 196 users_subscription_; |
222 | 197 |
223 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 198 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
224 }; | 199 }; |
225 | 200 |
226 } // namespace policy | 201 } // namespace policy |
227 | 202 |
228 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 203 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
OLD | NEW |