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

Side by Side Diff: mojo/shell/shell.h

Issue 1769163002: Add a instance groups to Connect(), and introduce an Identity struct. (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/shell/runner/host/child_process_host.h ('k') | mojo/shell/shell.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SHELL_SHELL_H_ 5 #ifndef MOJO_SHELL_SHELL_H_
6 #define MOJO_SHELL_SHELL_H_ 6 #define MOJO_SHELL_SHELL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/public/cpp/bindings/binding_set.h" 14 #include "mojo/public/cpp/bindings/binding_set.h"
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
16 #include "mojo/services/package_manager/package_manager.h" 16 #include "mojo/services/package_manager/package_manager.h"
17 #include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h " 17 #include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h "
18 #include "mojo/shell/connect_params.h" 18 #include "mojo/shell/connect_params.h"
19 #include "mojo/shell/identity.h"
20 #include "mojo/shell/loader.h" 19 #include "mojo/shell/loader.h"
21 #include "mojo/shell/native_runner.h" 20 #include "mojo/shell/native_runner.h"
21 #include "mojo/shell/public/cpp/identity.h"
22 #include "mojo/shell/public/cpp/interface_factory.h" 22 #include "mojo/shell/public/cpp/interface_factory.h"
23 #include "mojo/shell/public/cpp/shell_client.h" 23 #include "mojo/shell/public/cpp/shell_client.h"
24 #include "mojo/shell/public/interfaces/connector.mojom.h" 24 #include "mojo/shell/public/interfaces/connector.mojom.h"
25 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 25 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
26 #include "mojo/shell/public/interfaces/shell.mojom.h" 26 #include "mojo/shell/public/interfaces/shell.mojom.h"
27 #include "mojo/shell/public/interfaces/shell_client.mojom.h" 27 #include "mojo/shell/public/interfaces/shell_client.mojom.h"
28 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" 28 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
29 29
30 namespace base { 30 namespace base {
31 class FilePath; 31 class FilePath;
32 class SequencedWorkerPool; 32 class SequencedWorkerPool;
33 } 33 }
34 34
35 namespace mojo { 35 namespace mojo {
36 class ShellConnection; 36 class ShellConnection;
37 namespace shell { 37 namespace shell {
38 38
39 // A set of names of interfaces that may be exposed to an application.
40 using AllowedInterfaces = std::set<std::string>;
41 // A map of allowed applications to allowed interface sets. See shell.mojom for
42 // more details.
43 using CapabilityFilter = std::map<std::string, AllowedInterfaces>;
44
45 // Creates an identity for the Shell, used when the Shell connects to
46 // applications.
47 Identity CreateShellIdentity();
48
49 // Returns a capability filter that allows an application to connect to any
50 // other application and any service exposed by other applications.
51 CapabilityFilter GetPermissiveCapabilityFilter();
52
53 // Returns the set of interfaces that an application instance with |filter| is
54 // allowed to see from an instance with |identity|.
55 AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter,
56 const Identity& identity);
57
39 class Shell : public ShellClient { 58 class Shell : public ShellClient {
40 public: 59 public:
41 // API for testing. 60 // API for testing.
42 class TestAPI { 61 class TestAPI {
43 public: 62 public:
44 explicit TestAPI(Shell* shell); 63 explicit TestAPI(Shell* shell);
45 ~TestAPI(); 64 ~TestAPI();
46 65
47 // Returns true if there is a Instance for this name. 66 // Returns true if there is a Instance for this name.
48 bool HasRunningInstanceForName(const std::string& name) const; 67 bool HasRunningInstanceForName(const std::string& name) const;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 Instance* GetExistingInstance(const Identity& identity) const; 131 Instance* GetExistingInstance(const Identity& identity) const;
113 132
114 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); 133 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid);
115 134
116 // Attempt to complete the connection requested by |params| by connecting to 135 // Attempt to complete the connection requested by |params| by connecting to
117 // an existing instance. If there is an existing instance, |params| is taken, 136 // an existing instance. If there is an existing instance, |params| is taken,
118 // and this function returns true. 137 // and this function returns true.
119 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); 138 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params);
120 139
121 Instance* CreateInstance(const Identity& target_id, 140 Instance* CreateInstance(const Identity& target_id,
141 const CapabilityFilter& filter,
122 mojom::ShellClientRequest* request); 142 mojom::ShellClientRequest* request);
123 143
124 // Called from the instance implementing mojom::Shell. |user_id| must be 144 // Called from the instance implementing mojom::Shell. |user_id| must be
125 // resolved by the instance (i.e. must not be mojom::kInheritUserID). 145 // resolved by the instance (i.e. must not be mojom::kInheritUserID).
126 void CreateInstanceForFactory( 146 void CreateInstanceForFactory(
127 mojom::ShellClientFactoryPtr factory, 147 mojom::ShellClientFactoryPtr factory,
128 const std::string& name, 148 const std::string& name,
129 const std::string& user_id, 149 const std::string& user_id,
130 mojom::CapabilityFilterPtr filter, 150 mojom::CapabilityFilterPtr filter,
131 mojom::PIDReceiverRequest pid_receiver); 151 mojom::PIDReceiverRequest pid_receiver);
(...skipping 13 matching lines...) Expand all
145 165
146 // Callback when remote PackageManager resolves mojo:foo to mojo:bar. 166 // Callback when remote PackageManager resolves mojo:foo to mojo:bar.
147 // |params| are the params passed to Connect(). 167 // |params| are the params passed to Connect().
148 // |resolved_name| is the mojo: name identifying the physical package 168 // |resolved_name| is the mojo: name identifying the physical package
149 // application. 169 // application.
150 // |file_url| is the resolved file:// URL of the physical package. 170 // |file_url| is the resolved file:// URL of the physical package.
151 // |base_filter| is the CapabilityFilter the requested application should be 171 // |base_filter| is the CapabilityFilter the requested application should be
152 // run with, from its manifest. 172 // run with, from its manifest.
153 void OnGotResolvedName(scoped_ptr<ConnectParams> params, 173 void OnGotResolvedName(scoped_ptr<ConnectParams> params,
154 const String& resolved_name, 174 const String& resolved_name,
155 const String& resolved_qualifier, 175 const String& resolved_instance,
156 mojom::CapabilityFilterPtr base_filter, 176 mojom::CapabilityFilterPtr base_filter,
157 const String& file_url); 177 const String& file_url);
158 178
159 // Tries to load |target| with an Loader. Returns true if one was registered 179 // Tries to load |target| with an Loader. Returns true if one was registered
160 // and it was loaded, in which case |request| is taken. 180 // and it was loaded, in which case |request| is taken.
161 bool LoadWithLoader(const Identity& target, 181 bool LoadWithLoader(const Identity& target,
162 mojom::ShellClientRequest* request); 182 mojom::ShellClientRequest* request);
163 183
164 // Returns the appropriate loader for |name|, or the default loader if there 184 // Returns the appropriate loader for |name|, or the default loader if there
165 // is no loader configured for the name. 185 // is no loader configured for the name.
(...skipping 28 matching lines...) Expand all
194 214
195 DISALLOW_COPY_AND_ASSIGN(Shell); 215 DISALLOW_COPY_AND_ASSIGN(Shell);
196 }; 216 };
197 217
198 mojom::Connector::ConnectCallback EmptyConnectCallback(); 218 mojom::Connector::ConnectCallback EmptyConnectCallback();
199 219
200 } // namespace shell 220 } // namespace shell
201 } // namespace mojo 221 } // namespace mojo
202 222
203 #endif // MOJO_SHELL_SHELL_H_ 223 #endif // MOJO_SHELL_SHELL_H_
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/child_process_host.h ('k') | mojo/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698