| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ | 5 #ifndef SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ |
| 6 #define SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ | 6 #define SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "sandbox/sandbox_export.h" | 10 #include "sandbox/sandbox_export.h" |
| 11 | 11 |
| 12 namespace sandbox { | 12 namespace sandbox { |
| 13 class ErrorCode; | 13 class ErrorCode; |
| 14 class SandboxBPF; | |
| 15 | 14 |
| 16 namespace bpf_dsl { | 15 namespace bpf_dsl { |
| 16 class PolicyCompiler; |
| 17 |
| 17 namespace internal { | 18 namespace internal { |
| 18 | 19 |
| 19 // Internal interface implemented by BoolExpr implementations. | 20 // Internal interface implemented by BoolExpr implementations. |
| 20 class BoolExprImpl : public base::RefCounted<BoolExprImpl> { | 21 class BoolExprImpl : public base::RefCounted<BoolExprImpl> { |
| 21 public: | 22 public: |
| 22 BoolExprImpl() {} | 23 // Compile uses |pc| to construct an ErrorCode that conditionally continues |
| 24 // to either |true_ec| or |false_ec|, depending on whether the represented |
| 25 // boolean expression is true or false. |
| 23 virtual ErrorCode Compile(PolicyCompiler* pc, | 26 virtual ErrorCode Compile(PolicyCompiler* pc, |
| 24 ErrorCode true_ec, | 27 ErrorCode true_ec, |
| 25 ErrorCode false_ec) const = 0; | 28 ErrorCode false_ec) const = 0; |
| 26 | 29 |
| 27 protected: | 30 protected: |
| 31 BoolExprImpl() {} |
| 28 virtual ~BoolExprImpl() {} | 32 virtual ~BoolExprImpl() {} |
| 29 | 33 |
| 30 private: | 34 private: |
| 31 friend class base::RefCounted<BoolExprImpl>; | 35 friend class base::RefCounted<BoolExprImpl>; |
| 32 DISALLOW_COPY_AND_ASSIGN(BoolExprImpl); | 36 DISALLOW_COPY_AND_ASSIGN(BoolExprImpl); |
| 33 }; | 37 }; |
| 34 | 38 |
| 35 // Internal interface implemented by ResultExpr implementations. | 39 // Internal interface implemented by ResultExpr implementations. |
| 36 class ResultExprImpl : public base::RefCounted<ResultExprImpl> { | 40 class ResultExprImpl : public base::RefCounted<ResultExprImpl> { |
| 37 public: | 41 public: |
| 38 ResultExprImpl() {} | 42 // Compile uses |pc| to construct an ErrorCode analogous to the represented |
| 43 // result expression. |
| 39 virtual ErrorCode Compile(PolicyCompiler* pc) const = 0; | 44 virtual ErrorCode Compile(PolicyCompiler* pc) const = 0; |
| 45 |
| 46 // HasUnsafeTraps returns whether the result expression is or recursively |
| 47 // contains an unsafe trap expression. |
| 40 virtual bool HasUnsafeTraps() const; | 48 virtual bool HasUnsafeTraps() const; |
| 41 | 49 |
| 42 protected: | 50 protected: |
| 51 ResultExprImpl() {} |
| 43 virtual ~ResultExprImpl() {} | 52 virtual ~ResultExprImpl() {} |
| 44 | 53 |
| 45 private: | 54 private: |
| 46 friend class base::RefCounted<ResultExprImpl>; | 55 friend class base::RefCounted<ResultExprImpl>; |
| 47 DISALLOW_COPY_AND_ASSIGN(ResultExprImpl); | 56 DISALLOW_COPY_AND_ASSIGN(ResultExprImpl); |
| 48 }; | 57 }; |
| 49 | 58 |
| 50 } // namespace internal | 59 } // namespace internal |
| 51 } // namespace bpf_dsl | 60 } // namespace bpf_dsl |
| 52 } // namespace sandbox | 61 } // namespace sandbox |
| 53 | 62 |
| 54 #endif // SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ | 63 #endif // SANDBOX_LINUX_BPF_DSL_BPF_DSL_IMPL_H_ |
| OLD | NEW |