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 <set> |
10 #include <string> | 10 #include <string> |
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 an application 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 explicit Entry(const Entry& other); |
28 ~Entry(); | 28 ~Entry(); |
29 | 29 |
30 std::unique_ptr<base::DictionaryValue> Serialize() const; | 30 std::unique_ptr<base::DictionaryValue> Serialize() const; |
31 | 31 |
32 // 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 |
33 // caller must assume ownership of the tree of Entrys by enumerating | 33 // caller must assume ownership of the tree of Entrys by enumerating |
34 // applications(). | 34 // services(). |
35 static std::unique_ptr<Entry> Deserialize(const base::DictionaryValue& value); | 35 static std::unique_ptr<Entry> Deserialize(const base::DictionaryValue& value); |
36 | 36 |
37 bool ProvidesClass(const std::string& clazz) const; | 37 bool ProvidesClass(const std::string& clazz) const; |
38 | 38 |
39 bool operator==(const Entry& other) const; | 39 bool operator==(const Entry& other) const; |
40 bool operator<(const Entry& other) const; | 40 bool operator<(const Entry& other) const; |
41 | 41 |
42 const std::string& name() const { return name_; } | 42 const std::string& name() const { return name_; } |
43 void set_name(const std::string& name) { name_ = name; } | 43 void set_name(const std::string& name) { name_ = name; } |
44 const base::FilePath& path() const { return path_; } | 44 const base::FilePath& path() const { return path_; } |
45 void set_path(const base::FilePath& path) { path_ = path; } | 45 void set_path(const base::FilePath& path) { path_ = path; } |
46 const std::string& qualifier() const { return qualifier_; } | 46 const std::string& qualifier() const { return qualifier_; } |
47 void set_qualifier(const std::string& qualifier) { qualifier_ = qualifier; } | 47 void set_qualifier(const std::string& qualifier) { qualifier_ = qualifier; } |
48 const std::string& display_name() const { return display_name_; } | 48 const std::string& display_name() const { return display_name_; } |
49 void set_display_name(const std::string& display_name) { | 49 void set_display_name(const std::string& display_name) { |
50 display_name_ = display_name; | 50 display_name_ = display_name; |
51 } | 51 } |
52 const shell::CapabilitySpec& capabilities() const { return capabilities_; } | 52 const shell::CapabilitySpec& capabilities() const { return capabilities_; } |
53 void set_capabilities(const shell::CapabilitySpec& capabilities) { | 53 void set_capabilities(const shell::CapabilitySpec& capabilities) { |
54 capabilities_ = capabilities; | 54 capabilities_ = capabilities; |
55 } | 55 } |
56 const Entry* package() const { return package_; } | 56 const Entry* package() const { return package_; } |
57 void set_package(Entry* package) { package_ = package; } | 57 void set_package(Entry* package) { package_ = package; } |
58 const std::set<Entry*>& applications() { return applications_; } | 58 const std::set<Entry*>& services() { return services_; } |
59 | 59 |
60 private: | 60 private: |
61 std::string name_; | 61 std::string name_; |
62 base::FilePath path_; | 62 base::FilePath path_; |
63 std::string qualifier_; | 63 std::string qualifier_; |
64 std::string display_name_; | 64 std::string display_name_; |
65 shell::CapabilitySpec capabilities_; | 65 shell::CapabilitySpec capabilities_; |
66 Entry* package_ = nullptr; | 66 Entry* package_ = nullptr; |
67 std::set<Entry*> applications_; | 67 std::set<Entry*> services_; |
68 }; | 68 }; |
69 | 69 |
70 } // namespace catalog | 70 } // namespace catalog |
71 | 71 |
72 namespace mojo { | 72 namespace mojo { |
73 template <> | 73 template <> |
74 struct TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry> { | 74 struct TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry> { |
75 static shell::mojom::ResolveResultPtr Convert(const catalog::Entry& input); | 75 static shell::mojom::ResolveResultPtr Convert(const catalog::Entry& input); |
76 }; | 76 }; |
77 | 77 |
78 template<> | 78 template<> |
79 struct TypeConverter<catalog::mojom::EntryPtr, catalog::Entry> { | 79 struct TypeConverter<catalog::mojom::EntryPtr, catalog::Entry> { |
80 static catalog::mojom::EntryPtr Convert(const catalog::Entry& input); | 80 static catalog::mojom::EntryPtr Convert(const catalog::Entry& input); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace mojo | 83 } // namespace mojo |
84 | 84 |
85 #endif // SERVICES_CATALOG_ENTRY_H_ | 85 #endif // SERVICES_CATALOG_ENTRY_H_ |
OLD | NEW |