#include <queue>
#include <string>
#include <unordered_map>
#include "base/check.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "components/commerce/core/subscriptions/commerce_subscription.h"
#include "components/commerce/core/subscriptions/subscriptions_storage.h"
#include "components/session_proto_db/session_proto_storage.h"
namespace commerce {
std::optional<CommerceSubscriptionProto> GetCommerceSubscriptionProto(
const CommerceSubscription& subscription) { … }
SubscriptionsStorage::SubscriptionsStorage(
SessionProtoStorage<CommerceSubscriptionProto>* subscription_proto_db)
: … { … }
SubscriptionsStorage::SubscriptionsStorage() = default;
SubscriptionsStorage::~SubscriptionsStorage() = default;
void SubscriptionsStorage::GetUniqueNonExistingSubscriptions(
std::unique_ptr<std::vector<CommerceSubscription>> subscriptions,
GetLocalSubscriptionsCallback callback) { … }
void SubscriptionsStorage::GetUniqueExistingSubscriptions(
std::unique_ptr<std::vector<CommerceSubscription>> subscriptions,
GetLocalSubscriptionsCallback callback) { … }
void SubscriptionsStorage::UpdateStorage(
SubscriptionType type,
StorageOperationCallback callback,
std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions) { … }
void SubscriptionsStorage::UpdateStorageAndNotifyModifiedSubscriptions(
SubscriptionType type,
StorageUpdateCallback callback,
std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions) { … }
void SubscriptionsStorage::DeleteAll() { … }
void SubscriptionsStorage::SaveSubscription(
const CommerceSubscription& subscription,
base::OnceCallback<void(bool)> callback) { … }
void SubscriptionsStorage::DeleteSubscription(
const CommerceSubscription& subscription,
base::OnceCallback<void(bool)> callback) { … }
void SubscriptionsStorage::LoadAllSubscriptionsForType(
SubscriptionType type,
GetLocalSubscriptionsCallback callback) { … }
void SubscriptionsStorage::LoadAllSubscriptions(
GetLocalSubscriptionsCallback callback) { … }
void SubscriptionsStorage::HandleLoadCompleted(
GetLocalSubscriptionsCallback callback,
bool succeeded,
CommerceSubscriptions data) { … }
CommerceSubscription SubscriptionsStorage::GetSubscriptionFromProto(
const SessionProtoStorage<CommerceSubscriptionProto>::KeyAndValue& kv) { … }
std::unordered_map<std::string, CommerceSubscription>
SubscriptionsStorage::SubscriptionsListToMap(
std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { … }
void SubscriptionsStorage::PerformGetNonExistingSubscriptions(
std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions,
GetLocalSubscriptionsCallback callback,
std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { … }
void SubscriptionsStorage::PerformGetExistingSubscriptions(
std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions,
GetLocalSubscriptionsCallback callback,
std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { … }
void SubscriptionsStorage::PerformUpdateStorage(
StorageUpdateCallback callback,
std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions,
std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { … }
void SubscriptionsStorage::IsSubscribed(
CommerceSubscription subscription,
base::OnceCallback<void(bool)> callback) { … }
bool SubscriptionsStorage::IsSubscribedFromCache(
const CommerceSubscription& subscription) { … }
}