summaryrefslogtreecommitdiff
path: root/chromium/components/account_manager_core/account.cc
blob: 43a66cd3108b2691cb01a6236bc5c19cff5a788f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/account_manager_core/account.h"

#include "base/check.h"

namespace account_manager {

AccountKey::AccountKey(const std::string& id, AccountType type)
    : id_(id), account_type_(type) {
  DCHECK(!id_.empty());
}

bool AccountKey::operator<(const AccountKey& other) const {
  return std::tie(id_, account_type_) <
         std::tie(other.id_, other.account_type_);
}

bool AccountKey::operator==(const AccountKey& other) const {
  return std::tie(id_, account_type_) ==
         std::tie(other.id_, other.account_type_);
}

bool AccountKey::operator!=(const AccountKey& other) const {
  return !(*this == other);
}

bool Account::operator<(const Account& other) const {
  return std::tie(key, raw_email) < std::tie(other.key, other.raw_email);
}

bool Account::operator==(const Account& other) const {
  return std::tie(key, raw_email) == std::tie(other.key, other.raw_email);
}

bool Account::operator!=(const Account& other) const {
  return !(*this == other);
}

COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
std::ostream& operator<<(std::ostream& os, const AccountType& account_type) {
  switch (account_type) {
    case account_manager::AccountType::kGaia:
      os << "Gaia";
      break;
    case account_manager::AccountType::kActiveDirectory:
      os << "ActiveDirectory";
      break;
  }

  return os;
}

COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
std::ostream& operator<<(std::ostream& os, const AccountKey& account_key) {
  os << "{ id: " << account_key.id()
     << ", account_type: " << account_key.account_type() << " }";

  return os;
}

}  // namespace account_manager