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

Unified Diff: sandbox/mac/sandbox_compiler.h

Issue 2686433002: Move SandboxCompiler class into the sandbox library. (Closed)
Patch Set: Try getting rid of sysctl-read Created 3 years, 10 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
« no previous file with comments | « sandbox/mac/BUILD.gn ('k') | sandbox/mac/sandbox_compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/mac/sandbox_compiler.h
diff --git a/sandbox/mac/sandbox_compiler.h b/sandbox/mac/sandbox_compiler.h
new file mode 100644
index 0000000000000000000000000000000000000000..826dc8edc52f91418336a8d9fc38e65c1b96fc6f
--- /dev/null
+++ b/sandbox/mac/sandbox_compiler.h
@@ -0,0 +1,50 @@
+// Copyright 2017 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_MAC_SANDBOX_COMPILER_H_
+#define SANDBOX_MAC_SANDBOX_COMPILER_H_
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+#include "sandbox/mac/seatbelt_export.h"
+
+namespace sandbox {
+
+// This class wraps the C-style sandbox APIs in a class to ensure proper
+// initialization and cleanup.
+class SEATBELT_EXPORT SandboxCompiler {
+ public:
+ explicit SandboxCompiler(const std::string& profile_str);
+
+ ~SandboxCompiler();
+
+ // Inserts a boolean into the parameters key/value map. A duplicate key is not
+ // allowed, and will cause the function to return false. The value is not
+ // inserted in this case.
+ bool InsertBooleanParam(const std::string& key, bool value);
+
+ // Inserts a string into the parameters key/value map. A duplicate key is not
+ // allowed, and will cause the function to return false. The value is not
+ // inserted in this case.
+ bool InsertStringParam(const std::string& key, const std::string& value);
+
+ // Compiles and applies the profile; returns true on success.
+ bool CompileAndApplyProfile(std::string* error);
+
+ private:
+ // Storage of the key/value pairs of strings that are used in the sandbox
+ // profile.
+ std::map<std::string, std::string> params_map_;
+
+ // The sandbox profile source code.
+ const std::string profile_str_;
+
+ DISALLOW_COPY_AND_ASSIGN(SandboxCompiler);
+};
+
+} // namespace sandbox
+
+#endif // SANDBOX_MAC_SANDBOX_COMPILER_H_
« no previous file with comments | « sandbox/mac/BUILD.gn ('k') | sandbox/mac/sandbox_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698