pref_service_helper.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 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. //
  5. // Helper to initialize PrefService for cast shell.
  6. #ifndef CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_
  7. #define CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_
  8. #include <memory>
  9. #include <set>
  10. #include <string>
  11. #include "base/memory/ref_counted.h"
  12. #include "base/threading/thread_checker.h"
  13. #include "chromecast/base/process_types.h"
  14. #include "components/prefs/pref_service.h"
  15. class PrefRegistrySimple;
  16. namespace chromecast {
  17. namespace shell {
  18. // It uses JsonPrefStore internally and/so the format of config file is same to
  19. // that of JsonPrefStore.
  20. class PrefServiceHelper {
  21. public:
  22. // Loads configs from config file. Returns true if successful.
  23. static std::unique_ptr<PrefService> CreatePrefService(
  24. PrefRegistrySimple* registry,
  25. ProcessType process_type = ProcessType::kCastService);
  26. // Provides names of prefs that take a large amount of storage, and are
  27. // therefore stored in a different file.
  28. static std::set<std::string> LargePrefNames() __attribute__((weak));
  29. private:
  30. // Registers any needed preferences for the current platform.
  31. static void RegisterPlatformPrefs(PrefRegistrySimple* registry);
  32. // Called after the pref file has been loaded.
  33. static void OnPrefsLoaded(PrefService* pref_service);
  34. };
  35. } // namespace shell
  36. } // namespace chromecast
  37. #endif // CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_