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

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

Issue 2383763002: Report ARC status asynchronously via DeviceStatusCollector (Closed)
Patch Set: Created 4 years, 2 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
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 #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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <utility>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/callback_forward.h" 16 #include "base/callback_forward.h"
16 #include "base/callback_list.h" 17 #include "base/callback_list.h"
17 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
20 #include "base/sequenced_task_runner.h" 21 #include "base/sequenced_task_runner.h"
21 #include "base/task/cancelable_task_tracker.h" 22 #include "base/task/cancelable_task_tracker.h"
22 #include "base/threading/thread_checker.h" 23 #include "base/threading/thread_checker.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "base/timer/timer.h" 25 #include "base/timer/timer.h"
25 26
26 #include "chrome/browser/chromeos/settings/cros_settings.h" 27 #include "chrome/browser/chromeos/settings/cros_settings.h"
27 #include "chromeos/system/version_loader.h" 28 #include "chromeos/system/version_loader.h"
28 #include "components/policy/proto/device_management_backend.pb.h" 29 #include "components/policy/proto/device_management_backend.pb.h"
30 #include "mojo/public/cpp/bindings/string.h"
29 #include "ui/base/idle/idle.h" 31 #include "ui/base/idle/idle.h"
30 32
31 namespace chromeos { 33 namespace chromeos {
32 class CrosSettings; 34 class CrosSettings;
33 namespace system { 35 namespace system {
34 class StatisticsProvider; 36 class StatisticsProvider;
35 } 37 }
36 } 38 }
37 39
38 namespace content { 40 namespace content {
(...skipping 22 matching lines...) Expand all
61 // 63 //
62 // The format of this line from /proc/stat is: 64 // The format of this line from /proc/stat is:
63 // cpu user_time nice_time system_time idle_time 65 // cpu user_time nice_time system_time idle_time
64 using CPUStatisticsFetcher = base::Callback<std::string(void)>; 66 using CPUStatisticsFetcher = base::Callback<std::string(void)>;
65 67
66 // Reads CPU temperatures from /sys/class/hwmon/hwmon*/temp*_input and 68 // Reads CPU temperatures from /sys/class/hwmon/hwmon*/temp*_input and
67 // appropriate labels from /sys/class/hwmon/hwmon*/temp*_label. 69 // appropriate labels from /sys/class/hwmon/hwmon*/temp*_label.
68 using CPUTempFetcher = 70 using CPUTempFetcher =
69 base::Callback<std::vector<enterprise_management::CPUTempInfo>()>; 71 base::Callback<std::vector<enterprise_management::CPUTempInfo>()>;
70 72
73 using AndroidStatusFetcher =
74 base::Callback<std::pair<mojo::String, mojo::String>(void)>;
75
71 // Called in the UI thread after the device and session status have been 76 // Called in the UI thread after the device and session status have been
72 // collected asynchronously in GetDeviceAndSessionStatusAsync. Null pointers 77 // collected asynchronously in GetDeviceAndSessionStatusAsync. Null pointers
73 // indicate errors or that device or session status reporting is disabled. 78 // indicate errors or that device or session status reporting is disabled.
74 using StatusCallback = base::Callback<void( 79 using StatusCallback = base::Callback<void(
75 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>, 80 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>,
76 std::unique_ptr<enterprise_management::SessionStatusReportRequest>)>; 81 std::unique_ptr<enterprise_management::SessionStatusReportRequest>)>;
77 82
78 // Constructor. Callers can inject their own VolumeInfoFetcher, 83 // Constructor. Callers can inject their own VolumeInfoFetcher,
79 // CPUStatisticsFetcher and CPUTempFetcher. These callbacks are executed on 84 // CPUStatisticsFetcher and CPUTempFetcher. These callbacks are executed on
80 // Blocking Pool. A null callback can be passed for either parameter, to use 85 // Blocking Pool. A null callback can be passed for either parameter, to use
81 // the default implementation. 86 // the default implementation.
82 DeviceStatusCollector( 87 DeviceStatusCollector(
83 PrefService* local_state, 88 PrefService* local_state,
84 chromeos::system::StatisticsProvider* provider, 89 chromeos::system::StatisticsProvider* provider,
85 const VolumeInfoFetcher& volume_info_fetcher, 90 const VolumeInfoFetcher& volume_info_fetcher,
86 const CPUStatisticsFetcher& cpu_statistics_fetcher, 91 const CPUStatisticsFetcher& cpu_statistics_fetcher,
87 const CPUTempFetcher& cpu_temp_fetcher); 92 const CPUTempFetcher& cpu_temp_fetcher,
93 const AndroidStatusFetcher& android_status_fetcher_);
88 virtual ~DeviceStatusCollector(); 94 virtual ~DeviceStatusCollector();
89 95
90 // Gathers device and session status information and calls the passed response 96 // Gathers device and session status information and calls the passed response
91 // callback. Null pointers passed into the response indicate errors or that 97 // callback. Null pointers passed into the response indicate errors or that
92 // device or session status reporting is disabled. 98 // device or session status reporting is disabled.
93 virtual void GetDeviceAndSessionStatusAsync(const StatusCallback& response); 99 virtual void GetDeviceAndSessionStatusAsync(const StatusCallback& response);
94 100
95 // Called after the status information has successfully been submitted to 101 // Called after the status information has successfully been submitted to
96 // the server. 102 // the server.
97 void OnSubmittedSuccessfully(); 103 void OnSubmittedSuccessfully();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 bool GetOsUpdateStatus( 182 bool GetOsUpdateStatus(
177 enterprise_management::DeviceStatusReportRequest* status); 183 enterprise_management::DeviceStatusReportRequest* status);
178 bool GetRunningKioskApp( 184 bool GetRunningKioskApp(
179 enterprise_management::DeviceStatusReportRequest* status); 185 enterprise_management::DeviceStatusReportRequest* status);
180 186
181 // Helpers for the various portions of SESSION STATUS. Return true if they 187 // Helpers for the various portions of SESSION STATUS. Return true if they
182 // actually report any status. Functions that queue async queries take 188 // actually report any status. Functions that queue async queries take
183 // a |GetStatusState| instance. 189 // a |GetStatusState| instance.
184 bool GetAccountStatus( 190 bool GetAccountStatus(
185 enterprise_management::SessionStatusReportRequest* status); 191 enterprise_management::SessionStatusReportRequest* status);
192 bool GetAndroidStatus(
193 enterprise_management::SessionStatusReportRequest* status,
194 scoped_refptr<GetStatusState> state); // Queues async queries!
186 195
187 // Update the cached values of the reporting settings. 196 // Update the cached values of the reporting settings.
188 void UpdateReportingSettings(); 197 void UpdateReportingSettings();
189 198
190 // Callback invoked to update our cpu usage information. 199 // Callback invoked to update our cpu usage information.
191 void ReceiveCPUStatistics(const std::string& statistics); 200 void ReceiveCPUStatistics(const std::string& statistics);
192 201
193 PrefService* const local_state_; 202 PrefService* const local_state_;
194 203
195 // The last time an idle state check was performed. 204 // The last time an idle state check was performed.
(...skipping 27 matching lines...) Expand all
223 232
224 // Callback invoked to fetch information about the mounted disk volumes. 233 // Callback invoked to fetch information about the mounted disk volumes.
225 VolumeInfoFetcher volume_info_fetcher_; 234 VolumeInfoFetcher volume_info_fetcher_;
226 235
227 // Callback invoked to fetch information about cpu usage. 236 // Callback invoked to fetch information about cpu usage.
228 CPUStatisticsFetcher cpu_statistics_fetcher_; 237 CPUStatisticsFetcher cpu_statistics_fetcher_;
229 238
230 // Callback invoked to fetch information about cpu temperature. 239 // Callback invoked to fetch information about cpu temperature.
231 CPUTempFetcher cpu_temp_fetcher_; 240 CPUTempFetcher cpu_temp_fetcher_;
232 241
242 AndroidStatusFetcher android_status_fetcher_;
243
233 chromeos::system::StatisticsProvider* const statistics_provider_; 244 chromeos::system::StatisticsProvider* const statistics_provider_;
234 245
235 chromeos::CrosSettings* const cros_settings_; 246 chromeos::CrosSettings* const cros_settings_;
236 247
237 // The most recent CPU readings. 248 // The most recent CPU readings.
238 uint64_t last_cpu_active_ = 0; 249 uint64_t last_cpu_active_ = 0;
239 uint64_t last_cpu_idle_ = 0; 250 uint64_t last_cpu_idle_ = 0;
240 251
241 // Cached values of the reporting settings from the device policy. 252 // Cached values of the reporting settings from the device policy.
242 bool report_version_info_ = false; 253 bool report_version_info_ = false;
243 bool report_activity_times_ = false; 254 bool report_activity_times_ = false;
244 bool report_boot_mode_ = false; 255 bool report_boot_mode_ = false;
245 bool report_network_interfaces_ = false; 256 bool report_network_interfaces_ = false;
246 bool report_users_ = false; 257 bool report_users_ = false;
247 bool report_hardware_status_ = false; 258 bool report_hardware_status_ = false;
248 bool report_session_status_ = false; 259 bool report_session_status_ = false;
260 bool report_android_status_ = false;
249 bool report_os_update_status_ = false; 261 bool report_os_update_status_ = false;
250 bool report_running_kiosk_app_ = false; 262 bool report_running_kiosk_app_ = false;
251 263
252 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 264 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
253 version_info_subscription_; 265 version_info_subscription_;
254 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 266 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
255 activity_times_subscription_; 267 activity_times_subscription_;
256 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 268 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
257 boot_mode_subscription_; 269 boot_mode_subscription_;
258 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 270 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
(...skipping 14 matching lines...) Expand all
273 base::ThreadChecker thread_checker_; 285 base::ThreadChecker thread_checker_;
274 286
275 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; 287 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_;
276 288
277 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); 289 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector);
278 }; 290 };
279 291
280 } // namespace policy 292 } // namespace policy
281 293
282 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ 294 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698