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

Side by Side Diff: chrome/browser/chromeos/drive/file_cache.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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/drive/file_cache.h" 5 #include "chrome/browser/chromeos/drive/file_cache.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 path_to_delete_pattern.DirName(), 116 path_to_delete_pattern.DirName(),
117 false, // not recursive 117 false, // not recursive
118 base::FileEnumerator::FILES, 118 base::FileEnumerator::FILES,
119 path_to_delete_pattern.BaseName().value()); 119 path_to_delete_pattern.BaseName().value());
120 for (base::FilePath current = enumerator.Next(); !current.empty(); 120 for (base::FilePath current = enumerator.Next(); !current.empty();
121 current = enumerator.Next()) { 121 current = enumerator.Next()) {
122 // If |path_to_keep| is not empty and same as current, don't delete it. 122 // If |path_to_keep| is not empty and same as current, don't delete it.
123 if (!path_to_keep.empty() && current == path_to_keep) 123 if (!path_to_keep.empty() && current == path_to_keep)
124 continue; 124 continue;
125 125
126 success = file_util::Delete(current, false); 126 success = base::Delete(current, false);
127 if (!success) 127 if (!success)
128 DVLOG(1) << "Error deleting " << current.value(); 128 DVLOG(1) << "Error deleting " << current.value();
129 else 129 else
130 DVLOG(1) << "Deleted " << current.value(); 130 DVLOG(1) << "Deleted " << current.value();
131 } 131 }
132 } 132 }
133 133
134 // Runs callback with pointers dereferenced. 134 // Runs callback with pointers dereferenced.
135 // Used to implement GetFile, MarkAsMounted. 135 // Used to implement GetFile, MarkAsMounted.
136 void RunGetFileFromCacheCallback( 136 void RunGetFileFromCacheCallback(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 base::FileEnumerator enumerator(cache_file_directory_, 303 base::FileEnumerator enumerator(cache_file_directory_,
304 false, // not recursive 304 false, // not recursive
305 base::FileEnumerator::FILES); 305 base::FileEnumerator::FILES);
306 std::string resource_id; 306 std::string resource_id;
307 std::string md5; 307 std::string md5;
308 FileCacheEntry entry; 308 FileCacheEntry entry;
309 for (base::FilePath current = enumerator.Next(); !current.empty(); 309 for (base::FilePath current = enumerator.Next(); !current.empty();
310 current = enumerator.Next()) { 310 current = enumerator.Next()) {
311 util::ParseCacheFilePath(current, &resource_id, &md5); 311 util::ParseCacheFilePath(current, &resource_id, &md5);
312 if (!GetCacheEntry(resource_id, md5, &entry)) 312 if (!GetCacheEntry(resource_id, md5, &entry))
313 file_util::Delete(current, false /* recursive */); 313 base::Delete(current, false /* recursive */);
314 } 314 }
315 315
316 // Check the disk space again. 316 // Check the disk space again.
317 return HasEnoughSpaceFor(num_bytes, cache_file_directory_); 317 return HasEnoughSpaceFor(num_bytes, cache_file_directory_);
318 } 318 }
319 319
320 void FileCache::GetFileOnUIThread(const std::string& resource_id, 320 void FileCache::GetFileOnUIThread(const std::string& resource_id,
321 const std::string& md5, 321 const std::string& md5,
322 const GetFileFromCacheCallback& callback) { 322 const GetFileFromCacheCallback& callback) {
323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 784
785 if (it->HasError()) 785 if (it->HasError())
786 return false; 786 return false;
787 787
788 // Remove files. 788 // Remove files.
789 base::FileEnumerator enumerator(cache_file_directory_, 789 base::FileEnumerator enumerator(cache_file_directory_,
790 false, // not recursive 790 false, // not recursive
791 base::FileEnumerator::FILES); 791 base::FileEnumerator::FILES);
792 for (base::FilePath file = enumerator.Next(); !file.empty(); 792 for (base::FilePath file = enumerator.Next(); !file.empty();
793 file = enumerator.Next()) 793 file = enumerator.Next())
794 file_util::Delete(file, false /* recursive */); 794 base::Delete(file, false /* recursive */);
795 795
796 return true; 796 return true;
797 } 797 }
798 798
799 bool FileCache::HasEnoughSpaceFor(int64 num_bytes, 799 bool FileCache::HasEnoughSpaceFor(int64 num_bytes,
800 const base::FilePath& path) { 800 const base::FilePath& path) {
801 int64 free_space = 0; 801 int64 free_space = 0;
802 if (free_disk_space_getter_) 802 if (free_disk_space_getter_)
803 free_space = free_disk_space_getter_->AmountOfFreeDiskSpace(); 803 free_space = free_disk_space_getter_->AmountOfFreeDiskSpace();
804 else 804 else
(...skipping 20 matching lines...) Expand all
825 if (storage_->GetCacheEntry(it->GetKey(), &entry)) 825 if (storage_->GetCacheEntry(it->GetKey(), &entry))
826 continue; // Do not overwrite. 826 continue; // Do not overwrite.
827 827
828 storage_->PutCacheEntry(it->GetKey(), it->GetValue()); 828 storage_->PutCacheEntry(it->GetKey(), it->GetValue());
829 } 829 }
830 imported = true; 830 imported = true;
831 } 831 }
832 } 832 }
833 833
834 // Delete old DB. 834 // Delete old DB.
835 file_util::Delete(old_db_path, true /* recursive */ ); 835 base::Delete(old_db_path, true /* recursive */ );
836 return imported; 836 return imported;
837 } 837 }
838 838
839 } // namespace internal 839 } // namespace internal
840 } // namespace drive 840 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_database.cc ('k') | chrome/browser/chromeos/drive/file_cache_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698