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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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/win/jumplist_file_util.h" 5 #include "chrome/browser/win/jumplist_file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 ::RemoveDirectory(path.value().c_str()); 83 ::RemoveDirectory(path.value().c_str());
84 } 84 }
85 85
86 void DeleteDirectoryContentAndLogRuntime(const base::FilePath& path, 86 void DeleteDirectoryContentAndLogRuntime(const base::FilePath& path,
87 int max_file_deleted) { 87 int max_file_deleted) {
88 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.DeleteDirectoryContentDuration"); 88 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.DeleteDirectoryContentDuration");
89 89
90 DeleteDirectoryContent(path, kFileDeleteLimit); 90 DeleteDirectoryContent(path, kFileDeleteLimit);
91 } 91 }
92
93 bool FilesExceedLimitInDir(const base::FilePath& path, int max_files) {
94 int count = 0;
95 base::FileEnumerator file_iter(path, false, base::FileEnumerator::FILES);
96 while (!file_iter.Next().empty()) {
97 if (++count > max_files)
98 return true;
99 }
100 return false;
101 }
102
103 void DeleteNonCachedFiles(const base::FilePath& path,
104 const base::flat_set<base::FilePath>& cached_files) {
105 base::FileEnumerator traversal(path, false, base::FileEnumerator::FILES);
106
107 for (base::FilePath current = traversal.Next(); !current.empty();
108 current = traversal.Next()) {
109 if (cached_files.find(current) != cached_files.end())
110 continue;
111
112 // Try to clear the read-only bit if we find it.
113 base::FileEnumerator::FileInfo info = traversal.GetInfo();
114 if (info.find_data().dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
115 SetFileAttributes(
116 current.value().c_str(),
117 info.find_data().dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
118 }
119
120 ::DeleteFile(current.value().c_str());
121 }
122 }
OLDNEW
« 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