diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 12:34:24 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 12:34:24 +0000 |
commit | 0e91dd2a1cec40c6fa0390c890e10dc75398de34 (patch) | |
tree | f4385248c0abb048ec718cb555b5287847bc4429 /net | |
parent | fadf97f2f16f6b3ad2756cd07657c4f47172da92 (diff) | |
download | chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.zip chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.tar.gz chromium_src-0e91dd2a1cec40c6fa0390c890e10dc75398de34.tar.bz2 |
Move GetFreeDiskSpace to SysInfo.
Patch from Pawel Hajdan Jr.
Review URL: http://codereview.chromium.org/3141
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/cache_util.h | 4 | ||||
-rw-r--r-- | net/disk_cache/cache_util_posix.cc | 17 | ||||
-rw-r--r-- | net/disk_cache/cache_util_win.cc | 11 |
4 files changed, 2 insertions, 33 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index d321c83..05d017a 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -8,6 +8,7 @@ #include "base/histogram.h" #include "base/message_loop.h" #include "base/string_util.h" +#include "base/sys_info.h" #include "base/timer.h" #include "base/worker_pool.h" #include "net/disk_cache/cache_util.h" @@ -760,7 +761,7 @@ void BackendImpl::AdjustMaxCacheSize(int table_len) { return; // The user is not setting the size, let's figure it out. - int64 available = GetFreeDiskSpace(path_); + int64 available = base::SysInfo::AmountOfFreeDiskSpace(path_); if (available < 0) { max_size_ = kDefaultCacheSize; return; diff --git a/net/disk_cache/cache_util.h b/net/disk_cache/cache_util.h index 9df9b38..7abebe0 100644 --- a/net/disk_cache/cache_util.h +++ b/net/disk_cache/cache_util.h @@ -11,10 +11,6 @@ namespace disk_cache { -// Returns the available disk space on the volume that contains |path| -// (in bytes), or -1 on failure. -int64 GetFreeDiskSpace(const std::wstring& path); - // 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 6928187..80134b4 100644 --- a/net/disk_cache/cache_util_posix.cc +++ b/net/disk_cache/cache_util_posix.cc @@ -4,29 +4,12 @@ #include "net/disk_cache/cache_util.h" -#include <errno.h> -#include <sys/statvfs.h> -#include <unistd.h> - #include "base/file_util.h" #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) { - struct statvfs stats; - if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) { - return -1; - } - return static_cast<int64>(stats.f_bavail) * stats.f_frsize; -} - 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 dd4de1d..377cbbf 100644 --- a/net/disk_cache/cache_util_win.cc +++ b/net/disk_cache/cache_util_win.cc @@ -38,17 +38,6 @@ void DeleteFiles(const wchar_t* path, const wchar_t* search_name) { namespace disk_cache { -int64 GetFreeDiskSpace(const std::wstring& path) { - ULARGE_INTEGER available, total, free; - if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) { - return -1; - } - int64 rv = static_cast<int64>(available.QuadPart); - 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. |