summaryrefslogtreecommitdiffstats
path: root/sandbox/win
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2015-09-25 15:34:31 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-25 22:36:18 +0000
commit5ea2ab75db847e7506f4e9e6f6b370f65cc1bb39 (patch)
tree85a7fe3d9c8015204eacc8dbdae039fee4d631e8 /sandbox/win
parent997afddb1a38bba06bfd6f048b207434aebc967a (diff)
downloadchromium_src-5ea2ab75db847e7506f4e9e6f6b370f65cc1bb39.zip
chromium_src-5ea2ab75db847e7506f4e9e6f6b370f65cc1bb39.tar.gz
chromium_src-5ea2ab75db847e7506f4e9e6f6b370f65cc1bb39.tar.bz2
Make SharedMemoryHandle a class on windows.
This CL is intended to be a refactor and should not introduce any behavior changes. Previously, SharedMemoryhandle was typedefed to HANDLE. Making it a class allows us to add metainformation about the process in which the HANDLE is valid. This will be used in the future by Chrome's IPC system to automatically duplicate HANDLEs into their destination process. BUG=493414, 535028 Review URL: https://codereview.chromium.org/1320783002 Cr-Commit-Position: refs/heads/master@{#350932}
Diffstat (limited to 'sandbox/win')
-rw-r--r--sandbox/win/src/handle_inheritance_test.cc6
-rw-r--r--sandbox/win/src/policy_target_test.cc4
-rw-r--r--sandbox/win/tests/common/controller.cc10
3 files changed, 11 insertions, 9 deletions
diff --git a/sandbox/win/src/handle_inheritance_test.cc b/sandbox/win/src/handle_inheritance_test.cc
index 95a369a..1a411b5 100644
--- a/sandbox/win/src/handle_inheritance_test.cc
+++ b/sandbox/win/src/handle_inheritance_test.cc
@@ -56,7 +56,7 @@ SBOX_TESTS_COMMAND int
HandleInheritanceTests_ValidInheritedHandle(int argc, wchar_t **argv) {
if (argc != 1)
return SBOX_TEST_FAILED_TO_RUN_TEST;
- base::SharedMemoryHandle handle = nullptr;
+ HANDLE handle = nullptr;
base::StringToUint(argv[0], reinterpret_cast<unsigned int *>(&handle));
// This handle we inherited must be both valid and closeable.
@@ -79,8 +79,8 @@ TEST(HandleInheritanceTests, InheritByValue) {
ASSERT_TRUE(test_shared_memory.Map(0));
TestRunner runner;
- void *shared_handle =
- runner.GetPolicy()->AddHandleToShare(test_shared_memory.handle());
+ void* shared_handle = runner.GetPolicy()->AddHandleToShare(
+ test_shared_memory.handle().GetHandle());
std::string command_line =
"HandleInheritanceTests_ValidInheritedHandle " +
diff --git a/sandbox/win/src/policy_target_test.cc b/sandbox/win/src/policy_target_test.cc
index 4395a4f..bb1f0b2 100644
--- a/sandbox/win/src/policy_target_test.cc
+++ b/sandbox/win/src/policy_target_test.cc
@@ -376,8 +376,8 @@ TEST(PolicyTargetTest, ShareHandleTest) {
GetModuleFileNameW(NULL, prog_name, MAX_PATH);
TargetPolicy* policy = broker->CreatePolicy();
- void* shared_handle = policy->AddHandleToShare(
- read_only_view.handle());
+ void* shared_handle =
+ policy->AddHandleToShare(read_only_view.handle().GetHandle());
base::string16 arguments(L"\"");
arguments += prog_name;
diff --git a/sandbox/win/tests/common/controller.cc b/sandbox/win/tests/common/controller.cc
index 4f90fb4..8d3e29d 100644
--- a/sandbox/win/tests/common/controller.cc
+++ b/sandbox/win/tests/common/controller.cc
@@ -8,6 +8,7 @@
#include "base/memory/shared_memory.h"
#include "base/process/process.h"
+#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
#include "base/win/windows_version.h"
@@ -304,11 +305,12 @@ int DispatchCall(int argc, wchar_t **argv) {
// If the caller shared a shared memory handle with us attempt to open it
// in read only mode and sleep infinitely if we succeed.
if (0 == _wcsicmp(argv[3], L"shared_memory_handle")) {
- base::SharedMemoryHandle shared_handle = NULL;
- base::StringToUint(
- argv[4], reinterpret_cast<unsigned int*>(&shared_handle));
- if (shared_handle == NULL)
+ HANDLE raw_handle = nullptr;
+ base::StringToUint(argv[4], reinterpret_cast<unsigned int*>(&raw_handle));
+ if (raw_handle == nullptr)
return SBOX_TEST_INVALID_PARAMETER;
+ base::SharedMemoryHandle shared_handle(raw_handle,
+ base::GetCurrentProcId());
base::SharedMemory read_only_view(shared_handle, true);
if (!read_only_view.Map(0))
return SBOX_TEST_INVALID_PARAMETER;