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

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

Issue 2383763002: Report ARC status asynchronously via DeviceStatusCollector (Closed)
Patch Set: Nits addressed 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 <vector> 13 #include <vector>
14 14
15 #include "base/callback_forward.h" 15 #include "base/callback_forward.h"
16 #include "base/callback_list.h" 16 #include "base/callback_list.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.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 // Passed into asynchronous mojo interface for communicating with Android.
74 using AndroidStatusReceiver =
75 base::Callback<void(mojo::String, mojo::String)>;
76 // Calls the enterprise reporting mojo interface, passing over the
77 // AndroidStatusReceiver.
78 using AndroidStatusFetcher =
79 base::Callback<bool(const AndroidStatusReceiver&)>;
80
71 // Called in the UI thread after the device and session status have been 81 // Called in the UI thread after the device and session status have been
72 // collected asynchronously in GetDeviceAndSessionStatusAsync. Null pointers 82 // collected asynchronously in GetDeviceAndSessionStatusAsync. Null pointers
73 // indicate errors or that device or session status reporting is disabled. 83 // indicate errors or that device or session status reporting is disabled.
74 using StatusCallback = base::Callback<void( 84 using StatusCallback = base::Callback<void(
75 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>, 85 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>,
76 std::unique_ptr<enterprise_management::SessionStatusReportRequest>)>; 86 std::unique_ptr<enterprise_management::SessionStatusReportRequest>)>;
77 87
78 // Constructor. Callers can inject their own VolumeInfoFetcher, 88 // Constructor. Callers can inject their own VolumeInfoFetcher,
79 // CPUStatisticsFetcher and CPUTempFetcher. These callbacks are executed on 89 // CPUStatisticsFetcher and CPUTempFetcher. These callbacks are executed on
80 // Blocking Pool. A null callback can be passed for either parameter, to use 90 // Blocking Pool. A null callback can be passed for either parameter, to use
81 // the default implementation. 91 // the default implementation.
82 DeviceStatusCollector( 92 DeviceStatusCollector(
83 PrefService* local_state, 93 PrefService* local_state,
84 chromeos::system::StatisticsProvider* provider, 94 chromeos::system::StatisticsProvider* provider,
85 const VolumeInfoFetcher& volume_info_fetcher, 95 const VolumeInfoFetcher& volume_info_fetcher,
86 const CPUStatisticsFetcher& cpu_statistics_fetcher, 96 const CPUStatisticsFetcher& cpu_statistics_fetcher,
87 const CPUTempFetcher& cpu_temp_fetcher); 97 const CPUTempFetcher& cpu_temp_fetcher,
98 const AndroidStatusFetcher& android_status_fetcher);
88 virtual ~DeviceStatusCollector(); 99 virtual ~DeviceStatusCollector();
89 100
90 // Gathers device and session status information and calls the passed response 101 // Gathers device and session status information and calls the passed response
91 // callback. Null pointers passed into the response indicate errors or that 102 // callback. Null pointers passed into the response indicate errors or that
92 // device or session status reporting is disabled. 103 // device or session status reporting is disabled.
93 virtual void GetDeviceAndSessionStatusAsync(const StatusCallback& response); 104 virtual void GetDeviceAndSessionStatusAsync(const StatusCallback& response);
94 105
95 // Called after the status information has successfully been submitted to 106 // Called after the status information has successfully been submitted to
96 // the server. 107 // the server.
97 void OnSubmittedSuccessfully(); 108 void OnSubmittedSuccessfully();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 enterprise_management::DeviceStatusReportRequest* status, 185 enterprise_management::DeviceStatusReportRequest* status,
175 scoped_refptr<GetStatusState> state); // Queues async queries! 186 scoped_refptr<GetStatusState> state); // Queues async queries!
176 bool GetOsUpdateStatus( 187 bool GetOsUpdateStatus(
177 enterprise_management::DeviceStatusReportRequest* status); 188 enterprise_management::DeviceStatusReportRequest* status);
178 bool GetRunningKioskApp( 189 bool GetRunningKioskApp(
179 enterprise_management::DeviceStatusReportRequest* status); 190 enterprise_management::DeviceStatusReportRequest* status);
180 191
181 // Helpers for the various portions of SESSION STATUS. Return true if they 192 // Helpers for the various portions of SESSION STATUS. Return true if they
182 // actually report any status. Functions that queue async queries take 193 // actually report any status. Functions that queue async queries take
183 // a |GetStatusState| instance. 194 // a |GetStatusState| instance.
184 bool GetAccountStatus( 195 bool GetKioskSessionStatus(
185 enterprise_management::SessionStatusReportRequest* status); 196 enterprise_management::SessionStatusReportRequest* status);
197 bool GetAndroidStatus(
198 enterprise_management::SessionStatusReportRequest* status,
199 const scoped_refptr<GetStatusState>& state); // Queues async queries!
186 200
187 // Update the cached values of the reporting settings. 201 // Update the cached values of the reporting settings.
188 void UpdateReportingSettings(); 202 void UpdateReportingSettings();
189 203
190 // Callback invoked to update our cpu usage information. 204 // Callback invoked to update our cpu usage information.
191 void ReceiveCPUStatistics(const std::string& statistics); 205 void ReceiveCPUStatistics(const std::string& statistics);
192 206
193 PrefService* const local_state_; 207 PrefService* const local_state_;
194 208
195 // The last time an idle state check was performed. 209 // The last time an idle state check was performed.
(...skipping 27 matching lines...) Expand all
223 237
224 // Callback invoked to fetch information about the mounted disk volumes. 238 // Callback invoked to fetch information about the mounted disk volumes.
225 VolumeInfoFetcher volume_info_fetcher_; 239 VolumeInfoFetcher volume_info_fetcher_;
226 240
227 // Callback invoked to fetch information about cpu usage. 241 // Callback invoked to fetch information about cpu usage.
228 CPUStatisticsFetcher cpu_statistics_fetcher_; 242 CPUStatisticsFetcher cpu_statistics_fetcher_;
229 243
230 // Callback invoked to fetch information about cpu temperature. 244 // Callback invoked to fetch information about cpu temperature.
231 CPUTempFetcher cpu_temp_fetcher_; 245 CPUTempFetcher cpu_temp_fetcher_;
232 246
247 AndroidStatusFetcher android_status_fetcher_;
248
233 chromeos::system::StatisticsProvider* const statistics_provider_; 249 chromeos::system::StatisticsProvider* const statistics_provider_;
234 250
235 chromeos::CrosSettings* const cros_settings_; 251 chromeos::CrosSettings* const cros_settings_;
236 252
237 // The most recent CPU readings. 253 // The most recent CPU readings.
238 uint64_t last_cpu_active_ = 0; 254 uint64_t last_cpu_active_ = 0;
239 uint64_t last_cpu_idle_ = 0; 255 uint64_t last_cpu_idle_ = 0;
240 256
241 // Cached values of the reporting settings from the device policy. 257 // Cached values of the reporting settings from the device policy.
242 bool report_version_info_ = false; 258 bool report_version_info_ = false;
243 bool report_activity_times_ = false; 259 bool report_activity_times_ = false;
244 bool report_boot_mode_ = false; 260 bool report_boot_mode_ = false;
245 bool report_network_interfaces_ = false; 261 bool report_network_interfaces_ = false;
246 bool report_users_ = false; 262 bool report_users_ = false;
247 bool report_hardware_status_ = false; 263 bool report_hardware_status_ = false;
248 bool report_session_status_ = false; 264 bool report_kiosk_session_status_ = false;
265 bool report_android_status_ = false;
249 bool report_os_update_status_ = false; 266 bool report_os_update_status_ = false;
250 bool report_running_kiosk_app_ = false; 267 bool report_running_kiosk_app_ = false;
251 268
252 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 269 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
253 version_info_subscription_; 270 version_info_subscription_;
254 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 271 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
255 activity_times_subscription_; 272 activity_times_subscription_;
256 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 273 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
257 boot_mode_subscription_; 274 boot_mode_subscription_;
258 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 275 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
(...skipping 14 matching lines...) Expand all
273 base::ThreadChecker thread_checker_; 290 base::ThreadChecker thread_checker_;
274 291
275 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; 292 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_;
276 293
277 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); 294 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector);
278 }; 295 };
279 296
280 } // namespace policy 297 } // namespace policy
281 298
282 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ 299 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698