Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / child / process_control_impl.cc
blobf1e6c3d15541c39e7bf05185862fd6aaafdf85d9
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
3 // found in the LICENSE file.
5 #include "content/child/process_control_impl.h"
7 #include "base/stl_util.h"
8 #include "content/public/common/content_client.h"
9 #include "mojo/shell/static_application_loader.h"
10 #include "url/gurl.h"
12 namespace content {
14 ProcessControlImpl::ProcessControlImpl() {
17 ProcessControlImpl::~ProcessControlImpl() {
18 STLDeleteValues(&url_to_loader_map_);
21 void ProcessControlImpl::LoadApplication(
22 const mojo::String& url,
23 mojo::InterfaceRequest<mojo::Application> request,
24 const LoadApplicationCallback& callback) {
25 // Only register loaders when we need it.
26 if (!has_registered_loaders_) {
27 DCHECK(url_to_loader_map_.empty());
28 RegisterApplicationLoaders(&url_to_loader_map_);
29 has_registered_loaders_ = true;
32 GURL application_url = GURL(url.To<std::string>());
33 auto it = url_to_loader_map_.find(application_url);
34 if (it == url_to_loader_map_.end()) {
35 callback.Run(false);
36 OnLoadFailed();
37 return;
40 callback.Run(true);
41 it->second->Load(application_url, request.Pass());
44 } // namespace content