Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: mojo/services/catalog/catalog.h

Issue 1775243002: Rename PackageManager->Catalog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@42cpi
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/services/catalog/DEPS ('k') | mojo/services/catalog/catalog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_ 5 #ifndef MOJO_SERVICES_CATALOG_CATALOG_H_
6 #define MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_ 6 #define MOJO_SERVICES_CATALOG_CATALOG_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "mojo/public/cpp/bindings/binding_set.h" 12 #include "mojo/public/cpp/bindings/binding_set.h"
13 #include "mojo/services/package_manager/public/interfaces/catalog.mojom.h" 13 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h"
14 #include "mojo/services/package_manager/public/interfaces/resolver.mojom.h" 14 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h"
15 #include "mojo/shell/public/cpp/interface_factory.h" 15 #include "mojo/shell/public/cpp/interface_factory.h"
16 #include "mojo/shell/public/cpp/shell_client.h" 16 #include "mojo/shell/public/cpp/shell_client.h"
17 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h" 17 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace package_manager { 20 namespace catalog {
21 // A set of names of interfaces that may be exposed to an application. 21 // A set of names of interfaces that may be exposed to an application.
22 using AllowedInterfaces = std::set<std::string>; 22 using AllowedInterfaces = std::set<std::string>;
23 // A map of allowed applications to allowed interface sets. See shell.mojom for 23 // A map of allowed applications to allowed interface sets. See shell.mojom for
24 // more details. 24 // more details.
25 using CapabilityFilter = std::map<std::string, AllowedInterfaces>; 25 using CapabilityFilter = std::map<std::string, AllowedInterfaces>;
26 26
27 // Static information about an application package known to the PackageManager. 27 // Static information about an application package known to the Catalog.
28 struct ApplicationInfo { 28 struct ApplicationInfo {
29 ApplicationInfo(); 29 ApplicationInfo();
30 ApplicationInfo(const ApplicationInfo& other); 30 ApplicationInfo(const ApplicationInfo& other);
31 ~ApplicationInfo(); 31 ~ApplicationInfo();
32 32
33 std::string name; 33 std::string name;
34 std::string qualifier; 34 std::string qualifier;
35 std::string display_name; 35 std::string display_name;
36 CapabilityFilter base_filter; 36 CapabilityFilter base_filter;
37 }; 37 };
38 38
39 // Implemented by an object that provides storage for the application catalog 39 // Implemented by an object that provides storage for the application catalog
40 // (e.g. in Chrome, preferences). The PackageManagerImpl is the canonical owner 40 // (e.g. in Chrome, preferences). The Catalog is the canonical owner of the
41 // of the contents of the store, so no one else must modify its contents. 41 // contents of the store, so no one else must modify its contents.
42 class ApplicationCatalogStore { 42 class Store {
43 public: 43 public:
44 // Value is a string. 44 // Value is a string.
45 static const char kNameKey[]; 45 static const char kNameKey[];
46 // Value is a string. 46 // Value is a string.
47 static const char kQualifierKey[]; 47 static const char kQualifierKey[];
48 // Value is a string. 48 // Value is a string.
49 static const char kDisplayNameKey[]; 49 static const char kDisplayNameKey[];
50 // Value is a dictionary that maps from the filter to a list of string 50 // Value is a dictionary that maps from the filter to a list of string
51 // interfaces. 51 // interfaces.
52 static const char kCapabilitiesKey[]; 52 static const char kCapabilitiesKey[];
53 53
54 virtual ~ApplicationCatalogStore() {} 54 virtual ~Store() {}
55 55
56 // Called during initialization to construct the PackageManagerImpl's catalog. 56 // Called during initialization to construct the Catalog's catalog.
57 // Returns a serialized list of the apps. Each entry in the returned list 57 // Returns a serialized list of the apps. Each entry in the returned list
58 // corresponds to an app (as a dictionary). Each dictionary has a name, 58 // corresponds to an app (as a dictionary). Each dictionary has a name,
59 // display name and capabilities. The return value is owned by the caller. 59 // display name and capabilities. The return value is owned by the caller.
60 virtual const base::ListValue* GetStore() = 0; 60 virtual const base::ListValue* GetStore() = 0;
61 61
62 // Write the catalog to the store. Called when the PackageManagerImpl learns 62 // Write the catalog to the store. Called when the Catalog learns of a newly
63 // of a newly encountered application. 63 // encountered application.
64 virtual void UpdateStore(scoped_ptr<base::ListValue> store) = 0; 64 virtual void UpdateStore(scoped_ptr<base::ListValue> store) = 0;
65 }; 65 };
66 66
67 class PackageManager 67 class Catalog
68 : public mojo::ShellClient, 68 : public mojo::ShellClient,
69 public mojo::InterfaceFactory<mojom::Resolver>, 69 public mojo::InterfaceFactory<mojom::Resolver>,
70 public mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>, 70 public mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>,
71 public mojo::InterfaceFactory<mojom::Catalog>, 71 public mojo::InterfaceFactory<mojom::Catalog>,
72 public mojom::Resolver, 72 public mojom::Resolver,
73 public mojo::shell::mojom::ShellResolver, 73 public mojo::shell::mojom::ShellResolver,
74 public mojom::Catalog { 74 public mojom::Catalog {
75 public: 75 public:
76 // If |register_schemes| is true, mojo: and exe: schemes are registered as 76 // If |register_schemes| is true, mojo: and exe: schemes are registered as
77 // "standard". 77 // "standard".
78 PackageManager(base::TaskRunner* blocking_pool, 78 Catalog(base::TaskRunner* blocking_pool, scoped_ptr<Store> store);
79 scoped_ptr<ApplicationCatalogStore> catalog); 79 ~Catalog() override;
80 ~PackageManager() override;
81 80
82 private: 81 private:
83 using MojoNameAliasMap = 82 using MojoNameAliasMap =
84 std::map<std::string, std::pair<std::string, std::string>>; 83 std::map<std::string, std::pair<std::string, std::string>>;
85 84
86 // mojo::ShellClient: 85 // mojo::ShellClient:
87 bool AcceptConnection(mojo::Connection* connection) override; 86 bool AcceptConnection(mojo::Connection* connection) override;
88 87
89 // mojo::InterfaceFactory<mojom::Resolver>: 88 // mojo::InterfaceFactory<mojom::Resolver>:
90 void Create(mojo::Connection* connection, 89 void Create(mojo::Connection* connection,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void SerializeCatalog(); 136 void SerializeCatalog();
138 137
139 // Construct a catalog entry from |dictionary|. 138 // Construct a catalog entry from |dictionary|.
140 const ApplicationInfo& DeserializeApplication( 139 const ApplicationInfo& DeserializeApplication(
141 const base::DictionaryValue* dictionary); 140 const base::DictionaryValue* dictionary);
142 141
143 GURL GetManifestURL(const std::string& name); 142 GURL GetManifestURL(const std::string& name);
144 143
145 // Called once the manifest has been read. |pm| may be null at this point, 144 // Called once the manifest has been read. |pm| may be null at this point,
146 // but |callback| must be run. 145 // but |callback| must be run.
147 static void OnReadManifest(base::WeakPtr<PackageManager> pm, 146 static void OnReadManifest(base::WeakPtr<Catalog> catalog,
148 const std::string& name, 147 const std::string& name,
149 const ResolveMojoNameCallback& callback, 148 const ResolveMojoNameCallback& callback,
150 scoped_ptr<base::Value> manifest); 149 scoped_ptr<base::Value> manifest);
151 150
152 // Called once the manifest is read and |this| hasn't been deleted. 151 // Called once the manifest is read and |this| hasn't been deleted.
153 void OnReadManifestImpl(const std::string& name, 152 void OnReadManifestImpl(const std::string& name,
154 const ResolveMojoNameCallback& callback, 153 const ResolveMojoNameCallback& callback,
155 scoped_ptr<base::Value> manifest); 154 scoped_ptr<base::Value> manifest);
156 155
157 base::TaskRunner* blocking_pool_; 156 base::TaskRunner* blocking_pool_;
158 GURL system_package_dir_; 157 GURL system_package_dir_;
159 158
160 mojo::BindingSet<mojom::Resolver> resolver_bindings_; 159 mojo::BindingSet<mojom::Resolver> resolver_bindings_;
161 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; 160 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_;
162 mojo::BindingSet<mojom::Catalog> catalog_bindings_; 161 mojo::BindingSet<mojom::Catalog> catalog_bindings_;
163 162
164 scoped_ptr<ApplicationCatalogStore> catalog_store_; 163 scoped_ptr<Store> store_;
165 std::map<std::string, ApplicationInfo> catalog_; 164 std::map<std::string, ApplicationInfo> catalog_;
166 165
167 // Used when an app handles multiple names. Maps from app (as name) to name of 166 // Used when an app handles multiple names. Maps from app (as name) to name of
168 // app that is responsible for handling it. The value is a pair of the name of 167 // app that is responsible for handling it. The value is a pair of the name of
169 // the handler along with a qualifier. 168 // the handler along with a qualifier.
170 MojoNameAliasMap mojo_name_aliases_; 169 MojoNameAliasMap mojo_name_aliases_;
171 170
172 std::map<std::string, std::string> qualifiers_; 171 std::map<std::string, std::string> qualifiers_;
173 172
174 base::WeakPtrFactory<PackageManager> weak_factory_; 173 base::WeakPtrFactory<Catalog> weak_factory_;
175 174
176 DISALLOW_COPY_AND_ASSIGN(PackageManager); 175 DISALLOW_COPY_AND_ASSIGN(Catalog);
177 }; 176 };
178 177
179 } // namespace package_manager 178 } // namespace catalog
180 179
181 #endif // MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_ 180 #endif // MOJO_SERVICES_CATALOG_CATALOG_H_
OLDNEW
« no previous file with comments | « mojo/services/catalog/DEPS ('k') | mojo/services/catalog/catalog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698