1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
// Copyright 2024 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/ping_persisted_data.h"
#include <memory>
#include <string>
#include <vector>
#include "base/check.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "base/version.h"
#include "components/update_client/persisted_data.h"
#include "components/update_client/update_client_errors.h"
namespace updater {
namespace {
class PingPersistedData : public update_client::PersistedData {
public:
PingPersistedData();
PingPersistedData(const PingPersistedData&) = delete;
PingPersistedData& operator=(const PingPersistedData&) = delete;
~PingPersistedData() override;
// update_client::PersistedData overrides:
base::Version GetProductVersion(const std::string& id) const override;
void SetProductVersion(const std::string& id,
const base::Version& pv) override;
base::Version GetMaxPreviousProductVersion(
const std::string& id) const override;
void SetMaxPreviousProductVersion(const std::string& id,
const base::Version& max_version) override;
std::string GetFingerprint(const std::string& id) const override;
void SetFingerprint(const std::string& id, const std::string& fp) override;
int GetDateLastActive(const std::string& id) const override;
int GetDaysSinceLastActive(const std::string& id) const override;
void SetDateLastActive(const std::string& id, int dla) override;
int GetDateLastRollCall(const std::string& id) const override;
int GetDaysSinceLastRollCall(const std::string& id) const override;
void SetDateLastRollCall(const std::string& id, int dlrc) override;
std::string GetCohort(const std::string& id) const override;
void SetCohort(const std::string& id, const std::string& cohort) override;
std::string GetCohortName(const std::string& id) const override;
void SetCohortName(const std::string& id,
const std::string& cohort_name) override;
std::string GetCohortHint(const std::string& id) const override;
void SetCohortHint(const std::string& id,
const std::string& cohort_hint) override;
std::string GetPingFreshness(const std::string& id) const override;
void SetDateLastData(const std::vector<std::string>& ids,
int datenum,
base::OnceClosure callback) override;
int GetInstallDate(const std::string& id) const override;
void SetInstallDate(const std::string& id, int install_date) override;
std::string GetInstallId(const std::string& app_id) const override;
void SetInstallId(const std::string& app_id,
const std::string& install_id) override;
void GetActiveBits(const std::vector<std::string>& ids,
base::OnceCallback<void(const std::set<std::string>&)>
callback) const override;
base::Time GetThrottleUpdatesUntil() const override;
void SetThrottleUpdatesUntil(base::Time time) override;
void SetLastUpdateCheckError(
const update_client::CategorizedError& error) override;
private:
SEQUENCE_CHECKER(sequence_checker_);
};
PingPersistedData::PingPersistedData() = default;
PingPersistedData::~PingPersistedData() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
base::Version PingPersistedData::GetProductVersion(
const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetProductVersion(const std::string& id,
const base::Version& pv) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
base::Version PingPersistedData::GetMaxPreviousProductVersion(
const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetMaxPreviousProductVersion(
const std::string& id,
const base::Version& max_version) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetFingerprint(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetFingerprint(const std::string& id,
const std::string& fingerprint) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
int PingPersistedData::GetDateLastActive(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
int PingPersistedData::GetDaysSinceLastActive(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetDateLastActive(const std::string& id, int dla) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
int PingPersistedData::GetDateLastRollCall(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
int PingPersistedData::GetDaysSinceLastRollCall(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetDateLastRollCall(const std::string& id, int dlrc) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetCohort(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return {};
}
void PingPersistedData::SetCohort(const std::string& id,
const std::string& cohort) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetCohortName(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return {};
}
void PingPersistedData::SetCohortName(const std::string& id,
const std::string& cohort_name) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetCohortHint(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return {};
}
void PingPersistedData::SetCohortHint(const std::string& id,
const std::string& cohort_hint) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetPingFreshness(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetDateLastData(const std::vector<std::string>& ids,
int datenum,
base::OnceClosure callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
int PingPersistedData::GetInstallDate(const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return {};
}
void PingPersistedData::SetInstallDate(const std::string& id,
int install_date) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
std::string PingPersistedData::GetInstallId(const std::string& app_id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return "";
}
void PingPersistedData::SetInstallId(const std::string& app_id,
const std::string& install_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Do nothing.
}
void PingPersistedData::GetActiveBits(
const std::vector<std::string>& ids,
base::OnceCallback<void(const std::set<std::string>&)> callback) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
base::Time PingPersistedData::GetThrottleUpdatesUntil() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetLastUpdateCheckError(
const update_client::CategorizedError& error) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
void PingPersistedData::SetThrottleUpdatesUntil(base::Time time) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTREACHED();
}
} // namespace
std::unique_ptr<update_client::PersistedData> CreatePingPersistedData() {
return std::make_unique<PingPersistedData>();
}
} // namespace updater
|