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.
5 #ifndef SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_
6 #define SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "sandbox/sandbox_export.h"
19 // Internal interface implemented by BoolExpr implementations.
20 class BoolExprImpl
: public base::RefCounted
<BoolExprImpl
> {
22 // Compile uses |pc| to construct an ErrorCode that conditionally continues
23 // to either |true_ec| or |false_ec|, depending on whether the represented
24 // boolean expression is true or false.
25 virtual ErrorCode
Compile(PolicyCompiler
* pc
,
27 ErrorCode false_ec
) const = 0;
31 virtual ~BoolExprImpl() {}
34 friend class base::RefCounted
<BoolExprImpl
>;
35 DISALLOW_COPY_AND_ASSIGN(BoolExprImpl
);
38 // Internal interface implemented by ResultExpr implementations.
39 class ResultExprImpl
: public base::RefCounted
<ResultExprImpl
> {
41 // Compile uses |pc| to construct an ErrorCode analogous to the represented
43 virtual ErrorCode
Compile(PolicyCompiler
* pc
) const = 0;
45 // HasUnsafeTraps returns whether the result expression is or recursively
46 // contains an unsafe trap expression.
47 virtual bool HasUnsafeTraps() const;
49 // IsAllow returns whether the result expression is an "allow" result.
50 virtual bool IsAllow() const;
52 // IsAllow returns whether the result expression is a "deny" result.
53 virtual bool IsDeny() const;
57 virtual ~ResultExprImpl() {}
60 friend class base::RefCounted
<ResultExprImpl
>;
61 DISALLOW_COPY_AND_ASSIGN(ResultExprImpl
);
64 } // namespace internal
65 } // namespace bpf_dsl
66 } // namespace sandbox
68 #endif // SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_