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

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

Issue 1761153002: Replace ChildController with ShellClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@29binding
Patch Set: . 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 | « mojo/shell/application_manager.h ('k') | mojo/shell/native_runner.h » ('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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 runner_ = runner.get(); 99 runner_ = runner.get();
100 runner_->Start(path, identity_, start_sandboxed, std::move(request), 100 runner_->Start(path, identity_, start_sandboxed, std::move(request),
101 base::Bind(&Instance::PIDAvailable, 101 base::Bind(&Instance::PIDAvailable,
102 weak_factory_.GetWeakPtr()), 102 weak_factory_.GetWeakPtr()),
103 base::Bind(&ApplicationManager::CleanupRunner, 103 base::Bind(&ApplicationManager::CleanupRunner,
104 manager_->weak_ptr_factory_.GetWeakPtr(), 104 manager_->weak_ptr_factory_.GetWeakPtr(),
105 runner_)); 105 runner_));
106 return runner; 106 return runner;
107 } 107 }
108 108
109 scoped_ptr<NativeRunner> StartWithChannel( 109 scoped_ptr<NativeRunner> StartWithFactory(
110 ScopedHandle channel, 110 mojom::ShellClientFactoryPtr shell_client_factory,
111 const String& name,
111 mojom::ShellClientRequest request, 112 mojom::ShellClientRequest request,
112 mojom::PIDReceiverRequest pid_receiver_request, 113 mojom::PIDReceiverRequest pid_receiver_request,
113 NativeRunnerFactory* factory) { 114 NativeRunnerFactory* factory) {
114 pid_receiver_binding_.Bind(std::move(pid_receiver_request)); 115 pid_receiver_binding_.Bind(std::move(pid_receiver_request));
115 scoped_ptr<NativeRunner> runner = factory->Create(base::FilePath()); 116 scoped_ptr<NativeRunner> runner = factory->Create(base::FilePath());
116 runner_ = runner.get(); 117 runner_ = runner.get();
117 runner_->InitHost(std::move(channel), std::move(request)); 118 runner_->InitHost(std::move(shell_client_factory), name,
119 std::move(request));
118 return runner; 120 return runner;
119 } 121 }
120 122
121 mojom::InstanceInfoPtr CreateInstanceInfo() const { 123 mojom::InstanceInfoPtr CreateInstanceInfo() const {
122 mojom::InstanceInfoPtr info(mojom::InstanceInfo::New()); 124 mojom::InstanceInfoPtr info(mojom::InstanceInfo::New());
123 info->id = id_; 125 info->id = id_;
124 info->name = identity_.name(); 126 info->name = identity_.name();
125 info->qualifier = identity_.qualifier(); 127 info->qualifier = identity_.qualifier();
126 info->pid = pid_; 128 info->pid = pid_;
127 return info; 129 return info;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // implementation: 304 // implementation:
303 305
304 void ApplicationManager::Create(Connection* connection, 306 void ApplicationManager::Create(Connection* connection,
305 mojom::ApplicationManagerRequest request) { 307 mojom::ApplicationManagerRequest request) {
306 bindings_.AddBinding(this, std::move(request)); 308 bindings_.AddBinding(this, std::move(request));
307 } 309 }
308 310
309 //////////////////////////////////////////////////////////////////////////////// 311 ////////////////////////////////////////////////////////////////////////////////
310 // ApplicationManager, mojom::ApplicationManager implemetation: 312 // ApplicationManager, mojom::ApplicationManager implemetation:
311 313
312 void ApplicationManager::CreateInstanceForHandle( 314 void ApplicationManager::CreateInstanceForFactory(
313 ScopedHandle channel, 315 mojom::ShellClientFactoryPtr factory,
314 const String& name, 316 const String& name,
315 mojom::CapabilityFilterPtr filter, 317 mojom::CapabilityFilterPtr filter,
316 mojom::PIDReceiverRequest pid_receiver) { 318 mojom::PIDReceiverRequest pid_receiver) {
317 // We don't call ConnectToClient() here since the instance was created 319 // We don't call ConnectToClient() here since the instance was created
318 // manually by other code, not in response to a Connect() request. The newly 320 // manually by other code, not in response to a Connect() request. The newly
319 // created instance is identified by |name| and may be subsequently reached by 321 // created instance is identified by |name| and may be subsequently reached by
320 // client code using this identity. 322 // client code using this identity.
321 // TODO(beng): obtain userid from the inbound connection. 323 // TODO(beng): obtain userid from the inbound connection.
322 Identity target_id(name, std::string(), mojom::Connector::kUserInherit); 324 Identity target_id(name, std::string(), mojom::Connector::kUserInherit);
323 target_id.set_filter(filter->filter.To<CapabilityFilter>()); 325 target_id.set_filter(filter->filter.To<CapabilityFilter>());
324 mojom::ShellClientRequest request; 326 mojom::ShellClientRequest request;
325 Instance* instance = CreateInstance(target_id, &request); 327 Instance* instance = CreateInstance(target_id, &request);
326 native_runners_.push_back( 328 native_runners_.push_back(
327 instance->StartWithChannel(std::move(channel), std::move(request), 329 instance->StartWithFactory(std::move(factory), name, std::move(request),
328 std::move(pid_receiver), 330 std::move(pid_receiver),
329 native_runner_factory_.get())); 331 native_runner_factory_.get()));
330 } 332 }
331 333
332 void ApplicationManager::AddInstanceListener( 334 void ApplicationManager::AddInstanceListener(
333 mojom::InstanceListenerPtr listener) { 335 mojom::InstanceListenerPtr listener) {
334 Array<mojom::InstanceInfoPtr> instances; 336 Array<mojom::InstanceInfoPtr> instances;
335 for (auto& instance : identity_to_instance_) 337 for (auto& instance : identity_to_instance_)
336 instances.push_back(instance.second->CreateInstanceInfo()); 338 instances.push_back(instance.second->CreateInstanceInfo());
337 listener->SetExistingInstances(std::move(instances)); 339 listener->SetExistingInstances(std::move(instances));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 537 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
536 if (it->get() == runner) { 538 if (it->get() == runner) {
537 native_runners_.erase(it); 539 native_runners_.erase(it);
538 return; 540 return;
539 } 541 }
540 } 542 }
541 } 543 }
542 544
543 } // namespace shell 545 } // namespace shell
544 } // namespace mojo 546 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698