| 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 namespace service_manager { | 10 namespace service_manager { |
| 11 | 11 |
| 12 // Represents the identity of an application. | 12 // Represents the identity of an application. |
| 13 // |name| is the structured name of the application. | 13 // |name| is the structured name of the application. |
| 14 // |instance| is a string that allows to tie a specific instance to another. A | 14 // |instance| is a string that allows to tie a specific instance to another. A |
| 15 // typical use case of instance is to control process grouping for a given name. | 15 // typical use case of instance is to control process grouping for a given name. |
| 16 class Identity { | 16 class Identity { |
| 17 public: | 17 public: |
| 18 Identity(); | 18 Identity(); |
| 19 Identity(const std::string& name, | 19 Identity(const std::string& name, |
| 20 const std::string& user_id); | 20 const std::string& user_id); |
| 21 Identity(const std::string& name, | 21 Identity(const std::string& name, |
| 22 const std::string& user_id, | 22 const std::string& user_id, |
| 23 const std::string& instance); | 23 const std::string& instance); |
| 24 Identity(const Identity& other); | 24 Identity(const Identity& other); |
| 25 ~Identity(); | 25 ~Identity(); |
| 26 | 26 |
| 27 bool operator<(const Identity& other) const; | 27 bool operator<(const Identity& other) const; |
| 28 bool is_null() const { return name_.empty(); } | |
| 29 bool operator==(const Identity& other) const; | 28 bool operator==(const Identity& other) const; |
| 29 bool IsValid() const; |
| 30 | 30 |
| 31 const std::string& name() const { return name_; } | 31 const std::string& name() const { return name_; } |
| 32 const std::string& user_id() const { return user_id_; } | 32 const std::string& user_id() const { return user_id_; } |
| 33 void set_user_id(const std::string& user_id) { user_id_ = user_id; } | 33 void set_user_id(const std::string& user_id) { user_id_ = user_id; } |
| 34 const std::string& instance() const { return instance_; } | 34 const std::string& instance() const { return instance_; } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 std::string name_; | 37 std::string name_; |
| 38 std::string user_id_; | 38 std::string user_id_; |
| 39 std::string instance_; | 39 std::string instance_; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace service_manager | 42 } // namespace service_manager |
| 43 | 43 |
| 44 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ | 44 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ |
| OLD | NEW |