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

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

Issue 1776513003: Allow client process information to be passed via Connector::Connect(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/mojo_base.gyp ('k') | mojo/services/package_manager/package_manager.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_PACKAGE_MANAGER_PACKAGE_MANAGER_H_
6 #define MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_ 6 #define MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_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/package_manager/public/interfaces/catalog.mojom.h"
14 #include "mojo/services/package_manager/public/interfaces/resolver.mojom.h" 14 #include "mojo/services/package_manager/public/interfaces/resolver.mojom.h"
15 #include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h "
16 #include "mojo/shell/public/cpp/interface_factory.h" 15 #include "mojo/shell/public/cpp/interface_factory.h"
17 #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"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace package_manager { 20 namespace package_manager {
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 PackageManager.
(...skipping 29 matching lines...) Expand all
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 PackageManagerImpl learns
63 // of a newly encountered application. 63 // of a newly 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 : public mojo::ShellClient, 67 class PackageManager
68 public mojo::InterfaceFactory<mojom::Resolver>, 68 : public mojo::ShellClient,
69 public mojo::InterfaceFactory<mojom::ShellResolver>, 69 public mojo::InterfaceFactory<mojom::Resolver>,
70 public mojo::InterfaceFactory<mojom::Catalog>, 70 public mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>,
71 public mojom::Resolver, 71 public mojo::InterfaceFactory<mojom::Catalog>,
72 public mojom::ShellResolver, 72 public mojom::Resolver,
73 public mojom::Catalog { 73 public mojo::shell::mojom::ShellResolver,
74 public mojom::Catalog {
74 public: 75 public:
75 // 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
76 // "standard". 77 // "standard".
77 PackageManager(base::TaskRunner* blocking_pool, 78 PackageManager(base::TaskRunner* blocking_pool,
78 scoped_ptr<ApplicationCatalogStore> catalog); 79 scoped_ptr<ApplicationCatalogStore> catalog);
79 ~PackageManager() override; 80 ~PackageManager() override;
80 81
81 private: 82 private:
82 using MojoNameAliasMap = 83 using MojoNameAliasMap =
83 std::map<std::string, std::pair<std::string, std::string>>; 84 std::map<std::string, std::pair<std::string, std::string>>;
84 85
85 // mojo::ShellClient: 86 // mojo::ShellClient:
86 bool AcceptConnection(mojo::Connection* connection) override; 87 bool AcceptConnection(mojo::Connection* connection) override;
87 88
88 // mojo::InterfaceFactory<mojom::Resolver>: 89 // mojo::InterfaceFactory<mojom::Resolver>:
89 void Create(mojo::Connection* connection, 90 void Create(mojo::Connection* connection,
90 mojom::ResolverRequest request) override; 91 mojom::ResolverRequest request) override;
91 92
92 // mojo::InterfaceFactory<mojom::ShellResolver>: 93 // mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>:
93 void Create(mojo::Connection* connection, 94 void Create(mojo::Connection* connection,
94 mojom::ShellResolverRequest request) override; 95 mojo::shell::mojom::ShellResolverRequest request) override;
95 96
96 // mojo::InterfaceFactory<mojom::Catalog>: 97 // mojo::InterfaceFactory<mojom::Catalog>:
97 void Create(mojo::Connection* connection, 98 void Create(mojo::Connection* connection,
98 mojom::CatalogRequest request) override; 99 mojom::CatalogRequest request) override;
99 100
100 // mojom::Resolver: 101 // mojom::Resolver:
101 void ResolveResponse( 102 void ResolveResponse(
102 mojo::URLResponsePtr response, 103 mojo::URLResponsePtr response,
103 const ResolveResponseCallback& callback) override; 104 const ResolveResponseCallback& callback) override;
104 void ResolveInterfaces(mojo::Array<mojo::String> interfaces, 105 void ResolveInterfaces(mojo::Array<mojo::String> interfaces,
105 const ResolveInterfacesCallback& callback) override; 106 const ResolveInterfacesCallback& callback) override;
106 void ResolveMIMEType(const mojo::String& mime_type, 107 void ResolveMIMEType(const mojo::String& mime_type,
107 const ResolveMIMETypeCallback& callback) override; 108 const ResolveMIMETypeCallback& callback) override;
108 void ResolveProtocolScheme( 109 void ResolveProtocolScheme(
109 const mojo::String& scheme, 110 const mojo::String& scheme,
110 const ResolveProtocolSchemeCallback& callback) override; 111 const ResolveProtocolSchemeCallback& callback) override;
111 112
112 // mojom::ShellResolver: 113 // mojo::shell::mojom::ShellResolver:
113 void ResolveMojoName(const mojo::String& mojo_name, 114 void ResolveMojoName(const mojo::String& mojo_name,
114 const ResolveMojoNameCallback& callback) override; 115 const ResolveMojoNameCallback& callback) override;
115 116
116 // mojom::Catalog: 117 // mojom::Catalog:
117 void GetEntries(mojo::Array<mojo::String> names, 118 void GetEntries(mojo::Array<mojo::String> names,
118 const GetEntriesCallback& callback) override; 119 const GetEntriesCallback& callback) override;
119 120
120 // Completes resolving a Mojo name from the Shell after the resolved name has 121 // Completes resolving a Mojo name from the Shell after the resolved name has
121 // been added to the catalog and the manifest read. 122 // been added to the catalog and the manifest read.
122 void CompleteResolveMojoName(const std::string& resolved_name, 123 void CompleteResolveMojoName(const std::string& resolved_name,
(...skipping 27 matching lines...) Expand all
150 151
151 // Called once the manifest is read and |this| hasn't been deleted. 152 // Called once the manifest is read and |this| hasn't been deleted.
152 void OnReadManifestImpl(const std::string& name, 153 void OnReadManifestImpl(const std::string& name,
153 const ResolveMojoNameCallback& callback, 154 const ResolveMojoNameCallback& callback,
154 scoped_ptr<base::Value> manifest); 155 scoped_ptr<base::Value> manifest);
155 156
156 base::TaskRunner* blocking_pool_; 157 base::TaskRunner* blocking_pool_;
157 GURL system_package_dir_; 158 GURL system_package_dir_;
158 159
159 mojo::BindingSet<mojom::Resolver> resolver_bindings_; 160 mojo::BindingSet<mojom::Resolver> resolver_bindings_;
160 mojo::BindingSet<mojom::ShellResolver> shell_resolver_bindings_; 161 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_;
161 mojo::BindingSet<mojom::Catalog> catalog_bindings_; 162 mojo::BindingSet<mojom::Catalog> catalog_bindings_;
162 163
163 scoped_ptr<ApplicationCatalogStore> catalog_store_; 164 scoped_ptr<ApplicationCatalogStore> catalog_store_;
164 std::map<std::string, ApplicationInfo> catalog_; 165 std::map<std::string, ApplicationInfo> catalog_;
165 166
166 // Used when an app handles multiple names. Maps from app (as name) to name of 167 // Used when an app handles multiple names. Maps from app (as name) to name of
167 // app that is responsible for handling it. The value is a pair of the name of 168 // app that is responsible for handling it. The value is a pair of the name of
168 // the handler along with a qualifier. 169 // the handler along with a qualifier.
169 MojoNameAliasMap mojo_name_aliases_; 170 MojoNameAliasMap mojo_name_aliases_;
170 171
171 std::map<std::string, std::string> qualifiers_; 172 std::map<std::string, std::string> qualifiers_;
172 173
173 base::WeakPtrFactory<PackageManager> weak_factory_; 174 base::WeakPtrFactory<PackageManager> weak_factory_;
174 175
175 DISALLOW_COPY_AND_ASSIGN(PackageManager); 176 DISALLOW_COPY_AND_ASSIGN(PackageManager);
176 }; 177 };
177 178
178 } // namespace package_manager 179 } // namespace package_manager
179 180
180 #endif // MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_ 181 #endif // MOJO_SERVICES_PACKAGE_MANAGER_PACKAGE_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/mojo_base.gyp ('k') | mojo/services/package_manager/package_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698