blob: f717f8687955514df49db1b597ca61ab4e4d3e7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// 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/bind.h"
#include "content/common/mojo/static_loader.h"
#include "content/public/common/content_client.h"
#include "content/public/utility/content_utility_client.h"
#include "content/public/utility/utility_thread.h"
#include "content/utility/utility_thread_impl.h"
#if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
#include "media/mojo/services/mojo_media_application_factory.h"
#endif
namespace content {
namespace {
// Called when a static application terminates.
void QuitProcess() {
UtilityThread::Get()->ReleaseProcessIfNeeded();
}
} // namespace
UtilityProcessControlImpl::UtilityProcessControlImpl() {}
UtilityProcessControlImpl::~UtilityProcessControlImpl() {}
void UtilityProcessControlImpl::RegisterLoaders(
NameToLoaderMap* name_to_loader_map) {
NameToLoaderMap& map_ref = *name_to_loader_map;
ContentUtilityClient::StaticMojoApplicationMap apps;
GetContentClient()->utility()->RegisterMojoApplications(&apps);
for (const auto& entry : apps) {
map_ref[entry.first] =
new StaticLoader(entry.second, base::Bind(&QuitProcess));
}
#if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
map_ref["mojo:media"] = new StaticLoader(
base::Bind(&media::CreateMojoMediaApplication), base::Bind(&QuitProcess));
#endif
}
void UtilityProcessControlImpl::OnLoadFailed() {
UtilityThreadImpl* utility_thread =
static_cast<UtilityThreadImpl*>(UtilityThread::Get());
utility_thread->Shutdown();
utility_thread->ReleaseProcessIfNeeded();
}
} // namespace content
|