| 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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/common/mojo/static_application_loader.h" | 10 #include "content/common/mojo/static_application_loader.h" |
| 11 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
| 12 #include "url/gurl.h" | |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 ProcessControlImpl::ProcessControlImpl() { | 15 ProcessControlImpl::ProcessControlImpl() { |
| 17 } | 16 } |
| 18 | 17 |
| 19 ProcessControlImpl::~ProcessControlImpl() { | 18 ProcessControlImpl::~ProcessControlImpl() { |
| 20 STLDeleteValues(&url_to_loader_map_); | 19 STLDeleteValues(&name_to_loader_map_); |
| 21 } | 20 } |
| 22 | 21 |
| 23 void ProcessControlImpl::LoadApplication( | 22 void ProcessControlImpl::LoadApplication( |
| 24 const mojo::String& url, | 23 const mojo::String& name, |
| 25 mojo::InterfaceRequest<mojo::shell::mojom::ShellClient> request, | 24 mojo::InterfaceRequest<mojo::shell::mojom::ShellClient> request, |
| 26 const LoadApplicationCallback& callback) { | 25 const LoadApplicationCallback& callback) { |
| 27 // Only register loaders when we need it. | 26 // Only register loaders when we need it. |
| 28 if (!has_registered_loaders_) { | 27 if (!has_registered_loaders_) { |
| 29 DCHECK(url_to_loader_map_.empty()); | 28 DCHECK(name_to_loader_map_.empty()); |
| 30 RegisterApplicationLoaders(&url_to_loader_map_); | 29 RegisterApplicationLoaders(&name_to_loader_map_); |
| 31 has_registered_loaders_ = true; | 30 has_registered_loaders_ = true; |
| 32 } | 31 } |
| 33 | 32 |
| 34 GURL application_url = GURL(url.To<std::string>()); | 33 auto it = name_to_loader_map_.find(name); |
| 35 auto it = url_to_loader_map_.find(application_url); | 34 if (it == name_to_loader_map_.end()) { |
| 36 if (it == url_to_loader_map_.end()) { | |
| 37 callback.Run(false); | 35 callback.Run(false); |
| 38 OnLoadFailed(); | 36 OnLoadFailed(); |
| 39 return; | 37 return; |
| 40 } | 38 } |
| 41 | 39 |
| 42 callback.Run(true); | 40 callback.Run(true); |
| 43 it->second->Load(application_url, std::move(request)); | 41 it->second->Load(name, std::move(request)); |
| 44 } | 42 } |
| 45 | 43 |
| 46 } // namespace content | 44 } // namespace content |
| OLD | NEW |