diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 13:43:59 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 13:43:59 +0000 |
commit | 75ea01c8732f2a73facdbe660d15a7a6cceb23eb (patch) | |
tree | b257c1d10560fc3f8d07d1b2f15f95324413853f /net/disk_cache/cache_util_posix.cc | |
parent | f4062cd572df635ecd2ca4c2ca4ac3cd67117027 (diff) | |
download | chromium_src-75ea01c8732f2a73facdbe660d15a7a6cceb23eb.zip chromium_src-75ea01c8732f2a73facdbe660d15a7a6cceb23eb.tar.gz chromium_src-75ea01c8732f2a73facdbe660d15a7a6cceb23eb.tar.bz2 |
Mac/mach implementation of disk_cache::GetSystemMemory(). Patch by Kelly
Norton <knorton@google.com>.
http://codereview.chromium.org/3078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/cache_util_posix.cc')
-rw-r--r-- | net/disk_cache/cache_util_posix.cc | 15 |
1 files changed, 14 insertions, 1 deletions
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 <mach/mach_host.h> +#include <mach/mach_init.h> +#endif + namespace disk_cache { int64 GetFreeDiskSpace(const std::wstring& path) { @@ -36,8 +41,16 @@ int64 GetSystemMemory() { int64 result = static_cast<int64>(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<host_info_t>(&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 |