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

Unified Diff: ipc/test_util_mac.cc

Issue 1422873002: Reland 1: "mac: Add auto-close and share-read-only functionality to SharedMemory." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix error. Created 5 years, 2 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 | « ipc/test_util_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/test_util_mac.cc
diff --git a/ipc/test_util_mac.cc b/ipc/test_util_mac.cc
index 4639b13babe9f90ab8fd524c7d390c53b973797c..87270773f9ba6d3de4a41e0193155f22e8260074 100644
--- a/ipc/test_util_mac.cc
+++ b/ipc/test_util_mac.cc
@@ -4,6 +4,7 @@
#include "ipc/test_util_mac.h"
+#include <mach/mach_vm.h>
#include <servers/bootstrap.h>
#include "base/mac/mach_logging.h"
@@ -114,4 +115,28 @@ void IncrementMachRefCount(mach_port_name_t name, mach_port_right_t right) {
MACH_CHECK(kr == KERN_SUCCESS, kr) << "GetRefCount";
}
+bool GetMachProtections(void* address, size_t size, int* current, int* max) {
+ vm_region_info_t region_info;
+ mach_vm_address_t mem_address = reinterpret_cast<mach_vm_address_t>(address);
+ mach_vm_size_t mem_size = size;
+ vm_region_basic_info_64 basic_info;
+
+ region_info = reinterpret_cast<vm_region_recurse_info_t>(&basic_info);
+ vm_region_flavor_t flavor = VM_REGION_BASIC_INFO_64;
+ memory_object_name_t memory_object;
+ mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
+
+ kern_return_t kr =
+ mach_vm_region(mach_task_self(), &mem_address, &mem_size, flavor,
+ region_info, &count, &memory_object);
+ if (kr != KERN_SUCCESS) {
+ MACH_LOG(ERROR, kr) << "Failed to get region info.";
+ return false;
+ }
+
+ *current = basic_info.protection;
+ *max = basic_info.max_protection;
+ return true;
+}
+
} // namespace IPC
« no previous file with comments | « ipc/test_util_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698