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 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 mount_points.push_back(info.path.value()); | 350 mount_points.push_back(info.path.value()); |
351 | 351 |
352 for (const auto& mount_info : | 352 for (const auto& mount_info : |
353 chromeos::disks::DiskMountManager::GetInstance()->mount_points()) { | 353 chromeos::disks::DiskMountManager::GetInstance()->mount_points()) { |
354 // Extract a list of mount points to populate. | 354 // Extract a list of mount points to populate. |
355 mount_points.push_back(mount_info.first); | 355 mount_points.push_back(mount_info.first); |
356 } | 356 } |
357 | 357 |
358 // Call out to the blocking pool to sample disk volume info. | 358 // Call out to the blocking pool to sample disk volume info. |
359 base::PostTaskWithTraitsAndReplyWithResult( | 359 base::PostTaskWithTraitsAndReplyWithResult( |
360 FROM_HERE, | 360 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
361 base::TaskTraits().MayBlock().WithPriority( | |
362 base::TaskPriority::BACKGROUND), | |
363 base::Bind(volume_info_fetcher, mount_points), | 361 base::Bind(volume_info_fetcher, mount_points), |
364 base::Bind(&GetStatusState::OnVolumeInfoReceived, this)); | 362 base::Bind(&GetStatusState::OnVolumeInfoReceived, this)); |
365 } | 363 } |
366 | 364 |
367 // Queues an async callback to query CPU temperature information. | 365 // Queues an async callback to query CPU temperature information. |
368 void SampleCPUTempInfo( | 366 void SampleCPUTempInfo( |
369 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { | 367 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { |
370 // Call out to the blocking pool to sample CPU temp. | 368 // Call out to the blocking pool to sample CPU temp. |
371 base::PostTaskWithTraitsAndReplyWithResult( | 369 base::PostTaskWithTraitsAndReplyWithResult( |
372 FROM_HERE, | 370 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
373 base::TaskTraits().MayBlock().WithPriority( | |
374 base::TaskPriority::BACKGROUND), | |
375 cpu_temp_fetcher, | 371 cpu_temp_fetcher, |
376 base::Bind(&GetStatusState::OnCPUTempInfoReceived, this)); | 372 base::Bind(&GetStatusState::OnCPUTempInfoReceived, this)); |
377 } | 373 } |
378 | 374 |
379 bool FetchAndroidStatus( | 375 bool FetchAndroidStatus( |
380 const policy::DeviceStatusCollector::AndroidStatusFetcher& | 376 const policy::DeviceStatusCollector::AndroidStatusFetcher& |
381 android_status_fetcher) { | 377 android_status_fetcher) { |
382 return android_status_fetcher.Run( | 378 return android_status_fetcher.Run( |
383 base::Bind(&GetStatusState::OnAndroidInfoReceived, this)); | 379 base::Bind(&GetStatusState::OnAndroidInfoReceived, this)); |
384 } | 380 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 os_update_status_subscription_ = cros_settings_->AddSettingsObserver( | 488 os_update_status_subscription_ = cros_settings_->AddSettingsObserver( |
493 chromeos::kReportOsUpdateStatus, callback); | 489 chromeos::kReportOsUpdateStatus, callback); |
494 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver( | 490 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver( |
495 chromeos::kReportRunningKioskApp, callback); | 491 chromeos::kReportRunningKioskApp, callback); |
496 | 492 |
497 // Fetch the current values of the policies. | 493 // Fetch the current values of the policies. |
498 UpdateReportingSettings(); | 494 UpdateReportingSettings(); |
499 | 495 |
500 // Get the the OS and firmware version info. | 496 // Get the the OS and firmware version info. |
501 base::PostTaskWithTraitsAndReplyWithResult( | 497 base::PostTaskWithTraitsAndReplyWithResult( |
502 FROM_HERE, | 498 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
503 base::TaskTraits().MayBlock().WithPriority( | |
504 base::TaskPriority::BACKGROUND), | |
505 base::Bind(&chromeos::version_loader::GetVersion, | 499 base::Bind(&chromeos::version_loader::GetVersion, |
506 chromeos::version_loader::VERSION_FULL), | 500 chromeos::version_loader::VERSION_FULL), |
507 base::Bind(&DeviceStatusCollector::OnOSVersion, | 501 base::Bind(&DeviceStatusCollector::OnOSVersion, |
508 weak_factory_.GetWeakPtr())); | 502 weak_factory_.GetWeakPtr())); |
509 base::PostTaskWithTraitsAndReplyWithResult( | 503 base::PostTaskWithTraitsAndReplyWithResult( |
510 FROM_HERE, | 504 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
511 base::TaskTraits().MayBlock().WithPriority( | |
512 base::TaskPriority::BACKGROUND), | |
513 base::Bind(&chromeos::version_loader::GetFirmware), | 505 base::Bind(&chromeos::version_loader::GetFirmware), |
514 base::Bind(&DeviceStatusCollector::OnOSFirmware, | 506 base::Bind(&DeviceStatusCollector::OnOSFirmware, |
515 weak_factory_.GetWeakPtr())); | 507 weak_factory_.GetWeakPtr())); |
516 } | 508 } |
517 | 509 |
518 DeviceStatusCollector::~DeviceStatusCollector() { | 510 DeviceStatusCollector::~DeviceStatusCollector() { |
519 } | 511 } |
520 | 512 |
521 // static | 513 // static |
522 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) { | 514 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // Results must be written in the creation thread since that's where they | 712 // Results must be written in the creation thread since that's where they |
721 // are read from in the Get*StatusAsync methods. | 713 // are read from in the Get*StatusAsync methods. |
722 DCHECK(thread_checker_.CalledOnValidThread()); | 714 DCHECK(thread_checker_.CalledOnValidThread()); |
723 | 715 |
724 // If hardware reporting has been disabled, do nothing here. | 716 // If hardware reporting has been disabled, do nothing here. |
725 if (!report_hardware_status_) | 717 if (!report_hardware_status_) |
726 return; | 718 return; |
727 | 719 |
728 // Call out to the blocking pool to sample CPU stats. | 720 // Call out to the blocking pool to sample CPU stats. |
729 base::PostTaskWithTraitsAndReplyWithResult( | 721 base::PostTaskWithTraitsAndReplyWithResult( |
730 FROM_HERE, | 722 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
731 base::TaskTraits().MayBlock().WithPriority( | |
732 base::TaskPriority::BACKGROUND), | |
733 cpu_statistics_fetcher_, | 723 cpu_statistics_fetcher_, |
734 base::Bind(&DeviceStatusCollector::ReceiveCPUStatistics, | 724 base::Bind(&DeviceStatusCollector::ReceiveCPUStatistics, |
735 weak_factory_.GetWeakPtr())); | 725 weak_factory_.GetWeakPtr())); |
736 } | 726 } |
737 | 727 |
738 void DeviceStatusCollector::ReceiveCPUStatistics(const std::string& stats) { | 728 void DeviceStatusCollector::ReceiveCPUStatistics(const std::string& stats) { |
739 int cpu_usage_percent = 0; | 729 int cpu_usage_percent = 0; |
740 if (stats.empty()) { | 730 if (stats.empty()) { |
741 DLOG(WARNING) << "Unable to read CPU statistics"; | 731 DLOG(WARNING) << "Unable to read CPU statistics"; |
742 } else { | 732 } else { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1258 |
1269 void DeviceStatusCollector::OnOSVersion(const std::string& version) { | 1259 void DeviceStatusCollector::OnOSVersion(const std::string& version) { |
1270 os_version_ = version; | 1260 os_version_ = version; |
1271 } | 1261 } |
1272 | 1262 |
1273 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { | 1263 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { |
1274 firmware_version_ = version; | 1264 firmware_version_ = version; |
1275 } | 1265 } |
1276 | 1266 |
1277 } // namespace policy | 1267 } // namespace policy |
OLD | NEW |