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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_cache.cc

Issue 10854110: Revert 151238 - 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/gdata/gdata_cache.h" 5 #include "chrome/browser/chromeos/gdata/gdata_cache.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/chromeos/chromeos_version.h" 9 #include "base/chromeos/chromeos_version.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 } 825 }
826 826
827 void GDataCache::Store(const std::string& resource_id, 827 void GDataCache::Store(const std::string& resource_id,
828 const std::string& md5, 828 const std::string& md5,
829 const FilePath& source_path, 829 const FilePath& source_path,
830 FileOperationType file_operation_type, 830 FileOperationType file_operation_type,
831 GDataFileError* error) { 831 GDataFileError* error) {
832 AssertOnSequencedWorkerPool(); 832 AssertOnSequencedWorkerPool();
833 DCHECK(error); 833 DCHECK(error);
834 834
835 if (file_operation_type == FILE_OPERATION_COPY) {
836 int64 file_size;
837 if (!file_util::GetFileSize(source_path, &file_size)) {
838 LOG(WARNING) << "Couldn't get file size for: " << source_path.value();
839 *error = GDATA_FILE_ERROR_FAILED;
840 return;
841 }
842
843 bool enough_space = false;
844 FreeDiskSpaceIfNeededFor(file_size, &enough_space);
845 if (!enough_space) {
846 *error = GDATA_FILE_ERROR_NO_SPACE;
847 return;
848 }
849 }
850
851 FilePath dest_path; 835 FilePath dest_path;
852 FilePath symlink_path; 836 FilePath symlink_path;
853 CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP; 837 CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP;
854 838
855 // If file was previously pinned, store it in persistent dir and create 839 // If file was previously pinned, store it in persistent dir and create
856 // symlink in pinned dir. 840 // symlink in pinned dir.
857 GDataCacheEntry cache_entry; 841 GDataCacheEntry cache_entry;
858 if (GetCacheEntry(resource_id, md5, &cache_entry)) { // File exists in cache. 842 if (GetCacheEntry(resource_id, md5, &cache_entry)) { // File exists in cache.
859 // If file is dirty or mounted, return error. 843 // If file is dirty or mounted, return error.
860 if (cache_entry.is_dirty() || cache_entry.is_mounted()) { 844 if (cache_entry.is_dirty() || cache_entry.is_mounted()) {
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 const GDataCacheEntry& cache_entry) { 1579 const GDataCacheEntry& cache_entry) {
1596 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; 1580 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
1597 } 1581 }
1598 1582
1599 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { 1583 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) {
1600 delete global_free_disk_getter_for_testing; // Safe to delete NULL; 1584 delete global_free_disk_getter_for_testing; // Safe to delete NULL;
1601 global_free_disk_getter_for_testing = getter; 1585 global_free_disk_getter_for_testing = getter;
1602 } 1586 }
1603 1587
1604 } // namespace gdata 1588 } // namespace gdata
OLDNEW
« 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