summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-12 21:44:23 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-12 21:44:23 +0000
commit7d11f6d55ae2c731a6426b96fbbe492807f65982 (patch)
treee1a30d0d58da436430eb036a9f092190f459e704 /base
parent062c08a28b335742faaca102db1949ec1ece0b5a (diff)
downloadchromium_src-7d11f6d55ae2c731a6426b96fbbe492807f65982.zip
chromium_src-7d11f6d55ae2c731a6426b96fbbe492807f65982.tar.gz
chromium_src-7d11f6d55ae2c731a6426b96fbbe492807f65982.tar.bz2
Used process_util methods to wait for the service process to die in the ServiceProcessControlBrowserTest.
BUG=None TEST=browser_tests. Review URL: http://codereview.chromium.org/3653005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util.h44
-rw-r--r--base/process_util_posix.cc8
-rw-r--r--base/process_util_win.cc12
3 files changed, 63 insertions, 1 deletions
diff --git a/base/process_util.h b/base/process_util.h
index 6876e88..38d96ec 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -50,7 +50,6 @@ class FilePath;
namespace base {
#if defined(OS_WIN)
-
struct ProcessEntry : public PROCESSENTRY32 {
ProcessId pid() const { return th32ProcessID; }
ProcessId parent_pid() const { return th32ParentProcessID; }
@@ -60,6 +59,25 @@ struct ProcessEntry : public PROCESSENTRY32 {
struct IoCounters : public IO_COUNTERS {
};
+// Process access masks. These constants provide platform-independent
+// definitions for the standard Windows access masks.
+// See http://msdn.microsoft.com/en-us/library/ms684880(VS.85).aspx for
+// the specific semantics of each mask value.
+const uint32 kProcessAccessTerminate = PROCESS_TERMINATE;
+const uint32 kProcessAccessCreateThread = PROCESS_CREATE_THREAD;
+const uint32 kProcessAccessSetSessionId = PROCESS_SET_SESSIONID;
+const uint32 kProcessAccessVMOperation = PROCESS_VM_OPERATION;
+const uint32 kProcessAccessVMRead = PROCESS_VM_READ;
+const uint32 kProcessAccessVMWrite = PROCESS_VM_WRITE;
+const uint32 kProcessAccessDuplicateHandle = PROCESS_DUP_HANDLE;
+const uint32 kProcessAccessCreateProcess = PROCESS_CREATE_PROCESS;
+const uint32 kProcessAccessSetQuota = PROCESS_SET_QUOTA;
+const uint32 kProcessAccessSetInformation = PROCESS_SET_INFORMATION;
+const uint32 kProcessAccessQueryInformation = PROCESS_QUERY_INFORMATION;
+const uint32 kProcessAccessSuspendResume = PROCESS_SUSPEND_RESUME;
+const uint32 kProcessAccessQueryLimitedInfomation =
+ PROCESS_QUERY_LIMITED_INFORMATION;
+const uint32 kProcessAccessWaitForTermination = SYNCHRONIZE;
#elif defined(OS_POSIX)
struct ProcessEntry {
@@ -87,6 +105,22 @@ struct IoCounters {
uint64_t OtherTransferCount;
};
+// Process access masks. They are not used on Posix because access checking
+// does not happen during handle creation.
+const uint32 kProcessAccessTerminate = 0;
+const uint32 kProcessAccessCreateThread = 0;
+const uint32 kProcessAccessSetSessionId = 0;
+const uint32 kProcessAccessVMOperation = 0;
+const uint32 kProcessAccessVMRead = 0;
+const uint32 kProcessAccessVMWrite = 0;
+const uint32 kProcessAccessDuplicateHandle = 0;
+const uint32 kProcessAccessCreateProcess = 0;
+const uint32 kProcessAccessSetQuota = 0;
+const uint32 kProcessAccessSetInformation = 0;
+const uint32 kProcessAccessQueryInformation = 0;
+const uint32 kProcessAccessSuspendResume = 0;
+const uint32 kProcessAccessQueryLimitedInfomation = 0;
+const uint32 kProcessAccessWaitForTermination = 0;
#endif // defined(OS_POSIX)
// A minimalistic but hopefully cross-platform set of exit codes.
@@ -112,8 +146,16 @@ bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle);
// with more access rights and must only be used by trusted code.
// You have to close returned handle using CloseProcessHandle. Returns true
// on success.
+// TODO(sanjeevr): Replace all calls to OpenPrivilegedProcessHandle with the
+// more specific OpenProcessHandleWithAccess method and delete this.
bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle);
+// Converts a PID to a process handle using the desired access flags. Use a
+// combination of the kProcessAccess* flags defined above for |access_flags|.
+bool OpenProcessHandleWithAccess(ProcessId pid,
+ uint32 access_flags,
+ ProcessHandle* handle);
+
// Closes the process handle opened by OpenProcessHandle.
void CloseProcessHandle(ProcessHandle process);
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 31a8e9d..d3b8818 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -139,6 +139,14 @@ bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) {
return OpenProcessHandle(pid, handle);
}
+bool OpenProcessHandleWithAccess(ProcessId pid,
+ uint32 access_flags,
+ ProcessHandle* handle) {
+ // On POSIX permissions are checked for each operation on process,
+ // not when opening a "handle".
+ return OpenProcessHandle(pid, handle);
+}
+
void CloseProcessHandle(ProcessHandle process) {
// See OpenProcessHandle, nothing to do.
return;
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index c5d7790..f3e0cac 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -119,6 +119,18 @@ bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) {
return true;
}
+bool OpenProcessHandleWithAccess(ProcessId pid,
+ uint32 access_flags,
+ ProcessHandle* handle) {
+ ProcessHandle result = OpenProcess(access_flags, FALSE, pid);
+
+ if (result == INVALID_HANDLE_VALUE)
+ return false;
+
+ *handle = result;
+ return true;
+}
+
void CloseProcessHandle(ProcessHandle process) {
CloseHandle(process);
}