Files
Claudio DeSouza cf11547646 [cr133] Use sql::Database::Tag
This type is now being used to represent the tag name, as it offers ways
to check at compile time for the tag being valid.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/dd2d901c3ecfb8685f4e4eda55edd6c8247f62da

commit dd2d901c3ecfb8685f4e4eda55edd6c8247f62da
Author: Anthony Vallée-Dubois <anthonyvd@google.com>
Date:   Wed Dec 18 15:25:28 2024 -0800

    Assert that database tag is valid at compile time

    This CL adds facilities to assert at compile-time that a database tag
    passed to the `sql::Database` constructors is specified in the
    DatabaseTag variant list in the corresponding `histograms.xml` file.

    For many users of `Database`, this change is a no-op. That said, some
    create databases with `make_unique()`, and the mechanism for forwarding arguments used by that function is incompatible with the
    implicit invocation of the consteval constructor this CL introduces.
    For this reason, these callers are also updated to explicitly create
    the tag object.

    Finally, 19 databases were using tags not defined in the histograms
    file, so this CL adds these tags as variants.

    Change-Id: I7aa6fdc4b923325cc41038fef72b239b5c19e4bd
2025-01-27 09:41:28 -05:00

24 lines
845 B
C++

/* Copyright (c) 2025 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_CHROMIUM_SRC_SQL_SQL_NAME_VARIANTS_H_
#define BRAVE_CHROMIUM_SRC_SQL_SQL_NAME_VARIANTS_H_
#define IsValidDatabaseTag IsValidDatabaseTag_ChomiumImpl
#include "../gen/sql/sql_name_variants.h" // IWYU pragma: export
#undef IsValidDatabaseTag
namespace sql_metrics {
// In Chromium this check ensures the histograms.xml sync, but we don't care
// about this because it's for server-side synchronization.
constexpr bool IsValidDatabaseTag(std::string_view s) {
return true;
}
} // namespace sql_metrics
#endif // BRAVE_CHROMIUM_SRC_SQL_SQL_NAME_VARIANTS_H_