chromium/content/browser/attribution_reporting/sql_queries.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERIES_H_
#define CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERIES_H_

#include "content/browser/attribution_reporting/attribution_reporting.mojom.h"
#include "content/browser/attribution_reporting/rate_limit_table.h"

namespace content::attribution_queries {

static_assert;
inline constexpr const char kMinPrioritySql[] =;

// Rows are ordered by source_id instead of source_time because the former is
// strictly increasing while the latter is subject to clock adjustments. This
// property is only guaranteed because of the use of AUTOINCREMENT on the
// source_id column, which prevents reuse upon row deletion.
inline constexpr const char kGetMatchingSourcesSql[] =;

inline constexpr const char kSelectExpiredSourcesSql[] =;

inline constexpr const char kSelectInactiveSourcesSql[] =;

inline constexpr const char kScanSourcesData[] =;

inline constexpr const char kScanReportsData[] =;

inline constexpr const char kDeleteVestigialConversionSql[] =;

inline constexpr const char kCountActiveSourcesFromSourceOriginSql[] =;

inline constexpr const char kCountSourcesSql[] =;

inline constexpr const char kDedupKeySql[] =;

inline constexpr const char kGetSourcesDataKeysSql[] =;

static_assert;
inline constexpr const char kGetNullReportsDataKeysSql[] =;

inline constexpr const char kGetRateLimitDataKeysSql[] =;

inline constexpr const char kCountReportsForDestinationSql[] =;

inline constexpr char kNextReportTimeSql[] =;

// Set the report time for all reports that should have been sent before now
// to now + a random number of microseconds between `min_delay` and
// `max_delay`, both inclusive. We use RANDOM, instead of a method on the
// delegate, to avoid having to pull all reports into memory and update them
// one by one. We use ABS because RANDOM may return a negative integer. We add
// 1 to the difference between `max_delay` and `min_delay` to ensure that the
// range of generated values is inclusive. If `max_delay == min_delay`, we
// take the remainder modulo 1, which is always 0.
inline constexpr const char kSetReportTimeSql[] =;

// clang-format off

#define ATTRIBUTION_SOURCE_COLUMNS_SQL(prefix)

inline constexpr const char kReadSourceToAttributeSql[] =;

inline constexpr const char kGetActiveSourcesSql[] =;

#define ATTRIBUTION_SELECT_REPORT_AND_SOURCE_COLUMNS_SQL

inline constexpr const char kGetReportsSql[] =;

inline constexpr const char kGetReportSql[] =;

#undef ATTRIBUTION_SELECT_REPORT_AND_SOURCE_COLUMNS_SQL

inline constexpr const char kUpdateFailedReportSql[] =;

static_assert;
inline constexpr const char kDeletePendingEventLevelReportsForSourceSql[] =;

static_assert;
inline constexpr char kDeleteAggregatableReportsForDestinationLimitSql[] =;

// clang-format on

inline constexpr const char kRateLimitAttributionAllowedSql[] =;

static_assert;
#define RATE_LIMIT_SOURCE_CONDITION

static_assert;
static_assert;
#define RATE_LIMIT_ATTRIBUTION_CONDITION

inline constexpr const char kRateLimitSourceAllowedSql[] =;

inline constexpr const char kRateLimitSourceAllowedDestinationRateLimitSql[] =;

inline constexpr const char
    kRateLimitSourceAllowedDestinationPerDayRateLimitSql[] =;

#define RATE_LIMIT_SELECT_REPORTING_ORIGINS_QUERY

inline constexpr const char kRateLimitSelectSourceReportingOriginsSql[] =;

inline constexpr const char kRateLimitSelectAttributionReportingOriginsSql[] =;

#undef RATE_LIMIT_SELECT_REPORTING_ORIGINS_QUERY

inline constexpr const char kRateLimitSelectSourceReportingOriginsBySiteSql[] =;

static_assert;
#define RATE_LIMIT_REPORT_ID_SET_CONDITION

inline constexpr const char kDeleteAttributionRateLimitByReportIdSql[] =;

inline constexpr const char kDeleteRateLimitRangeSql[] =;

inline constexpr const char kSelectRateLimitsForDeletionSql[] =;

inline constexpr const char kDeleteExpiredRateLimitsSql[] =;

inline constexpr const char kDeleteRateLimitsBySourceIdSql[] =;

inline constexpr const char kDeactivateForSourceDestinationLimitSql[] =;

#undef RATE_LIMIT_SOURCE_CONDITION

inline constexpr const char kAggregatableDebugReportAllowedForRateLimitSql[] =;

inline constexpr const char kDeleteExpiredAggregatableDebugRateLimitsSql[] =;

inline constexpr const char kSelectAggregatableDebugRateLimitsForDeletionSql[] =;

inline constexpr const char kDeleteAggregatableDebugRateLimitRangeSql[] =;

}  // namespace content::attribution_queries

#endif  // CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERIES_H_