Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / utility / utility_process_control_impl.cc
blob7878cbd4e027df461a5c127acecfd3e14da52977
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/utility/utility_process_control_impl.h"
7 #include "base/bind.h"
8 #include "content/public/common/content_client.h"
9 #include "content/public/utility/content_utility_client.h"
10 #include "content/public/utility/utility_thread.h"
11 #include "content/utility/utility_thread_impl.h"
12 #include "mojo/shell/static_application_loader.h"
14 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
15 #include "media/mojo/services/mojo_media_application.h"
16 #endif
18 namespace content {
20 namespace {
22 // Called when a static application terminates.
23 void QuitProcess() {
24 UtilityThread::Get()->ReleaseProcessIfNeeded();
27 } // namespace
29 UtilityProcessControlImpl::UtilityProcessControlImpl() {}
31 UtilityProcessControlImpl::~UtilityProcessControlImpl() {}
33 void UtilityProcessControlImpl::RegisterApplicationLoaders(
34 URLToLoaderMap* url_to_loader_map) {
35 URLToLoaderMap& map_ref = *url_to_loader_map;
37 ContentUtilityClient::StaticMojoApplicationMap apps;
38 GetContentClient()->utility()->RegisterMojoApplications(&apps);
40 for (const auto& entry : apps) {
41 map_ref[entry.first] = new mojo::shell::StaticApplicationLoader(
42 entry.second, base::Bind(&QuitProcess));
45 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
46 map_ref[media::MojoMediaApplication::AppUrl()] =
47 new mojo::shell::StaticApplicationLoader(
48 base::Bind(&media::MojoMediaApplication::CreateApp),
49 base::Bind(&QuitProcess));
50 #endif
53 void UtilityProcessControlImpl::OnLoadFailed() {
54 UtilityThreadImpl* utility_thread =
55 static_cast<UtilityThreadImpl*>(UtilityThread::Get());
56 utility_thread->Shutdown();
57 utility_thread->ReleaseProcessIfNeeded();
60 } // namespace content