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

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

Issue 1898433002: Remove shell::Loader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix windows gyp linkage Created 4 years, 8 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 | « services/shell/loader.h ('k') | services/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 SERVICES_SHELL_SHELL_H_ 5 #ifndef SERVICES_SHELL_SHELL_H_
6 #define SERVICES_SHELL_SHELL_H_ 6 #define SERVICES_SHELL_SHELL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.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 "services/shell/connect_params.h" 16 #include "services/shell/connect_params.h"
17 #include "services/shell/loader.h"
18 #include "services/shell/native_runner.h" 17 #include "services/shell/native_runner.h"
19 #include "services/shell/public/cpp/capabilities.h" 18 #include "services/shell/public/cpp/capabilities.h"
20 #include "services/shell/public/cpp/identity.h" 19 #include "services/shell/public/cpp/identity.h"
21 #include "services/shell/public/cpp/interface_factory.h" 20 #include "services/shell/public/cpp/interface_factory.h"
22 #include "services/shell/public/cpp/shell_client.h" 21 #include "services/shell/public/cpp/shell_client.h"
23 #include "services/shell/public/interfaces/connector.mojom.h" 22 #include "services/shell/public/interfaces/connector.mojom.h"
24 #include "services/shell/public/interfaces/interface_provider.mojom.h" 23 #include "services/shell/public/interfaces/interface_provider.mojom.h"
25 #include "services/shell/public/interfaces/shell.mojom.h" 24 #include "services/shell/public/interfaces/shell.mojom.h"
26 #include "services/shell/public/interfaces/shell_client.mojom.h" 25 #include "services/shell/public/interfaces/shell_client.mojom.h"
27 #include "services/shell/public/interfaces/shell_client_factory.mojom.h" 26 #include "services/shell/public/interfaces/shell_client_factory.mojom.h"
(...skipping 19 matching lines...) Expand all
47 private: 46 private:
48 Shell* shell_; 47 Shell* shell_;
49 48
50 DISALLOW_COPY_AND_ASSIGN(TestAPI); 49 DISALLOW_COPY_AND_ASSIGN(TestAPI);
51 }; 50 };
52 51
53 // |native_runner_factory| is an instance of an object capable of vending 52 // |native_runner_factory| is an instance of an object capable of vending
54 // implementations of NativeRunner, e.g. for in or out-of-process execution. 53 // implementations of NativeRunner, e.g. for in or out-of-process execution.
55 // See native_runner.h and RunNativeApplication(). 54 // See native_runner.h and RunNativeApplication().
56 // |file_task_runner| provides access to a thread to perform file copy 55 // |file_task_runner| provides access to a thread to perform file copy
57 // operations on. This may be null only in testing environments where 56 // operations on.
58 // applications are loaded via Loader implementations.
59 Shell(std::unique_ptr<NativeRunnerFactory> native_runner_factory, 57 Shell(std::unique_ptr<NativeRunnerFactory> native_runner_factory,
60 mojom::ShellClientPtr catalog); 58 mojom::ShellClientPtr catalog);
61 ~Shell() override; 59 ~Shell() override;
62 60
63 // Provide a callback to be notified whenever an instance is destroyed. 61 // Provide a callback to be notified whenever an instance is destroyed.
64 // Typically the creator of the Shell will use this to determine when some set 62 // Typically the creator of the Shell will use this to determine when some set
65 // of instances it created are destroyed, so it can shut down. 63 // of instances it created are destroyed, so it can shut down.
66 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); 64 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback);
67 65
68 // Completes a connection between a source and target application as defined 66 // Completes a connection between a source and target application as defined
69 // by |params|, exchanging InterfaceProviders between them. If no existing 67 // by |params|, exchanging InterfaceProviders between them. If no existing
70 // instance of the target application is running, one will be loaded. 68 // instance of the target application is running, one will be loaded.
71 void Connect(std::unique_ptr<ConnectParams> params); 69 void Connect(std::unique_ptr<ConnectParams> params);
72 70
73 // Creates a new Instance identified as |name|. This is intended for use by 71 // Creates a new Instance identified as |name|. This is intended for use by
74 // the Shell's embedder to register itself with the shell. This must only be 72 // the Shell's embedder to register itself with the shell. This must only be
75 // called once. 73 // called once.
76 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name); 74 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name);
77 75
78 // Sets the default Loader to be used if not overridden by SetLoaderForName().
79 void set_default_loader(std::unique_ptr<Loader> loader) {
80 default_loader_ = std::move(loader);
81 }
82
83 // Sets a Loader to be used for a specific name.
84 void SetLoaderForName(std::unique_ptr<Loader> loader,
85 const std::string& name);
86
87 private: 76 private:
88 class Instance; 77 class Instance;
89 78
90 // ShellClient: 79 // ShellClient:
91 bool AcceptConnection(Connection* connection) override; 80 bool AcceptConnection(Connection* connection) override;
92 81
93 void InitCatalog(mojom::ShellClientPtr catalog); 82 void InitCatalog(mojom::ShellClientPtr catalog);
94 83
95 // Destroys all Shell-ends of connections established with Applications. 84 // Destroys all Shell-ends of connections established with Applications.
96 // Applications connected by this Shell will observe pipe errors and have a 85 // Applications connected by this Shell will observe pipe errors and have a
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Callback when remote Catalog resolves mojo:foo to mojo:bar. 129 // Callback when remote Catalog resolves mojo:foo to mojo:bar.
141 // |params| are the params passed to Connect(). 130 // |params| are the params passed to Connect().
142 // |client| if provided is a ShellClientPtr which should be used to manage the 131 // |client| if provided is a ShellClientPtr which should be used to manage the
143 // new application instance. This may be null. 132 // new application instance. This may be null.
144 // |result| contains the result of the resolve operation. 133 // |result| contains the result of the resolve operation.
145 void OnGotResolvedName(mojom::ShellResolverPtr resolver, 134 void OnGotResolvedName(mojom::ShellResolverPtr resolver,
146 std::unique_ptr<ConnectParams> params, 135 std::unique_ptr<ConnectParams> params,
147 mojom::ShellClientPtr client, 136 mojom::ShellClientPtr client,
148 mojom::ResolveResultPtr result); 137 mojom::ResolveResultPtr result);
149 138
150 // Tries to load |target| with an Loader. Returns true if one was registered
151 // and it was loaded, in which case |request| is taken.
152 bool LoadWithLoader(const Identity& target,
153 mojom::ShellClientRequest* request);
154
155 // Returns the appropriate loader for |name|, or the default loader if there
156 // is no loader configured for the name.
157 Loader* GetLoaderForName(const std::string& name);
158
159 base::WeakPtr<Shell> GetWeakPtr(); 139 base::WeakPtr<Shell> GetWeakPtr();
160 140
161 void CleanupRunner(NativeRunner* runner); 141 void CleanupRunner(NativeRunner* runner);
162 142
163 // Loader management.
164 // Loaders are chosen in the order they are listed here.
165 std::map<std::string, Loader*> name_to_loader_;
166 std::unique_ptr<Loader> default_loader_;
167
168 std::map<Identity, Instance*> identity_to_instance_; 143 std::map<Identity, Instance*> identity_to_instance_;
169 144
170 // Tracks the names of instances that are allowed to field connection requests 145 // Tracks the names of instances that are allowed to field connection requests
171 // from all users. 146 // from all users.
172 std::set<std::string> singletons_; 147 std::set<std::string> singletons_;
173 148
174 std::map<Identity, mojom::ShellClientFactoryPtr> shell_client_factories_; 149 std::map<Identity, mojom::ShellClientFactoryPtr> shell_client_factories_;
175 // Counter used to assign ids to client factories. 150 // Counter used to assign ids to client factories.
176 uint32_t shell_client_factory_id_counter_; 151 uint32_t shell_client_factory_id_counter_;
177 152
178 mojo::InterfacePtrSet<mojom::InstanceListener> instance_listeners_; 153 mojo::InterfacePtrSet<mojom::InstanceListener> instance_listeners_;
179 154
180 base::Callback<void(const Identity&)> instance_quit_callback_; 155 base::Callback<void(const Identity&)> instance_quit_callback_;
181 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; 156 std::unique_ptr<NativeRunnerFactory> native_runner_factory_;
182 std::vector<std::unique_ptr<NativeRunner>> native_runners_; 157 std::vector<std::unique_ptr<NativeRunner>> native_runners_;
183 std::unique_ptr<ShellConnection> shell_connection_; 158 std::unique_ptr<ShellConnection> shell_connection_;
184 base::WeakPtrFactory<Shell> weak_ptr_factory_; 159 base::WeakPtrFactory<Shell> weak_ptr_factory_;
185 160
186 DISALLOW_COPY_AND_ASSIGN(Shell); 161 DISALLOW_COPY_AND_ASSIGN(Shell);
187 }; 162 };
188 163
189 mojom::Connector::ConnectCallback EmptyConnectCallback(); 164 mojom::Connector::ConnectCallback EmptyConnectCallback();
190 165
191 } // namespace shell 166 } // namespace shell
192 167
193 #endif // SERVICES_SHELL_SHELL_H_ 168 #endif // SERVICES_SHELL_SHELL_H_
OLDNEW
« no previous file with comments | « services/shell/loader.h ('k') | services/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698