#include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
#include <string.h>
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/uuid.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
constexpr char kPushMessagingAppIdentifierPrefix[] = …;
constexpr char kInstanceIDGuidSuffix[] = …;
namespace {
constexpr size_t kPrefixLength = …;
constexpr size_t kGuidSuffixLength = …;
constexpr char kPrefValueSeparator = …;
constexpr size_t kGuidLength = …;
std::string FromTimeToString(base::Time time) { … }
bool FromStringToTime(const std::string& time_string,
std::optional<base::Time>* time) { … }
std::string MakePrefValue(
const GURL& origin,
int64_t service_worker_registration_id,
const std::optional<base::Time>& expiration_time = std::nullopt) { … }
bool DisassemblePrefValue(const std::string& pref_value,
GURL* origin,
int64_t* service_worker_registration_id,
std::optional<base::Time>* expiration_time) { … }
}
void PushMessagingAppIdentifier::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
bool PushMessagingAppIdentifier::UseInstanceID(const std::string& app_id) { … }
PushMessagingAppIdentifier PushMessagingAppIdentifier::Generate(
const GURL& origin,
int64_t service_worker_registration_id,
const std::optional<base::Time>& expiration_time) { … }
PushMessagingAppIdentifier PushMessagingAppIdentifier::LegacyGenerateForTesting(
const GURL& origin,
int64_t service_worker_registration_id,
const std::optional<base::Time>& expiration_time) { … }
PushMessagingAppIdentifier PushMessagingAppIdentifier::GenerateInternal(
const GURL& origin,
int64_t service_worker_registration_id,
bool use_instance_id,
const std::optional<base::Time>& expiration_time) { … }
PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByAppId(
Profile* profile, const std::string& app_id) { … }
PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByServiceWorker(
Profile* profile,
const GURL& origin,
int64_t service_worker_registration_id) { … }
std::vector<PushMessagingAppIdentifier> PushMessagingAppIdentifier::GetAll(
Profile* profile) { … }
void PushMessagingAppIdentifier::DeleteAllFromPrefs(Profile* profile) { … }
size_t PushMessagingAppIdentifier::GetCount(Profile* profile) { … }
PushMessagingAppIdentifier::PushMessagingAppIdentifier(
const PushMessagingAppIdentifier& other) = default;
PushMessagingAppIdentifier::PushMessagingAppIdentifier()
: … { … }
PushMessagingAppIdentifier::PushMessagingAppIdentifier(
const std::string& app_id,
const GURL& origin,
int64_t service_worker_registration_id,
const std::optional<base::Time>& expiration_time)
: … { … }
PushMessagingAppIdentifier::~PushMessagingAppIdentifier() { … }
bool PushMessagingAppIdentifier::IsExpired() const { … }
void PushMessagingAppIdentifier::PersistToPrefs(Profile* profile) const { … }
void PushMessagingAppIdentifier::DeleteFromPrefs(Profile* profile) const { … }
void PushMessagingAppIdentifier::DCheckValid() const { … }