From 75ea01c8732f2a73facdbe660d15a7a6cceb23eb Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Tue, 16 Sep 2008 13:43:59 +0000 Subject: Mac/mach implementation of disk_cache::GetSystemMemory(). Patch by Kelly Norton . http://codereview.chromium.org/3078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2258 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/cache_util_posix.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'net/disk_cache') diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc index 041b2b5..c912e2b 100644 --- a/net/disk_cache/cache_util_posix.cc +++ b/net/disk_cache/cache_util_posix.cc @@ -12,6 +12,11 @@ #include "base/logging.h" #include "base/string_util.h" +#if defined(OS_MACOSX) +#include +#include +#endif + namespace disk_cache { int64 GetFreeDiskSpace(const std::wstring& path) { @@ -36,8 +41,16 @@ int64 GetSystemMemory() { int64 result = static_cast(pages) * page_size; DCHECK(result > 0); return result; +#elif defined(OS_MACOSX) + struct host_basic_info hostinfo; + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; + int result = host_info(mach_host_self(), + HOST_BASIC_INFO, + reinterpret_cast(&hostinfo), + &count); + DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); + return (result == KERN_SUCCESS) ? hostinfo.max_mem : -1; #else - // TODO(pinkerton): figure this out for mac NOTIMPLEMENTED(); return -1; #endif -- cgit v1.1