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

Unified Diff: sandbox/src/job_unittest.cc

Issue 9959018: Use ScopedProcessInformation and other RAII types in sandbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/src/job_unittest.cc
diff --git a/sandbox/src/job_unittest.cc b/sandbox/src/job_unittest.cc
index 0f7010dd5904e922a0dda9c3587882bb00c7684d..0fe167c9336cc0c5436623c56ca654b9ea235a4f 100644
--- a/sandbox/src/job_unittest.cc
+++ b/sandbox/src/job_unittest.cc
@@ -4,6 +4,7 @@
// This file contains unit tests for the job object.
+#include "base/win/scoped_process_information.h"
#include "sandbox/src/job.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -159,11 +160,11 @@ TEST(JobTest, ProcessInJob) {
wchar_t notepad[] = L"notepad";
STARTUPINFO si = { sizeof(si) };
- PROCESS_INFORMATION pi = {0};
+ base::win::ScopedProcessInformation pi;
result = ::CreateProcess(NULL, notepad, NULL, NULL, FALSE, 0, NULL, NULL, &si,
- &pi);
+ pi.Receive());
ASSERT_TRUE(result);
- ASSERT_EQ(ERROR_SUCCESS, job.AssignProcessToJob(pi.hProcess));
+ ASSERT_EQ(ERROR_SUCCESS, job.AssignProcessToJob(pi.process_handle()));
// Get the job handle.
HANDLE job_handle = job.Detach();
@@ -178,9 +179,9 @@ TEST(JobTest, ProcessInJob) {
EXPECT_EQ(1, jbpidl.NumberOfAssignedProcesses);
EXPECT_EQ(1, jbpidl.NumberOfProcessIdsInList);
- EXPECT_EQ(pi.dwProcessId, jbpidl.ProcessIdList[0]);
+ EXPECT_EQ(pi.process_id(), jbpidl.ProcessIdList[0]);
- EXPECT_TRUE(::TerminateProcess(pi.hProcess, 0));
+ EXPECT_TRUE(::TerminateProcess(pi.process_handle(), 0));
EXPECT_TRUE(::CloseHandle(job_handle));
erikwright (departed) 2012/03/30 16:29:31 Previously process and thread handles were leaked.
}

Powered by Google App Engine
This is Rietveld 408576698