| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/process_control_impl.h" | 5 #include "content/child/process_control_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "content/common/mojo/embedded_application_runner.h" | 11 #include "content/common/mojo/embedded_application_runner.h" |
| 12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 ProcessControlImpl::ProcessControlImpl() { | 16 ProcessControlImpl::ProcessControlImpl() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 ProcessControlImpl::~ProcessControlImpl() { | 19 ProcessControlImpl::~ProcessControlImpl() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 void ProcessControlImpl::LoadApplication( | 22 void ProcessControlImpl::LoadApplication( |
| 23 const mojo::String& name, | 23 const std::string& name, |
| 24 shell::mojom::ServiceRequest request, | 24 shell::mojom::ServiceRequest request, |
| 25 const LoadApplicationCallback& callback) { | 25 const LoadApplicationCallback& callback) { |
| 26 // Only register apps on first run. | 26 // Only register apps on first run. |
| 27 if (!has_registered_apps_) { | 27 if (!has_registered_apps_) { |
| 28 DCHECK(apps_.empty()); | 28 DCHECK(apps_.empty()); |
| 29 ApplicationMap apps; | 29 ApplicationMap apps; |
| 30 RegisterApplications(&apps); | 30 RegisterApplications(&apps); |
| 31 for (const auto& app : apps) { | 31 for (const auto& app : apps) { |
| 32 std::unique_ptr<EmbeddedApplicationRunner> runner( | 32 std::unique_ptr<EmbeddedApplicationRunner> runner( |
| 33 new EmbeddedApplicationRunner(app.first, app.second)); | 33 new EmbeddedApplicationRunner(app.first, app.second)); |
| 34 runner->SetQuitClosure(base::Bind(&ProcessControlImpl::OnApplicationQuit, | 34 runner->SetQuitClosure(base::Bind(&ProcessControlImpl::OnApplicationQuit, |
| 35 base::Unretained(this))); | 35 base::Unretained(this))); |
| 36 apps_.insert(std::make_pair(app.first, std::move(runner))); | 36 apps_.insert(std::make_pair(app.first, std::move(runner))); |
| 37 } | 37 } |
| 38 has_registered_apps_ = true; | 38 has_registered_apps_ = true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 auto it = apps_.find(name); | 41 auto it = apps_.find(name); |
| 42 if (it == apps_.end()) { | 42 if (it == apps_.end()) { |
| 43 callback.Run(false); | 43 callback.Run(false); |
| 44 OnLoadFailed(); | 44 OnLoadFailed(); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 | 47 |
| 48 callback.Run(true); | 48 callback.Run(true); |
| 49 it->second->BindServiceRequest(std::move(request)); | 49 it->second->BindServiceRequest(std::move(request)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace content | 52 } // namespace content |
| OLD | NEW |