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

Unified Diff: sandbox/linux/seccomp-bpf-helpers/cons.h

Issue 299743002: Add domain-specific language for BPF policies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add explicit virtual destructors to test policies Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf-helpers/cons.h
diff --git a/sandbox/linux/seccomp-bpf-helpers/cons.h b/sandbox/linux/seccomp-bpf-helpers/cons.h
new file mode 100644
index 0000000000000000000000000000000000000000..e60797e5de4b83dcbecc3be545f4d909ab8b877e
--- /dev/null
+++ b/sandbox/linux/seccomp-bpf-helpers/cons.h
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_
+#define SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_
+
+#include "base/memory/ref_counted.h"
+#include "sandbox/sandbox_export.h"
+
+namespace sandbox {
+
+// Cons provides an immutable linked list abstraction as commonly
+// provided in functional programming languages like Lisp or Haskell.
+template <typename T>
+class Cons : public base::RefCounted<Cons<T> > {
+ public:
+ // List provides an abstraction for referencing a list of zero or
+ // more Cons nodes.
+ typedef scoped_refptr<const Cons<T> > List;
+
+ // Return this node's head element.
+ const T& head() const { return head_; }
+
+ // Return this node's tail element.
+ List tail() const { return tail_; }
+
+ // Construct a new List using |head| and |tail|.
+ static List Make(const T& head, List tail) {
+ return make_scoped_refptr(new const Cons<T>(head, tail));
+ }
+
+ private:
+ Cons(const T& head, List tail) : head_(head), tail_(tail) {}
+ virtual ~Cons() {}
+
+ T head_;
+ List tail_;
+
+ friend class base::RefCounted<Cons<T> >;
+ DISALLOW_COPY_AND_ASSIGN(Cons);
+};
+
+} // namespace sandbox
+
+#endif // SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_

Powered by Google App Engine
This is Rietveld 408576698