chromium/google_apis/gaia/core_account_id.h

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

#ifndef GOOGLE_APIS_GAIA_CORE_ACCOUNT_ID_H_
#define GOOGLE_APIS_GAIA_CORE_ACCOUNT_ID_H_

#include <ostream>
#include <string>
#include <vector>

#include "base/component_export.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"

// Represent the id of an account for interaction with GAIA.
//
// --------------------------------------------------------------------------
// DO NOT USE CoreAccountId AS A PERSISTENT IDENTIFIER OF AN ACCOUNT.
//
// Currently a CoreAccountId can be created from a Gaia ID or from an email
// that was canonicalized. We are in the process of migrating this identifier
// to always be created from a Gaia ID.
// Until the migration is complete, the value of a CoreAccountId value may
// change on start-up.
// --------------------------------------------------------------------------

struct COMPONENT_EXPORT(GOOGLE_APIS) CoreAccountId {};

COMPONENT_EXPORT()
bool operator<(const CoreAccountId& lhs, const CoreAccountId& rhs);

COMPONENT_EXPORT()
bool operator==(const CoreAccountId& lhs, const CoreAccountId& rhs);

COMPONENT_EXPORT()
bool operator!=(const CoreAccountId& lhs, const CoreAccountId& rhs);

COMPONENT_EXPORT()
std::ostream& operator<<(std::ostream& out, const CoreAccountId& a);

// Returns the values of the account ids in a vector. Useful especially for
// logs.
COMPONENT_EXPORT()
std::vector<std::string> ToStringList(
    const std::vector<CoreAccountId>& account_ids);

namespace std {
template <>
struct hash<CoreAccountId> {};
}  // namespace std

#endif  // GOOGLE_APIS_GAIA_CORE_ACCOUNT_ID_H_