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

Unified Diff: content/common/sandbox_init_mac.cc

Issue 2944623003: Call SetApplicationIsDaemon() in V2 sandbox. (Closed)
Patch Set: Only execute callback if not-null Created 3 years, 5 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 | « content/common/sandbox_init_mac.h ('k') | content/common/sandbox_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_init_mac.cc
diff --git a/content/common/sandbox_init_mac.cc b/content/common/sandbox_init_mac.cc
index f73e85db4d109045820688b28b0924360a07169b..314bfbb5dd2080c38b722ace5d94265ff7786afb 100644
--- a/content/common/sandbox_init_mac.cc
+++ b/content/common/sandbox_init_mac.cc
@@ -4,6 +4,7 @@
#include "content/common/sandbox_init_mac.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
@@ -14,14 +15,28 @@
namespace content {
-bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) {
+namespace {
+
+bool InitializeSandbox(int sandbox_type,
+ const base::FilePath& allowed_dir,
+ base::OnceClosure hook) {
// Warm up APIs before turning on the sandbox.
Sandbox::SandboxWarmup(sandbox_type);
+ // Execute the post warmup callback.
+ if (!hook.is_null())
+ std::move(hook).Run();
+
// Actually sandbox the process.
return Sandbox::EnableSandbox(sandbox_type, allowed_dir);
}
+} // namespace
+
+bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) {
+ return InitializeSandbox(sandbox_type, allowed_dir, base::OnceClosure());
+}
+
// Fill in |sandbox_type| and |allowed_dir| based on the command line, returns
// false if the current process type doesn't need to be sandboxed or if the
// sandbox was disabled from the command line.
@@ -72,12 +87,16 @@ bool GetSandboxTypeFromCommandLine(int* sandbox_type,
return true;
}
-bool InitializeSandbox() {
+bool InitializeSandboxWithPostWarmupHook(base::OnceClosure hook) {
int sandbox_type = 0;
base::FilePath allowed_dir;
if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir))
return true;
- return InitializeSandbox(sandbox_type, allowed_dir);
+ return InitializeSandbox(sandbox_type, allowed_dir, std::move(hook));
+}
+
+bool InitializeSandbox() {
+ return InitializeSandboxWithPostWarmupHook(base::OnceClosure());
}
} // namespace content
« no previous file with comments | « content/common/sandbox_init_mac.h ('k') | content/common/sandbox_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698