forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.cc
74 lines (59 loc) · 2.54 KB
/
service.cc
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2017 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 "services/viz/service.h"
#include "base/command_line.h"
#include "components/viz/service/main/viz_main_impl.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/config/gpu_switches.h"
#include "media/gpu/buildflags.h"
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
#if defined(OS_CHROMEOS) && BUILDFLAG(USE_VAAPI)
#include "media/gpu/vaapi/vaapi_wrapper.h"
#endif
namespace viz {
Service::Service(service_manager::mojom::ServiceRequest request)
: service_binding_(this, std::move(request)) {}
Service::~Service() = default;
void Service::OnStart() {
base::PlatformThread::SetName("VizMain");
registry_.AddInterface<mojom::VizMain>(
base::Bind(&Service::BindVizMainRequest, base::Unretained(this)));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
gpu::GpuPreferences gpu_preferences;
if (command_line->HasSwitch(switches::kGpuPreferences)) {
std::string value =
command_line->GetSwitchValueASCII(switches::kGpuPreferences);
bool success = gpu_preferences.FromSwitchValue(value);
CHECK(success);
}
auto gpu_init = std::make_unique<gpu::GpuInit>();
gpu_init->set_sandbox_helper(this);
gpu_init->InitializeAndStartSandbox(command_line, gpu_preferences);
VizMainImpl::ExternalDependencies deps;
deps.create_display_compositor = true;
deps.connector = service_binding_.GetConnector();
viz_main_ = std::make_unique<VizMainImpl>(nullptr, std::move(deps),
std::move(gpu_init));
}
void Service::OnBindInterface(const service_manager::BindSourceInfo& info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void Service::BindVizMainRequest(mojom::VizMainRequest request) {
viz_main_->Bind(std::move(request));
}
void Service::PreSandboxStartup() {
#if defined(OS_CHROMEOS) && BUILDFLAG(USE_VAAPI)
media::VaapiWrapper::PreSandboxInitialization();
#endif
// TODO(sad): https://crbug.com/645602
}
bool Service::EnsureSandboxInitialized(gpu::GpuWatchdogThread* watchdog_thread,
const gpu::GPUInfo* gpu_info,
const gpu::GpuPreferences& gpu_prefs) {
// TODO(sad): https://crbug.com/645602
return true;
}
} // namespace viz