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

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

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

Powered by Google App Engine
This is Rietveld 408576698