// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_DATABASE_SIGNAL_KEY_H_ #define COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_DATABASE_SIGNAL_KEY_H_ #include <cstdint> #include <ostream> #include <string> #include "base/time/time.h" namespace segmentation_platform { // The SignalKey is used for identifying a particular record in the // SignalDatabase. The format is defined in go/chrome-segmentation-storage-mvp. // // It provides functionality to convert to and from a binary format. The format // for this binary key must never change on a single device, so an internal // representation for this, SignalKeyInternal, is used. // // The SignalKey is not meant to be used by external clients in any way, // and should be considered as an internal implementation detail of the // SignalDatabase. // // The binary representation of the key does not store any resolution smaller // than seconds, so any constructed SignalKey is immediately stripped of // resolutions smaller than 1 second to ensure a SignalKey which has been // converted to a binary key and back again matches the original SignalKey. // // Since the binary representation is not human readable, the struct also // supports being streamed or by calling ToDebugString(), which will make it be // presented using this format: // {kind=..., name_hash=..., range_start=..., range_start=...} which is useful // for debugging. // // The binary representation of a key can be lexicographically compared. The // fields are in the following order: kind, name_hash, range_start, range_end. class SignalKey { … }; std::ostream& operator<<(std::ostream& os, const SignalKey& key); } // namespace segmentation_platform #endif // COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_DATABASE_SIGNAL_KEY_H_