#include "chrome/browser/notifications/scheduler/internal/impression_history_tracker.h"
#include <algorithm>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/notreached.h"
#include "chrome/browser/notifications/scheduler/internal/scheduler_utils.h"
namespace notifications {
namespace {
size_t GetDismissCount(const ThrottleConfig* custom_throttle_config,
const SchedulerConfig& config) { … }
base::TimeDelta GetSuppressionDuration(
const ThrottleConfig* custom_throttle_config,
const SchedulerConfig& config) { … }
std::string ToDatabaseKey(SchedulerClientType type) { … }
}
ImpressionHistoryTrackerImpl::ImpressionHistoryTrackerImpl(
const SchedulerConfig& config,
std::vector<SchedulerClientType> registered_clients,
std::unique_ptr<CollectionStore<ClientState>> store,
base::Clock* clock)
: … { … }
ImpressionHistoryTrackerImpl::~ImpressionHistoryTrackerImpl() = default;
void ImpressionHistoryTrackerImpl::Init(Delegate* delegate,
InitCallback callback) { … }
void ImpressionHistoryTrackerImpl::AddImpression(
SchedulerClientType type,
const std::string& guid,
const Impression::ImpressionResultMap& impression_mapping,
const Impression::CustomData& custom_data,
std::optional<base::TimeDelta> ignore_timeout_duration) { … }
void ImpressionHistoryTrackerImpl::AnalyzeImpressionHistory() { … }
void ImpressionHistoryTrackerImpl::GetClientStates(
std::map<SchedulerClientType, const ClientState*>* client_states) const { … }
const Impression* ImpressionHistoryTrackerImpl::GetImpression(
SchedulerClientType type,
const std::string& guid) { … }
void ImpressionHistoryTrackerImpl::GetImpressionDetail(
SchedulerClientType type,
ImpressionDetail::ImpressionDetailCallback callback) { … }
void ImpressionHistoryTrackerImpl::OnUserAction(
const UserActionData& action_data) { … }
void ImpressionHistoryTrackerImpl::OnStoreInitialized(
InitCallback callback,
bool success,
CollectionStore<ClientState>::Entries entries) { … }
void ImpressionHistoryTrackerImpl::SyncRegisteredClients() { … }
void ImpressionHistoryTrackerImpl::HandleIgnoredImpressions(
ClientState* client_state) { … }
void ImpressionHistoryTrackerImpl::AnalyzeImpressionHistory(
ClientState* client_state) { … }
void ImpressionHistoryTrackerImpl::PruneImpressionByCreateTime(
base::circular_deque<Impression*>* impressions,
const base::Time& start_time) { … }
void ImpressionHistoryTrackerImpl::GenerateImpressionResult(
Impression* impression) { … }
void ImpressionHistoryTrackerImpl::UpdateThrottling(ClientState* client_state,
Impression* impression) { … }
void ImpressionHistoryTrackerImpl::CheckConsecutiveDismiss(
ClientState* client_state,
base::circular_deque<Impression*>* impressions) { … }
void ImpressionHistoryTrackerImpl::OnCustomNegativeActionCountQueried(
SchedulerClientType type,
base::circular_deque<Impression*>* impressions,
std::unique_ptr<ThrottleConfig> custom_throttle_config) { … }
void ImpressionHistoryTrackerImpl::ApplyPositiveImpression(
ClientState* client_state,
Impression* impression) { … }
void ImpressionHistoryTrackerImpl::ApplyNegativeImpression(
ClientState* client_state,
Impression* impression) { … }
void ImpressionHistoryTrackerImpl::OnCustomSuppressionDurationQueried(
SchedulerClientType type,
std::unique_ptr<ThrottleConfig> custom_throttle_config) { … }
void ImpressionHistoryTrackerImpl::CheckSuppressionExpiration(
ClientState* client_state) { … }
bool ImpressionHistoryTrackerImpl::MaybeUpdateDb(SchedulerClientType type) { … }
bool ImpressionHistoryTrackerImpl::MaybeUpdateAllDb() { … }
void ImpressionHistoryTrackerImpl::SetNeedsUpdate(SchedulerClientType type,
bool needs_update) { … }
bool ImpressionHistoryTrackerImpl::NeedsUpdate(SchedulerClientType type) const { … }
Impression* ImpressionHistoryTrackerImpl::FindImpressionNeedsUpdate(
SchedulerClientType type,
const std::string& notification_guid) { … }
Impression* ImpressionHistoryTrackerImpl::GetImpressionInternal(
SchedulerClientType type,
const std::string& guid) { … }
void ImpressionHistoryTrackerImpl::OnClickInternal(
SchedulerClientType type,
const std::string& notification_guid,
bool update_db) { … }
void ImpressionHistoryTrackerImpl::OnButtonClickInternal(
SchedulerClientType type,
const std::string& notification_guid,
ActionButtonType button_type,
bool update_db) { … }
void ImpressionHistoryTrackerImpl::OnDismissInternal(
SchedulerClientType type,
const std::string& notification_guid,
bool update_db) { … }
}