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

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

Issue 1921183003: Fixes race in Shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 4 years, 7 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/catalog/reader.cc ('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>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name); 74 mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name);
75 75
76 private: 76 private:
77 class Instance; 77 class Instance;
78 78
79 // ShellClient: 79 // ShellClient:
80 bool AcceptConnection(Connection* connection) override; 80 bool AcceptConnection(Connection* connection) override;
81 81
82 void InitCatalog(mojom::ShellClientPtr catalog); 82 void InitCatalog(mojom::ShellClientPtr catalog);
83 83
84 // Returns the resolver to use for the specified identity.
85 // NOTE: ShellResolvers are cached to ensure we service requests in order. If
86 // we use a separate ShellResolver for each request ordering is not
87 // guaranteed and can lead to random flake.
88 mojom::ShellResolver* GetResolver(const Identity& identity);
89
84 // Destroys all Shell-ends of connections established with Applications. 90 // Destroys all Shell-ends of connections established with Applications.
85 // Applications connected by this Shell will observe pipe errors and have a 91 // Applications connected by this Shell will observe pipe errors and have a
86 // chance to shutdown. 92 // chance to shutdown.
87 void TerminateShellConnections(); 93 void TerminateShellConnections();
88 94
89 // Removes a Instance when it encounters an error. 95 // Removes a Instance when it encounters an error.
90 void OnInstanceError(Instance* instance); 96 void OnInstanceError(Instance* instance);
91 97
92 // Completes a connection between a source and target application as defined 98 // Completes a connection between a source and target application as defined
93 // by |params|, exchanging InterfaceProviders between them. If no existing 99 // by |params|, exchanging InterfaceProviders between them. If no existing
(...skipping 30 matching lines...) Expand all
124 // If there is not one running one is started for |source_identity|. 130 // If there is not one running one is started for |source_identity|.
125 mojom::ShellClientFactory* GetShellClientFactory( 131 mojom::ShellClientFactory* GetShellClientFactory(
126 const Identity& shell_client_factory_identity); 132 const Identity& shell_client_factory_identity);
127 void OnShellClientFactoryLost(const Identity& which); 133 void OnShellClientFactoryLost(const Identity& which);
128 134
129 // Callback when remote Catalog resolves mojo:foo to mojo:bar. 135 // Callback when remote Catalog resolves mojo:foo to mojo:bar.
130 // |params| are the params passed to Connect(). 136 // |params| are the params passed to Connect().
131 // |client| if provided is a ShellClientPtr which should be used to manage the 137 // |client| if provided is a ShellClientPtr which should be used to manage the
132 // new application instance. This may be null. 138 // new application instance. This may be null.
133 // |result| contains the result of the resolve operation. 139 // |result| contains the result of the resolve operation.
134 void OnGotResolvedName(mojom::ShellResolverPtr resolver, 140 void OnGotResolvedName(std::unique_ptr<ConnectParams> params,
135 std::unique_ptr<ConnectParams> params,
136 mojom::ShellClientPtr client, 141 mojom::ShellClientPtr client,
137 mojom::ResolveResultPtr result); 142 mojom::ResolveResultPtr result);
138 143
139 base::WeakPtr<Shell> GetWeakPtr(); 144 base::WeakPtr<Shell> GetWeakPtr();
140 145
141 void CleanupRunner(NativeRunner* runner); 146 void CleanupRunner(NativeRunner* runner);
142 147
143 std::map<Identity, Instance*> identity_to_instance_; 148 std::map<Identity, Instance*> identity_to_instance_;
144 149
145 // Tracks the names of instances that are allowed to field connection requests 150 // Tracks the names of instances that are allowed to field connection requests
146 // from all users. 151 // from all users.
147 std::set<std::string> singletons_; 152 std::set<std::string> singletons_;
148 153
149 std::map<Identity, mojom::ShellClientFactoryPtr> shell_client_factories_; 154 std::map<Identity, mojom::ShellClientFactoryPtr> shell_client_factories_;
150 // Counter used to assign ids to client factories. 155 // Counter used to assign ids to client factories.
151 uint32_t shell_client_factory_id_counter_; 156 uint32_t shell_client_factory_id_counter_;
152 157
158 std::map<Identity, mojom::ShellResolverPtr> identity_to_resolver_;
159
153 mojo::InterfacePtrSet<mojom::InstanceListener> instance_listeners_; 160 mojo::InterfacePtrSet<mojom::InstanceListener> instance_listeners_;
154 161
155 base::Callback<void(const Identity&)> instance_quit_callback_; 162 base::Callback<void(const Identity&)> instance_quit_callback_;
156 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; 163 std::unique_ptr<NativeRunnerFactory> native_runner_factory_;
157 std::vector<std::unique_ptr<NativeRunner>> native_runners_; 164 std::vector<std::unique_ptr<NativeRunner>> native_runners_;
158 std::unique_ptr<ShellConnection> shell_connection_; 165 std::unique_ptr<ShellConnection> shell_connection_;
159 base::WeakPtrFactory<Shell> weak_ptr_factory_; 166 base::WeakPtrFactory<Shell> weak_ptr_factory_;
160 167
161 DISALLOW_COPY_AND_ASSIGN(Shell); 168 DISALLOW_COPY_AND_ASSIGN(Shell);
162 }; 169 };
163 170
164 mojom::Connector::ConnectCallback EmptyConnectCallback(); 171 mojom::Connector::ConnectCallback EmptyConnectCallback();
165 172
166 } // namespace shell 173 } // namespace shell
167 174
168 #endif // SERVICES_SHELL_SHELL_H_ 175 #endif // SERVICES_SHELL_SHELL_H_
OLDNEW
« no previous file with comments | « services/catalog/reader.cc ('k') | services/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698