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

Unified Diff: sandbox/win/src/job.cc

Issue 319573006: Add sandbox support for process memory limits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review 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/win/src/job.cc
diff --git a/sandbox/win/src/job.cc b/sandbox/win/src/job.cc
index 62b8d5c3c4b294844970f84cad94b207fc9cb38e..b62f8a588e3be8da6f63bba1f059d1779c1ac997 100644
--- a/sandbox/win/src/job.cc
+++ b/sandbox/win/src/job.cc
@@ -52,11 +52,11 @@ DWORD Job::Init(JobLevel security_level,
jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS;
}
case JOB_UNPROTECTED: {
- // The JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag is not supported on
- // Windows 2000. We need a mechanism on Windows 2000 to ensure
- // that processes in the job are terminated when the job is closed
- if (base::win::GetVersion() == base::win::VERSION_PRE_XP)
- break;
+ if (process_memory_limit_) {
+ jeli.BasicLimitInformation.LimitFlags |=
+ JOB_OBJECT_LIMIT_PROCESS_MEMORY;
+ jeli.ProcessMemoryLimit = process_memory_limit_;
+ }
jeli.BasicLimitInformation.LimitFlags |=
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
@@ -85,6 +85,14 @@ DWORD Job::Init(JobLevel security_level,
return ERROR_SUCCESS;
}
+DWORD Job::SetProcessMemoryLimit(size_t limit) {
+ if (job_handle_)
+ return ERROR_ALREADY_INITIALIZED;
+
+ process_memory_limit_ = limit;
+ return ERROR_SUCCESS;
+}
+
DWORD Job::UserHandleGrantAccess(HANDLE handle) {
if (!job_handle_)
return ERROR_NO_DATA;

Powered by Google App Engine
This is Rietveld 408576698