| 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 #include "base/hash.h" |
| 11 |
| 10 namespace service_manager { | 12 namespace service_manager { |
| 11 | 13 |
| 12 // Represents the identity of an application. | 14 // Represents the identity of an application. |
| 13 // |name| is the structured name of the application. | 15 // |name| is the structured name of the application. |
| 14 // |instance| is a string that allows to tie a specific instance to another. A | 16 // |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. | 17 // typical use case of instance is to control process grouping for a given name. |
| 16 class Identity { | 18 class Identity { |
| 17 public: | 19 public: |
| 18 Identity(); | 20 Identity(); |
| 19 explicit Identity(const std::string& name); | 21 explicit Identity(const std::string& name); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 const std::string& instance() const { return instance_; } | 37 const std::string& instance() const { return instance_; } |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 std::string name_; | 40 std::string name_; |
| 39 std::string user_id_; | 41 std::string user_id_; |
| 40 std::string instance_; | 42 std::string instance_; |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 } // namespace service_manager | 45 } // namespace service_manager |
| 44 | 46 |
| 47 namespace std { |
| 48 |
| 49 template <> |
| 50 struct hash<service_manager::Identity> { |
| 51 std::size_t operator()(const service_manager::Identity& identity) const { |
| 52 return base::Hash(identity.name() + identity.user_id() + |
| 53 identity.instance()); |
| 54 } |
| 55 }; |
| 56 |
| 57 } // namespace std |
| 58 |
| 45 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ | 59 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_IDENTITY_H_ |
| OLD | NEW |