Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/bpf_dsl.h

Issue 299743002: Add domain-specific language for BPF policies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify slightly by making Cond into a typedef Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_
OLDNEW
« no previous file with comments | « sandbox/linux/sandbox_linux_test_sources.gypi ('k') | sandbox/linux/seccomp-bpf-helpers/bpf_dsl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698