chromium/chrome/updater/prefs.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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[] =;

// Serializes access to prefs.
const char kPrefsAccessMutex[] = PREFS_ACCESS_MUTEX;

// Total time to wait when creating prefs.
constexpr base::TimeDelta kCreatePrefsWait(base::Minutes(2));

// The prefs can fail to load, for example with `PREF_READ_ERROR_FILE_LOCKED`,
// so this function retries a few times.
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) {}

}  // namespace

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) {}

// Overrides `check_wrong_user` to always return `false` when calling
// `CreateGlobalPrefsInternal`. This allows the test driver to allow creating
// the global prefs even if running at high integrity, such as in the
// `IntegrationTestUserInSystem.ElevatedInstallOfUserUpdaterAndApp` test.
scoped_refptr<GlobalPrefs> CreateGlobalPrefsForTesting(UpdaterScope scope) {}

scoped_refptr<LocalPrefs> CreateLocalPrefs(UpdaterScope scope) {}

void PrefsCommitPendingWrites(PrefService* pref_service) {}

}  // namespace updater