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

Side by Side Diff: mojo/shell/application_manager.cc

Issue 1728083002: Extract a Connector interface from Shell that can be cloned & passed to other threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@12uid
Patch Set: . Created 4 years, 10 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/application_manager.h ('k') | mojo/shell/background/background_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 #include "mojo/shell/application_manager.h" 5 #include "mojo/shell/application_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 base::Callback<void(const Identity&)> callback) { 71 base::Callback<void(const Identity&)> callback) {
72 instance_quit_callback_ = callback; 72 instance_quit_callback_ = callback;
73 } 73 }
74 74
75 void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) { 75 void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) {
76 TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::Connect", 76 TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::Connect",
77 TRACE_EVENT_SCOPE_THREAD, "original_url", 77 TRACE_EVENT_SCOPE_THREAD, "original_url",
78 params->target().url().spec()); 78 params->target().url().spec());
79 DCHECK(params->target().url().is_valid()); 79 DCHECK(params->target().url().is_valid());
80 80
81 if (params->target().user_id() == mojom::Shell::kUserInherit) { 81 if (params->target().user_id() == mojom::Connector::kUserInherit) {
82 ApplicationInstance* source = GetApplicationInstance(params->source()); 82 ApplicationInstance* source = GetApplicationInstance(params->source());
83 Identity target = params->target(); 83 Identity target = params->target();
84 // TODO(beng): we should CHECK source. 84 // TODO(beng): we should CHECK source.
85 target.set_user_id(source ? source->identity().user_id() 85 target.set_user_id(source ? source->identity().user_id()
86 : mojom::Shell::kUserRoot); 86 : mojom::Connector::kUserRoot);
87 params->set_target(target); 87 params->set_target(target);
88 } 88 }
89 89
90 // Connect to an existing matching instance, if possible. 90 // Connect to an existing matching instance, if possible.
91 if (ConnectToExistingInstance(&params)) 91 if (ConnectToExistingInstance(&params))
92 return; 92 return;
93 93
94 std::string url = params->target().url().spec(); 94 std::string url = params->target().url().spec();
95 shell_resolver_->ResolveMojoURL( 95 shell_resolver_->ResolveMojoURL(
96 url, 96 url,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ScopedHandle channel, 172 ScopedHandle channel,
173 const String& url, 173 const String& url,
174 mojom::CapabilityFilterPtr filter, 174 mojom::CapabilityFilterPtr filter,
175 mojom::PIDReceiverRequest pid_receiver) { 175 mojom::PIDReceiverRequest pid_receiver) {
176 // We don't call ConnectToClient() here since the instance was created 176 // We don't call ConnectToClient() here since the instance was created
177 // manually by other code, not in response to a Connect() request. The newly 177 // manually by other code, not in response to a Connect() request. The newly
178 // created instance is identified by |url| and may be subsequently reached by 178 // created instance is identified by |url| and may be subsequently reached by
179 // client code using this identity. 179 // client code using this identity.
180 CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>(); 180 CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>();
181 // TODO(beng): obtain userid from the inbound connection. 181 // TODO(beng): obtain userid from the inbound connection.
182 Identity target_id(url.To<GURL>(), std::string(), mojom::Shell::kUserInherit, 182 Identity target_id(url.To<GURL>(), std::string(),
183 local_filter); 183 mojom::Connector::kUserInherit, local_filter);
184 mojom::ShellClientRequest request; 184 mojom::ShellClientRequest request;
185 ApplicationInstance* instance = CreateInstance(target_id, &request); 185 ApplicationInstance* instance = CreateInstance(target_id, &request);
186 instance->BindPIDReceiver(std::move(pid_receiver)); 186 instance->BindPIDReceiver(std::move(pid_receiver));
187 scoped_ptr<NativeRunner> runner = 187 scoped_ptr<NativeRunner> runner =
188 native_runner_factory_->Create(base::FilePath()); 188 native_runner_factory_->Create(base::FilePath());
189 runner->InitHost(std::move(channel), std::move(request)); 189 runner->InitHost(std::move(channel), std::move(request));
190 instance->SetNativeRunner(runner.get()); 190 instance->SetNativeRunner(runner.get());
191 native_runners_.push_back(std::move(runner)); 191 native_runners_.push_back(std::move(runner));
192 } 192 }
193 193
(...skipping 22 matching lines...) Expand all
216 SetLoaderForURL(std::move(loader), url); 216 SetLoaderForURL(std::move(loader), url);
217 217
218 ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_); 218 ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_);
219 } 219 }
220 220
221 bool ApplicationManager::ConnectToExistingInstance( 221 bool ApplicationManager::ConnectToExistingInstance(
222 scoped_ptr<ConnectParams>* params) { 222 scoped_ptr<ConnectParams>* params) {
223 ApplicationInstance* instance = GetApplicationInstance((*params)->target()); 223 ApplicationInstance* instance = GetApplicationInstance((*params)->target());
224 if (!instance) { 224 if (!instance) {
225 Identity root_identity = (*params)->target(); 225 Identity root_identity = (*params)->target();
226 root_identity.set_user_id(mojom::Shell::kUserRoot); 226 root_identity.set_user_id(mojom::Connector::kUserRoot);
227 instance = GetApplicationInstance(root_identity); 227 instance = GetApplicationInstance(root_identity);
228 if (!instance) return false; 228 if (!instance) return false;
229 } 229 }
230 instance->ConnectToClient(std::move(*params)); 230 instance->ConnectToClient(std::move(*params));
231 return true; 231 return true;
232 } 232 }
233 233
234 ApplicationInstance* ApplicationManager::CreateInstance( 234 ApplicationInstance* ApplicationManager::CreateInstance(
235 const Identity& target_id, 235 const Identity& target_id,
236 mojom::ShellClientRequest* request) { 236 mojom::ShellClientRequest* request) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 info->qualifier = instance->identity().qualifier(); 373 info->qualifier = instance->identity().qualifier();
374 if (instance->identity().url().spec() == "mojo://shell/") 374 if (instance->identity().url().spec() == "mojo://shell/")
375 info->pid = base::Process::Current().Pid(); 375 info->pid = base::Process::Current().Pid();
376 else 376 else
377 info->pid = instance->pid(); 377 info->pid = instance->pid();
378 return info; 378 return info;
379 } 379 }
380 380
381 } // namespace shell 381 } // namespace shell
382 } // namespace mojo 382 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/background/background_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698