Index: chrome/browser/automation/testing_automation_provider.cc |
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc |
index 64421079bc7e286976d07711e478b4b7b725f202..3ed8e583f1e037caf52e7582a17f0797d1add31d 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -159,7 +159,7 @@ |
#endif |
#if defined(OS_MACOSX) |
-#include "base/mach_ipc_mac.h" |
+#include <mach/mach.h> |
#endif |
#if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
@@ -490,7 +490,30 @@ void TestingAutomationProvider::AppendTab(int handle, |
void TestingAutomationProvider::GetMachPortCount(int* port_count) { |
#if defined(OS_MACOSX) |
- base::mac::GetNumberOfMachPorts(mach_task_self(), port_count); |
+ mach_port_name_array_t names; |
+ mach_msg_type_number_t names_count; |
+ mach_port_type_array_t types; |
+ mach_msg_type_number_t types_count; |
+ |
+ // A friendlier interface would allow NULL buffers to only get the counts. |
+ kern_return_t kr = mach_port_names(mach_task_self(), &names, &names_count, |
Mark Mentovai
2013/04/11 17:02:56
local for mach_task_self() (yeah, even though…)
Robert Sesek
2013/04/11 17:10:32
Done.
|
+ &types, &types_count); |
+ if (kr != KERN_SUCCESS) { |
+ *port_count = -1; |
Mark Mentovai
2013/04/11 17:02:56
-1 for failure on Mac but 0 for “not implemented”
Robert Sesek
2013/04/11 17:10:32
Done.
|
+ return; |
+ } |
+ |
+ // The documentation states this is an invariant. |
+ DCHECK_EQ(names_count, types_count); |
+ *port_count = names_count; |
+ |
+ vm_deallocate(mach_task_self(), |
Mark Mentovai
2013/04/11 17:02:56
For 64-bit compatibility, use mach_vm_deallocate i
Robert Sesek
2013/04/11 17:10:32
Done.
|
+ reinterpret_cast<vm_address_t>(names), |
+ names_count * sizeof(mach_port_name_array_t)); |
+ vm_deallocate(mach_task_self(), |
+ reinterpret_cast<vm_address_t>(types), |
+ types_count * sizeof(mach_port_type_array_t)); |
+ |
#else |
*port_count = 0; |
#endif |