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_CATALOG_ENTRY_H_ | 5 #ifndef SERVICES_CATALOG_ENTRY_H_ |
6 #define SERVICES_CATALOG_ENTRY_H_ | 6 #define SERVICES_CATALOG_ENTRY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
| 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "services/catalog/public/interfaces/catalog.mojom.h" | 13 #include "services/catalog/public/interfaces/catalog.mojom.h" |
14 #include "services/shell/public/cpp/capabilities.h" | 14 #include "services/shell/public/cpp/capabilities.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 } | 18 } |
19 | 19 |
20 namespace catalog { | 20 namespace catalog { |
21 | 21 |
22 // Static information about a service package known to the Catalog. | 22 // Static information about a service package known to the Catalog. |
23 class Entry { | 23 class Entry { |
24 public: | 24 public: |
25 Entry(); | 25 Entry(); |
26 explicit Entry(const std::string& name); | 26 explicit Entry(const std::string& name); |
| 27 explicit Entry(const Entry& other); |
27 ~Entry(); | 28 ~Entry(); |
28 | 29 |
29 std::unique_ptr<base::DictionaryValue> Serialize() const; | 30 std::unique_ptr<base::DictionaryValue> Serialize() const; |
30 | 31 |
31 // If the constructed Entry is a package that provides other Entrys, the | 32 // If the constructed Entry is a package that provides other Entrys, the |
32 // caller must assume ownership of the tree of Entrys by enumerating | 33 // caller must assume ownership of the tree of Entrys by enumerating |
33 // services(). | 34 // services(). |
34 static std::unique_ptr<Entry> Deserialize(const base::DictionaryValue& value); | 35 static std::unique_ptr<Entry> Deserialize(const base::DictionaryValue& value); |
35 | 36 |
36 bool ProvidesClass(const std::string& clazz) const; | 37 bool ProvidesClass(const std::string& clazz) const; |
(...skipping 10 matching lines...) Expand all Loading... |
47 const std::string& display_name() const { return display_name_; } | 48 const std::string& display_name() const { return display_name_; } |
48 void set_display_name(const std::string& display_name) { | 49 void set_display_name(const std::string& display_name) { |
49 display_name_ = display_name; | 50 display_name_ = display_name; |
50 } | 51 } |
51 const shell::CapabilitySpec& capabilities() const { return capabilities_; } | 52 const shell::CapabilitySpec& capabilities() const { return capabilities_; } |
52 void set_capabilities(const shell::CapabilitySpec& capabilities) { | 53 void set_capabilities(const shell::CapabilitySpec& capabilities) { |
53 capabilities_ = capabilities; | 54 capabilities_ = capabilities; |
54 } | 55 } |
55 const Entry* package() const { return package_; } | 56 const Entry* package() const { return package_; } |
56 void set_package(Entry* package) { package_ = package; } | 57 void set_package(Entry* package) { package_ = package; } |
57 | 58 const std::set<Entry*>& services() { return services_; } |
58 std::vector<std::unique_ptr<Entry>> TakeChildren() { | |
59 return std::move(children_); | |
60 } | |
61 | 59 |
62 private: | 60 private: |
63 std::string name_; | 61 std::string name_; |
64 base::FilePath path_; | 62 base::FilePath path_; |
65 std::string qualifier_; | 63 std::string qualifier_; |
66 std::string display_name_; | 64 std::string display_name_; |
67 shell::CapabilitySpec capabilities_; | 65 shell::CapabilitySpec capabilities_; |
68 Entry* package_ = nullptr; | 66 Entry* package_ = nullptr; |
69 std::vector<std::unique_ptr<Entry>> children_; | 67 std::set<Entry*> services_; |
70 }; | 68 }; |
71 | 69 |
72 } // namespace catalog | 70 } // namespace catalog |
73 | 71 |
74 namespace mojo { | 72 namespace mojo { |
75 template <> | 73 template <> |
76 struct TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry> { | 74 struct TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry> { |
77 static shell::mojom::ResolveResultPtr Convert(const catalog::Entry& input); | 75 static shell::mojom::ResolveResultPtr Convert(const catalog::Entry& input); |
78 }; | 76 }; |
79 | 77 |
80 template<> | 78 template<> |
81 struct TypeConverter<catalog::mojom::EntryPtr, catalog::Entry> { | 79 struct TypeConverter<catalog::mojom::EntryPtr, catalog::Entry> { |
82 static catalog::mojom::EntryPtr Convert(const catalog::Entry& input); | 80 static catalog::mojom::EntryPtr Convert(const catalog::Entry& input); |
83 }; | 81 }; |
84 | 82 |
85 } // namespace mojo | 83 } // namespace mojo |
86 | 84 |
87 #endif // SERVICES_CATALOG_ENTRY_H_ | 85 #endif // SERVICES_CATALOG_ENTRY_H_ |
OLD | NEW |