OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 base::Callback<void(const Identity&)> callback) { | 74 base::Callback<void(const Identity&)> callback) { |
75 instance_quit_callback_ = callback; | 75 instance_quit_callback_ = callback; |
76 } | 76 } |
77 | 77 |
78 void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) { | 78 void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) { |
79 TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::Connect", | 79 TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::Connect", |
80 TRACE_EVENT_SCOPE_THREAD, "original_url", | 80 TRACE_EVENT_SCOPE_THREAD, "original_url", |
81 params->target().url().spec()); | 81 params->target().url().spec()); |
82 DCHECK(params->target().url().is_valid()); | 82 DCHECK(params->target().url().is_valid()); |
83 | 83 |
84 if (params->target().user_id() == mojom::Shell::kUserInherit) { | 84 if (params->target().user_id() == mojom::Connector::kUserInherit) { |
85 ApplicationInstance* source = GetApplicationInstance(params->source()); | 85 ApplicationInstance* source = GetApplicationInstance(params->source()); |
86 Identity target = params->target(); | 86 Identity target = params->target(); |
87 // TODO(beng): we should CHECK source. | 87 // TODO(beng): we should CHECK source. |
88 target.set_user_id(source ? source->identity().user_id() | 88 target.set_user_id(source ? source->identity().user_id() |
89 : mojom::Shell::kUserRoot); | 89 : mojom::Connector::kUserRoot); |
90 params->set_target(target); | 90 params->set_target(target); |
91 } | 91 } |
92 | 92 |
93 // Connect to an existing matching instance, if possible. | 93 // Connect to an existing matching instance, if possible. |
94 if (ConnectToExistingInstance(¶ms)) | 94 if (ConnectToExistingInstance(¶ms)) |
95 return; | 95 return; |
96 | 96 |
97 std::string url = params->target().url().spec(); | 97 std::string url = params->target().url().spec(); |
98 shell_resolver_->ResolveMojoURL( | 98 shell_resolver_->ResolveMojoURL( |
99 url, | 99 url, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ScopedHandle channel, | 175 ScopedHandle channel, |
176 const String& url, | 176 const String& url, |
177 mojom::CapabilityFilterPtr filter, | 177 mojom::CapabilityFilterPtr filter, |
178 mojom::PIDReceiverRequest pid_receiver) { | 178 mojom::PIDReceiverRequest pid_receiver) { |
179 // We don't call ConnectToClient() here since the instance was created | 179 // We don't call ConnectToClient() here since the instance was created |
180 // manually by other code, not in response to a Connect() request. The newly | 180 // manually by other code, not in response to a Connect() request. The newly |
181 // created instance is identified by |url| and may be subsequently reached by | 181 // created instance is identified by |url| and may be subsequently reached by |
182 // client code using this identity. | 182 // client code using this identity. |
183 CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>(); | 183 CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>(); |
184 // TODO(beng): obtain userid from the inbound connection. | 184 // TODO(beng): obtain userid from the inbound connection. |
185 Identity target_id(url.To<GURL>(), std::string(), mojom::Shell::kUserInherit, | 185 Identity target_id(url.To<GURL>(), std::string(), |
186 local_filter); | 186 mojom::Connector::kUserInherit, local_filter); |
187 mojom::ShellClientRequest request; | 187 mojom::ShellClientRequest request; |
188 ApplicationInstance* instance = CreateInstance(target_id, &request); | 188 ApplicationInstance* instance = CreateInstance(target_id, &request); |
189 instance->BindPIDReceiver(std::move(pid_receiver)); | 189 instance->BindPIDReceiver(std::move(pid_receiver)); |
190 scoped_ptr<NativeRunner> runner = | 190 scoped_ptr<NativeRunner> runner = |
191 native_runner_factory_->Create(base::FilePath()); | 191 native_runner_factory_->Create(base::FilePath()); |
192 runner->InitHost(std::move(channel), std::move(request)); | 192 runner->InitHost(std::move(channel), std::move(request)); |
193 instance->SetNativeRunner(runner.get()); | 193 instance->SetNativeRunner(runner.get()); |
194 native_runners_.push_back(std::move(runner)); | 194 native_runners_.push_back(std::move(runner)); |
195 } | 195 } |
196 | 196 |
(...skipping 22 matching lines...) Expand all Loading... |
219 SetLoaderForURL(std::move(loader), url); | 219 SetLoaderForURL(std::move(loader), url); |
220 | 220 |
221 ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_); | 221 ConnectToInterface(this, CreateShellIdentity(), url, &shell_resolver_); |
222 } | 222 } |
223 | 223 |
224 bool ApplicationManager::ConnectToExistingInstance( | 224 bool ApplicationManager::ConnectToExistingInstance( |
225 scoped_ptr<ConnectParams>* params) { | 225 scoped_ptr<ConnectParams>* params) { |
226 ApplicationInstance* instance = GetApplicationInstance((*params)->target()); | 226 ApplicationInstance* instance = GetApplicationInstance((*params)->target()); |
227 if (!instance) { | 227 if (!instance) { |
228 Identity root_identity = (*params)->target(); | 228 Identity root_identity = (*params)->target(); |
229 root_identity.set_user_id(mojom::Shell::kUserRoot); | 229 root_identity.set_user_id(mojom::Connector::kUserRoot); |
230 instance = GetApplicationInstance(root_identity); | 230 instance = GetApplicationInstance(root_identity); |
231 if (!instance) return false; | 231 if (!instance) return false; |
232 } | 232 } |
233 instance->ConnectToClient(std::move(*params)); | 233 instance->ConnectToClient(std::move(*params)); |
234 return true; | 234 return true; |
235 } | 235 } |
236 | 236 |
237 ApplicationInstance* ApplicationManager::CreateInstance( | 237 ApplicationInstance* ApplicationManager::CreateInstance( |
238 const Identity& target_id, | 238 const Identity& target_id, |
239 mojom::ShellClientRequest* request) { | 239 mojom::ShellClientRequest* request) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 info->qualifier = instance->identity().qualifier(); | 376 info->qualifier = instance->identity().qualifier(); |
377 if (instance->identity().url().spec() == "mojo://shell/") | 377 if (instance->identity().url().spec() == "mojo://shell/") |
378 info->pid = base::Process::Current().Pid(); | 378 info->pid = base::Process::Current().Pid(); |
379 else | 379 else |
380 info->pid = instance->pid(); | 380 info->pid = instance->pid(); |
381 return info; | 381 return info; |
382 } | 382 } |
383 | 383 |
384 } // namespace shell | 384 } // namespace shell |
385 } // namespace mojo | 385 } // namespace mojo |
OLD | NEW |