OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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. | |
4 | |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_HELPERS_BPF_DSL_H_ | |
6 #define SANDBOX_LINUX_SECCOMP_BPF_HELPERS_BPF_DSL_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "sandbox/linux/seccomp-bpf/errorcode.h" | |
11 #include "sandbox/sandbox_export.h" | |
12 | |
13 namespace sandbox { | |
14 class SandboxBPF; | |
15 } | |
16 | |
17 namespace sandbox { | |
18 | |
19 namespace bpfdsl { | |
20 | |
21 class CondImpl : public base::RefCounted<CondImpl> { | |
mdempsky
2014/05/20 23:26:29
I really want to change this to
class CondImp
| |
22 public: | |
23 CondImpl() {} | |
24 virtual ErrorCode Compile(SandboxBPF* sb, | |
25 ErrorCode true_ec, | |
26 ErrorCode false_ec) const = 0; | |
27 | |
28 protected: | |
29 friend class base::RefCounted<CondImpl>; | |
30 virtual ~CondImpl() {} | |
31 | |
32 private: | |
33 DISALLOW_COPY_AND_ASSIGN(CondImpl); | |
34 }; | |
35 | |
36 typedef scoped_refptr<const CondImpl> Cond; | |
37 | |
38 SANDBOX_EXPORT Cond operator&&(Cond lhs, Cond rhs); | |
39 SANDBOX_EXPORT Cond operator||(Cond lhs, Cond rhs); | |
40 | |
41 class Iffer; | |
42 class Thener; | |
43 class Elser; | |
44 | |
45 class SANDBOX_EXPORT Iffer { | |
46 public: | |
47 // TODO(mdempsky): Make private? | |
48 explicit Iffer(SandboxBPF* sb); | |
49 Iffer(const Iffer& iffer); | |
50 Thener If(Cond cond) const; | |
51 | |
52 private: | |
53 SandboxBPF* sb_; | |
54 DISALLOW_ASSIGN(Iffer); | |
55 }; | |
56 | |
57 class SANDBOX_EXPORT Thener { | |
58 public: | |
59 ~Thener(); | |
60 Elser Then(ErrorCode ec) const; | |
61 | |
62 private: | |
63 Thener(SandboxBPF* sb, Cond cond); | |
64 SandboxBPF* sb_; | |
65 Cond cond_; | |
66 friend class Iffer; | |
67 friend class Elser; | |
68 DISALLOW_COPY_AND_ASSIGN(Thener); | |
69 }; | |
70 | |
71 class SANDBOX_EXPORT Elser { | |
72 public: | |
73 ~Elser(); | |
74 ErrorCode Else(ErrorCode ec) const; | |
75 | |
76 private: | |
77 Elser(SandboxBPF* sb, Cond cond, ErrorCode true_ec); | |
78 SandboxBPF* sb_; | |
79 Cond cond_; | |
80 ErrorCode true_ec_; | |
81 friend class Iffer; | |
82 friend class Thener; | |
83 DISALLOW_COPY_AND_ASSIGN(Elser); | |
84 }; | |
85 | |
86 } // namespace bpfdsl | |
87 | |
88 SANDBOX_EXPORT bpfdsl::Iffer DSL(SandboxBPF* sb); | |
89 | |
90 template <typename T> | |
91 class SANDBOX_EXPORT Arg { | |
92 public: | |
93 explicit Arg(int num); | |
94 bpfdsl::Cond operator==(const T& rhs) const; | |
95 | |
96 private: | |
97 int num_; | |
98 DISALLOW_COPY_AND_ASSIGN(Arg); | |
99 }; | |
100 | |
101 extern template class Arg<int>; | |
102 | |
103 } // namespace sandbox | |
104 | |
105 #endif // SANDBOX_LINUX_SECCOMP_BPF_HELPERS_BPF_DSL_H_ | |
OLD | NEW |