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