Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: chrome/browser/chromeos/gdata/gdata_cache.cc

Issue 10831279: Check for space before storing files to the cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_cache.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_cache.cc b/chrome/browser/chromeos/gdata/gdata_cache.cc
index 059e4f0d29950d36a42058dc4062269ac301ec97..f728f76d6dccb42b881b8515b64bec3fba74e550 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache.cc
@@ -832,6 +832,20 @@ void GDataCache::Store(const std::string& resource_id,
AssertOnSequencedWorkerPool();
DCHECK(error);
kinaba 2012/08/13 05:06:30 I think we can wrap whole these checks with: if (f
Zachary Kuznia 2012/08/13 05:12:26 Done.
+ int64 file_size;
+ if (!file_util::GetFileSize(source_path, &file_size)) {
+ LOG(WARNING) << "Couldn't get file size for: " << source_path.value();
+ *error = GDATA_FILE_ERROR_FAILED;
+ return;
+ }
+
+ bool enough_space = false;
+ FreeDiskSpaceIfNeededFor(file_size, &enough_space);
+ if (!enough_space) {
+ *error = GDATA_FILE_ERROR_NO_SPACE;
+ return;
+ }
+
FilePath dest_path;
FilePath symlink_path;
CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP;
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698