| Index: content/utility/utility_process_control_impl.cc
|
| diff --git a/content/utility/utility_process_control_impl.cc b/content/utility/utility_process_control_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..71429cea59e462d3eea0ac99e3a7e4264370b8af
|
| --- /dev/null
|
| +++ b/content/utility/utility_process_control_impl.cc
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/utility/utility_process_control_impl.h"
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/stl_util.h"
|
| +#include "content/public/common/static_mojo_application_loader.h"
|
| +#include "content/public/utility/utility_thread.h"
|
| +#include "mojo/application/public/cpp/application_delegate.h"
|
| +#include "mojo/shell/application_loader.h"
|
| +
|
| +namespace content {
|
| +
|
| +namespace {
|
| +
|
| +// Called when a static application terminates.
|
| +void QuitProcess() {
|
| + content::UtilityThread::Get()->ReleaseProcessIfNeeded();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +UtilityProcessControlImpl::UtilityProcessControlImpl() {
|
| +}
|
| +
|
| +UtilityProcessControlImpl::~UtilityProcessControlImpl() {
|
| + STLDeleteValues(&url_to_loader_map_);
|
| +}
|
| +
|
| +void UtilityProcessControlImpl::LoadApplication(
|
| + const mojo::String& url,
|
| + mojo::InterfaceRequest<mojo::Application> request,
|
| + const LoadApplicationCallback& callback) {
|
| + GURL application_url = GURL(url.To<std::string>());
|
| + auto it = url_to_loader_map_.find(application_url);
|
| + if (it == url_to_loader_map_.end()) {
|
| + callback.Run(LOAD_APPLICATION_RESULT_NOT_FOUND);
|
| + return;
|
| + }
|
| +
|
| + callback.Run(LOAD_APPLICATION_RESULT_OK);
|
| + it->second->Load(application_url, request.Pass());
|
| +}
|
| +
|
| +void UtilityProcessControlImpl::RegisterStaticAppForURL(
|
| + const GURL& url,
|
| + const StaticAppFactory& factory) {
|
| + auto result = url_to_loader_map_.insert(std::make_pair(
|
| + url,
|
| + // Cleaned up in ~UtilityProcessControlImp.
|
| + new StaticMojoApplicationLoader(factory, base::Bind(&QuitProcess))));
|
| + DCHECK(result.second);
|
| +}
|
| +
|
| +} // namespace content
|
|
|