diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-17 15:32:03 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-17 15:32:03 +0000 |
commit | b4f71a8d7e0186a717354e1064a23d5159950846 (patch) | |
tree | b82db787c0a34feb598c802a56730a37a2641e7d | |
parent | def7fce451d9f70ffa602d6e38524cb8ecc8adfa (diff) | |
download | chromium_src-b4f71a8d7e0186a717354e1064a23d5159950846.zip chromium_src-b4f71a8d7e0186a717354e1064a23d5159950846.tar.gz chromium_src-b4f71a8d7e0186a717354e1064a23d5159950846.tar.bz2 |
Revision 2303 introduced AmountOfPhysicalMemory in SysInfo, so now GetSystemMemory in net/disk_cache/cache_util is redundant.
Patch from Pawel Hajdan Jr.
Review URL: http://codereview.chromium.org/3103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2306 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/disk_cache/cache_util.h | 4 | ||||
-rw-r--r-- | net/disk_cache/cache_util_posix.cc | 29 | ||||
-rw-r--r-- | net/disk_cache/cache_util_win.cc | 13 | ||||
-rw-r--r-- | net/disk_cache/mem_backend_impl.cc | 3 |
4 files changed, 2 insertions, 47 deletions
diff --git a/net/disk_cache/cache_util.h b/net/disk_cache/cache_util.h index 0977472..9df9b38 100644 --- a/net/disk_cache/cache_util.h +++ b/net/disk_cache/cache_util.h @@ -15,10 +15,6 @@ namespace disk_cache { // (in bytes), or -1 on failure. int64 GetFreeDiskSpace(const std::wstring& path); -// Returns the total physical memory on the system (in bytes), -// or -1 on failure. -int64 GetSystemMemory(); - // Moves the cache files from the given path to another location. // Returns true if successful, false otherwise. bool MoveCache(const std::wstring& from_path, const std::wstring& to_path); diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc index c912e2b..6928187 100644 --- a/net/disk_cache/cache_util_posix.cc +++ b/net/disk_cache/cache_util_posix.cc @@ -27,35 +27,6 @@ int64 GetFreeDiskSpace(const std::wstring& path) { return static_cast<int64>(stats.f_bavail) * stats.f_frsize; } -int64 GetSystemMemory() { -#if defined(OS_LINUX) - // _SC_PHYS_PAGES is not part of POSIX and not available on OS X - long pages = sysconf(_SC_PHYS_PAGES); - if (pages == -1) { - return -1; - } - long page_size = sysconf(_SC_PAGE_SIZE); - if (page_size == -1) { - return -1; - } - 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 - NOTIMPLEMENTED(); - return -1; -#endif -} - bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { // Just use the version from base. return file_util::Move(from_path.c_str(), to_path.c_str()); diff --git a/net/disk_cache/cache_util_win.cc b/net/disk_cache/cache_util_win.cc index e45388b..dd4de1d 100644 --- a/net/disk_cache/cache_util_win.cc +++ b/net/disk_cache/cache_util_win.cc @@ -49,19 +49,6 @@ int64 GetFreeDiskSpace(const std::wstring& path) { return rv; } -int64 GetSystemMemory() { - MEMORYSTATUSEX memory_info; - memory_info.dwLength = sizeof(memory_info); - if (!GlobalMemoryStatusEx(&memory_info)) { - return -1; - } - - int64 rv = static_cast<int64>(memory_info.ullTotalPhys); - if (rv < 0) - rv = kint64max; - return rv; -} - bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { // I don't want to use the shell version of move because if something goes // wrong, that version will attempt to move file by file and fail at the end. diff --git a/net/disk_cache/mem_backend_impl.cc b/net/disk_cache/mem_backend_impl.cc index 8eb4e6a..cf4a411 100644 --- a/net/disk_cache/mem_backend_impl.cc +++ b/net/disk_cache/mem_backend_impl.cc @@ -4,6 +4,7 @@ #include "net/disk_cache/mem_backend_impl.h" +#include "base/sys_info.h" #include "net/disk_cache/cache_util.h" #include "net/disk_cache/mem_entry_impl.h" @@ -40,7 +41,7 @@ bool MemBackendImpl::Init() { if (max_size_) return true; - int64 total_memory = GetSystemMemory(); + int64 total_memory = base::SysInfo::AmountOfPhysicalMemory(); if (total_memory < 0) { max_size_ = kDefaultCacheSize; |