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

Unified Diff: chrome/browser/win/jumplist_file_util.cc

Issue 2859193005: Cache JumpList icons to avoid unnecessary creation and deletion (Closed)
Patch Set: Fix nits. Created 3 years, 7 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 | « chrome/browser/win/jumplist_file_util.h ('k') | chrome/browser/win/jumplist_file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist_file_util.cc
diff --git a/chrome/browser/win/jumplist_file_util.cc b/chrome/browser/win/jumplist_file_util.cc
index 78f79a4b21a2d43afa0dce8b29824276be5cb3b8..91edc3fcbe6d17a6dfc58f3a8d8edb3444a3e595 100644
--- a/chrome/browser/win/jumplist_file_util.cc
+++ b/chrome/browser/win/jumplist_file_util.cc
@@ -89,3 +89,34 @@ void DeleteDirectoryContentAndLogRuntime(const base::FilePath& path,
DeleteDirectoryContent(path, kFileDeleteLimit);
}
+
+bool FilesExceedLimitInDir(const base::FilePath& path, int max_files) {
+ int count = 0;
+ base::FileEnumerator file_iter(path, false, base::FileEnumerator::FILES);
+ while (!file_iter.Next().empty()) {
+ if (++count > max_files)
+ return true;
+ }
+ return false;
+}
+
+void DeleteNonCachedFiles(const base::FilePath& path,
+ const base::flat_set<base::FilePath>& cached_files) {
+ base::FileEnumerator traversal(path, false, base::FileEnumerator::FILES);
+
+ for (base::FilePath current = traversal.Next(); !current.empty();
+ current = traversal.Next()) {
+ if (cached_files.find(current) != cached_files.end())
+ continue;
+
+ // Try to clear the read-only bit if we find it.
+ base::FileEnumerator::FileInfo info = traversal.GetInfo();
+ if (info.find_data().dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
+ SetFileAttributes(
+ current.value().c_str(),
+ info.find_data().dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
+ }
+
+ ::DeleteFile(current.value().c_str());
+ }
+}
« no previous file with comments | « chrome/browser/win/jumplist_file_util.h ('k') | chrome/browser/win/jumplist_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698