#include "chrome/updater/prefs.h"
#include <algorithm>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/function_ref.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/lock.h"
#include "chrome/updater/persisted_data.h"
#include "chrome/updater/prefs_impl.h"
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h"
#include "components/update_client/update_client.h"
namespace updater {
namespace {
const char kPrefQualified[] = …;
const char kPrefSwapping[] = …;
const char kPrefMigratedLegacyUpdaters[] = …;
const char kPrefActiveVersion[] = …;
const char kPrefServerStarts[] = …;
const char kPrefsAccessMutex[] = PREFS_ACCESS_MUTEX;
constexpr base::TimeDelta kCreatePrefsWait(base::Minutes(2));
std::unique_ptr<PrefService> CreatePrefService(
const base::FilePath& prefs_dir,
scoped_refptr<PrefRegistrySimple> pref_registry,
const base::TimeDelta& wait_period) { … }
scoped_refptr<GlobalPrefs> CreateGlobalPrefsInternal(
UpdaterScope scope,
base::FunctionRef<bool(UpdaterScope)> check_wrong_user = &WrongUser) { … }
}
UpdaterPrefsImpl::UpdaterPrefsImpl(const base::FilePath& prefs_dir,
std::unique_ptr<ScopedLock> lock,
std::unique_ptr<PrefService> prefs)
: … { … }
UpdaterPrefsImpl::~UpdaterPrefsImpl() { … }
PrefService* UpdaterPrefsImpl::GetPrefService() const { … }
bool UpdaterPrefsImpl::GetQualified() const { … }
void UpdaterPrefsImpl::SetQualified(bool value) { … }
std::string UpdaterPrefsImpl::GetActiveVersion() const { … }
void UpdaterPrefsImpl::SetActiveVersion(const std::string& value) { … }
bool UpdaterPrefsImpl::GetSwapping() const { … }
void UpdaterPrefsImpl::SetSwapping(bool value) { … }
bool UpdaterPrefsImpl::GetMigratedLegacyUpdaters() const { … }
void UpdaterPrefsImpl::SetMigratedLegacyUpdaters() { … }
int UpdaterPrefsImpl::CountServerStarts() { … }
scoped_refptr<GlobalPrefs> CreateGlobalPrefs(UpdaterScope scope) { … }
scoped_refptr<GlobalPrefs> CreateGlobalPrefsForTesting(UpdaterScope scope) { … }
scoped_refptr<LocalPrefs> CreateLocalPrefs(UpdaterScope scope) { … }
void PrefsCommitPendingWrites(PrefService* pref_service) { … }
}