We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / content / common / sandbox_linux / bpf_gpu_policy_linux.h
blobcc66c5bc96f8768a4eeff4e622c6a34348ebd3a9
1 // Copyright 2013 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 #ifndef CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
14 namespace sandbox {
15 namespace syscall_broker {
16 class BrokerFilePermission;
17 class BrokerProcess;
21 namespace content {
23 class GpuProcessPolicy : public SandboxBPFBasePolicy {
24 public:
25 GpuProcessPolicy();
26 explicit GpuProcessPolicy(bool allow_mincore);
27 ~GpuProcessPolicy() override;
29 sandbox::bpf_dsl::ResultExpr EvaluateSyscall(
30 int system_call_number) const override;
32 bool PreSandboxHook() override;
34 protected:
35 // Start a broker process to handle open() inside the sandbox.
36 // |broker_sandboxer_allocator| is a function pointer which can allocate a
37 // suitable sandbox policy for the broker process itself.
38 // |permissions_extra| is a list of file permissions
39 // that should be whitelisted by the broker process, in addition to
40 // the basic ones.
41 void InitGpuBrokerProcess(
42 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void),
43 const std::vector<sandbox::syscall_broker::BrokerFilePermission>&
44 permissions_extra);
46 sandbox::syscall_broker::BrokerProcess* broker_process() {
47 return broker_process_;
50 private:
51 // A BrokerProcess is a helper that is started before the sandbox is engaged
52 // and will serve requests to access files over an IPC channel. The client of
53 // this runs from a SIGSYS handler triggered by the seccomp-bpf sandbox.
54 // This should never be destroyed, as after the sandbox is started it is
55 // vital to the process.
56 // This is allocated by InitGpuBrokerProcess, called from PreSandboxHook(),
57 // which executes iff the sandbox is going to be enabled afterwards.
58 sandbox::syscall_broker::BrokerProcess* broker_process_;
60 // eglCreateWindowSurface() needs mincore().
61 bool allow_mincore_;
63 DISALLOW_COPY_AND_ASSIGN(GpuProcessPolicy);
66 } // namespace content
68 #endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_