| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "services/service_manager/public/cpp/identity.h" | |
| 6 | |
| 7 #include "base/guid.h" | |
| 8 #include "services/service_manager/public/interfaces/connector.mojom.h" | |
| 9 | |
| 10 namespace service_manager { | |
| 11 | |
| 12 Identity::Identity() : Identity("") {} | |
| 13 | |
| 14 Identity::Identity(const std::string& name) | |
| 15 : Identity(name, mojom::kInheritUserID) {} | |
| 16 | |
| 17 Identity::Identity(const std::string& name, const std::string& user_id) | |
| 18 : Identity(name, user_id, "") {} | |
| 19 | |
| 20 Identity::Identity(const std::string& name, const std::string& user_id, | |
| 21 const std::string& instance) | |
| 22 : name_(name), | |
| 23 user_id_(user_id), | |
| 24 instance_(instance) { | |
| 25 DCHECK(!user_id.empty()); | |
| 26 DCHECK(base::IsValidGUID(user_id)); | |
| 27 } | |
| 28 | |
| 29 Identity::Identity(const Identity& other) = default; | |
| 30 | |
| 31 Identity::~Identity() {} | |
| 32 | |
| 33 bool Identity::operator<(const Identity& other) const { | |
| 34 if (name_ != other.name_) | |
| 35 return name_ < other.name_; | |
| 36 if (instance_ != other.instance_) | |
| 37 return instance_ < other.instance_; | |
| 38 return user_id_ < other.user_id_; | |
| 39 } | |
| 40 | |
| 41 bool Identity::operator==(const Identity& other) const { | |
| 42 return other.name_ == name_ && other.instance_ == instance_ && | |
| 43 other.user_id_ == user_id_; | |
| 44 } | |
| 45 | |
| 46 bool Identity::IsValid() const { | |
| 47 return !name_.empty() && base::IsValidGUID(user_id_); | |
| 48 } | |
| 49 | |
| 50 } // namespace service_manager | |
| OLD | NEW |