blob: 5c5a1128ce95ab61860bf974581b93b051ce899e [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <vector>
#include "base/macros.h"
class PrefService;
class PrefRegistrySimple;
namespace base {
class Clock;
} // namespace base
namespace syncer {
// Use this for determining if a cache guid was recently used by this device.
class DeviceInfoPrefs {
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
static void MigrateRecentLocalCacheGuidsPref(PrefService* pref_service);
// |pref_service| and |clock| must outlive this class and be non null.
DeviceInfoPrefs(PrefService* pref_service, const base::Clock* clock);
// Returns if the given |cache_guid| is present in the saved pref. This is
// most reliable when dealing with recent devices only, due to garbage
// collection of local GUIDs, as per kMaxDaysLocalCacheGuidsStored.
bool IsRecentLocalCacheGuid(const std::string& cache_guid) const;
// Adds the given |cache_guid| to the internal list stored in prefs and
// exposed via IsRecentLocalCacheGuid(). If the |cache_guid| already exists,
// this will reset the expiry date for that entry.
void AddLocalCacheGuid(const std::string& cache_guid);
// Garbage-collects local cache GUIDs if too old.
void GarbageCollectExpiredCacheGuids();
PrefService* const pref_service_;
const base::Clock* const clock_;
} // namespace syncer