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

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

Issue 1787083003: Use chrome manifest with embedded shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shell-no-wait
Patch Set: rebase 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 | « content/browser/mojo/chrome_manifest.json ('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
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Typically the creator of the Shell will use this to determine when some set 65 // Typically the creator of the Shell will use this to determine when some set
66 // of instances it created are destroyed, so it can shut down. 66 // of instances it created are destroyed, so it can shut down.
67 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); 67 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback);
68 68
69 // Completes a connection between a source and target application as defined 69 // Completes a connection between a source and target application as defined
70 // by |params|, exchanging InterfaceProviders between them. If no existing 70 // by |params|, exchanging InterfaceProviders between them. If no existing
71 // instance of the target application is running, one will be loaded. 71 // instance of the target application is running, one will be loaded.
72 void Connect(scoped_ptr<ConnectParams> params); 72 void Connect(scoped_ptr<ConnectParams> params);
73 73
74 // Creates a new Instance identified as |name|. This is intended for use by 74 // Creates a new Instance identified as |name|. This is intended for use by
75 // the Shell's embedder to register itself with the shell. The name is never 75 // the Shell's embedder to register itself with the shell. This must only be
76 // resolved and there must not be an existing instance associated with it. 76 // called once.
77 // This must only be called once.
78 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name); 77 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name);
79 78
80 // Sets the default Loader to be used if not overridden by SetLoaderForName(). 79 // Sets the default Loader to be used if not overridden by SetLoaderForName().
81 void set_default_loader(scoped_ptr<Loader> loader) { 80 void set_default_loader(scoped_ptr<Loader> loader) {
82 default_loader_ = std::move(loader); 81 default_loader_ = std::move(loader);
83 } 82 }
84 83
85 // Sets a Loader to be used for a specific name. 84 // Sets a Loader to be used for a specific name.
86 void SetLoaderForName(scoped_ptr<Loader> loader, const std::string& name); 85 void SetLoaderForName(scoped_ptr<Loader> loader, const std::string& name);
87 86
(...skipping 11 matching lines...) Expand all
99 void InitCatalog(mojom::ShellClientPtr catalog); 98 void InitCatalog(mojom::ShellClientPtr catalog);
100 99
101 // Destroys all Shell-ends of connections established with Applications. 100 // Destroys all Shell-ends of connections established with Applications.
102 // Applications connected by this Shell will observe pipe errors and have a 101 // Applications connected by this Shell will observe pipe errors and have a
103 // chance to shutdown. 102 // chance to shutdown.
104 void TerminateShellConnections(); 103 void TerminateShellConnections();
105 104
106 // Removes a Instance when it encounters an error. 105 // Removes a Instance when it encounters an error.
107 void OnInstanceError(Instance* instance); 106 void OnInstanceError(Instance* instance);
108 107
108 // Completes a connection between a source and target application as defined
109 // by |params|, exchanging InterfaceProviders between them. If no existing
110 // instance of the target application is running, one will be loaded.
111 //
112 // If |client| is not null, there must not be an instance of the target
113 // application already running. The shell will create a new instance and use
114 // |client| to control.
115 void Connect(scoped_ptr<ConnectParams> params, mojom::ShellClientPtr client);
116
109 // Returns a running instance matching |identity|. 117 // Returns a running instance matching |identity|.
110 Instance* GetExistingInstance(const Identity& identity) const; 118 Instance* GetExistingInstance(const Identity& identity) const;
111 // Like GetExistingInstance, but if no instance for |identity.user_id()| is 119 // Like GetExistingInstance, but if no instance for |identity.user_id()| is
112 // found, looks for kRootUserID too. 120 // found, looks for kRootUserID too.
113 Instance* GetExistingOrRootInstance(const Identity& identity) const; 121 Instance* GetExistingOrRootInstance(const Identity& identity) const;
114 122
115 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); 123 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid);
116 124
117 // Attempt to complete the connection requested by |params| by connecting to 125 // Attempt to complete the connection requested by |params| by connecting to
118 // an existing instance. If there is an existing instance, |params| is taken, 126 // an existing instance. If there is an existing instance, |params| is taken,
(...skipping 13 matching lines...) Expand all
132 mojom::ShellClientRequest request); 140 mojom::ShellClientRequest request);
133 // Returns a running ShellClientFactory for |shell_client_factory_identity|, 141 // Returns a running ShellClientFactory for |shell_client_factory_identity|,
134 // if there is not one running one is started for |source_identity|. 142 // if there is not one running one is started for |source_identity|.
135 mojom::ShellClientFactory* GetShellClientFactory( 143 mojom::ShellClientFactory* GetShellClientFactory(
136 const Identity& shell_client_factory_identity, 144 const Identity& shell_client_factory_identity,
137 const Identity& source_identity); 145 const Identity& source_identity);
138 void OnShellClientFactoryLost(const Identity& which);; 146 void OnShellClientFactoryLost(const Identity& which);;
139 147
140 // Callback when remote Catalog resolves mojo:foo to mojo:bar. 148 // Callback when remote Catalog resolves mojo:foo to mojo:bar.
141 // |params| are the params passed to Connect(). 149 // |params| are the params passed to Connect().
150 // |client| if provided is a ShellClientPtr which should be used to manage the
151 // new application instance. This may be null.
142 // |resolved_name| is the mojo: name identifying the physical package 152 // |resolved_name| is the mojo: name identifying the physical package
143 // application. 153 // application.
144 // |file_url| is the resolved file:// URL of the physical package. 154 // |file_url| is the resolved file:// URL of the physical package.
145 // |base_filter| is the CapabilitySpecPtr the requested application should be 155 // |capabilities| is the CapabilitySpecPtr the requested application should be
146 // run with, from its manifest. 156 // run with, from its manifest.
147 void OnGotResolvedName(scoped_ptr<ConnectParams> params, 157 void OnGotResolvedName(scoped_ptr<ConnectParams> params,
158 mojom::ShellClientPtr client,
148 const String& resolved_name, 159 const String& resolved_name,
149 const String& resolved_instance, 160 const String& resolved_instance,
150 mojom::CapabilitySpecPtr capabilities, 161 mojom::CapabilitySpecPtr capabilities,
151 const String& file_url); 162 const String& file_url);
152 163
153 // Tries to load |target| with an Loader. Returns true if one was registered 164 // Tries to load |target| with an Loader. Returns true if one was registered
154 // and it was loaded, in which case |request| is taken. 165 // and it was loaded, in which case |request| is taken.
155 bool LoadWithLoader(const Identity& target, 166 bool LoadWithLoader(const Identity& target,
156 mojom::ShellClientRequest* request); 167 mojom::ShellClientRequest* request);
157 168
158 // Returns the appropriate loader for |name|, or the default loader if there 169 // Returns the appropriate loader for |name|, or the default loader if there
159 // is no loader configured for the name. 170 // is no loader configured for the name.
160 Loader* GetLoaderForName(const std::string& name); 171 Loader* GetLoaderForName(const std::string& name);
161 172
162 void CleanupRunner(NativeRunner* runner); 173 void CleanupRunner(NativeRunner* runner);
163 174
164 mojom::ShellResolverPtr shell_resolver_; 175 mojom::ShellResolverPtr shell_resolver_;
165 176
166 // Loader management. 177 // Loader management.
167 // Loaders are chosen in the order they are listed here. 178 // Loaders are chosen in the order they are listed here.
168 NameToLoaderMap name_to_loader_; 179 NameToLoaderMap name_to_loader_;
169 scoped_ptr<Loader> default_loader_; 180 scoped_ptr<Loader> default_loader_;
170 181
171 IdentityToInstanceMap identity_to_instance_; 182 IdentityToInstanceMap identity_to_instance_;
172 183
173 IdentityToShellClientFactoryMap shell_client_factories_; 184 IdentityToShellClientFactoryMap shell_client_factories_;
174 // Counter used to assign ids to content handlers. 185 // Counter used to assign ids to content handlers.
175 uint32_t shell_client_factory_id_counter_; 186 uint32_t shell_client_factory_id_counter_;
176 187
177 // The Instance created by the shell embedder, if any.
178 Instance* embedder_instance_ = nullptr;
179
180 InterfacePtrSet<mojom::InstanceListener> instance_listeners_; 188 InterfacePtrSet<mojom::InstanceListener> instance_listeners_;
181 189
182 base::Callback<void(const Identity&)> instance_quit_callback_; 190 base::Callback<void(const Identity&)> instance_quit_callback_;
183 scoped_ptr<NativeRunnerFactory> native_runner_factory_; 191 scoped_ptr<NativeRunnerFactory> native_runner_factory_;
184 std::vector<scoped_ptr<NativeRunner>> native_runners_; 192 std::vector<scoped_ptr<NativeRunner>> native_runners_;
185 scoped_ptr<ShellConnection> shell_connection_; 193 scoped_ptr<ShellConnection> shell_connection_;
186 base::WeakPtrFactory<Shell> weak_ptr_factory_; 194 base::WeakPtrFactory<Shell> weak_ptr_factory_;
187 195
188 DISALLOW_COPY_AND_ASSIGN(Shell); 196 DISALLOW_COPY_AND_ASSIGN(Shell);
189 }; 197 };
190 198
191 mojom::Connector::ConnectCallback EmptyConnectCallback(); 199 mojom::Connector::ConnectCallback EmptyConnectCallback();
192 200
193 } // namespace shell 201 } // namespace shell
194 } // namespace mojo 202 } // namespace mojo
195 203
196 #endif // MOJO_SHELL_SHELL_H_ 204 #endif // MOJO_SHELL_SHELL_H_
OLDNEW
« no previous file with comments | « content/browser/mojo/chrome_manifest.json ('k') | mojo/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698