guest_os_prefs.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/guest_os/guest_os_prefs.h"
  5. #include "components/prefs/pref_registry_simple.h"
  6. namespace guest_os {
  7. namespace prefs {
  8. // The following prefs (nested under a provided location, e.g. arc.metrics)
  9. // persist engagement time across sessions, to be accumulated and sent to UMA
  10. // once a day.
  11. // Total engagement time of the device.
  12. const char kEngagementTimeTotal[] = ".engagement_time.total";
  13. // Time spent with a matched window in the foreground.
  14. const char kEngagementTimeForeground[] = ".engagement_time.foreground";
  15. // Time spent without a matched window in the foreground but the guest OS
  16. // otherwise running in the background.
  17. const char kEngagementTimeBackground[] = ".engagement_time.background";
  18. // The OS version when engagement prefs were recorded. Old results will be
  19. // discarded if a version change is detected.
  20. const char kEngagementTimeOsVersion[] = ".engagement_time.os_version";
  21. // The day ID (number of days since origin of Time) when engagement time was
  22. // last recorded.
  23. const char kEngagementTimeDayId[] = ".engagement_time.day_id";
  24. void RegisterEngagementProfilePrefs(PrefRegistrySimple* registry,
  25. const std::string& pref_prefix) {
  26. registry->RegisterTimeDeltaPref(pref_prefix + kEngagementTimeBackground,
  27. base::TimeDelta());
  28. registry->RegisterIntegerPref(pref_prefix + kEngagementTimeDayId, 0);
  29. registry->RegisterTimeDeltaPref(pref_prefix + kEngagementTimeForeground,
  30. base::TimeDelta());
  31. registry->RegisterStringPref(pref_prefix + kEngagementTimeOsVersion, "");
  32. registry->RegisterTimeDeltaPref(pref_prefix + kEngagementTimeTotal,
  33. base::TimeDelta());
  34. }
  35. } // namespace prefs
  36. } // namespace guest_os