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

Side by Side Diff: chrome/browser/win/jumplist_file_util.cc

Issue 2778513002: Delete JumpListIconsOld and update revised links in every update (Closed)
Patch Set: Fix nits in histograms.xml Created 3 years, 9 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 <Shlwapi.h>
8 #include <windows.h> 7 #include <windows.h>
9 8
10 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
11 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
12 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
13 12
14 FolderDeleteResult DeleteFiles(const base::FilePath& path, 13 FolderDeleteResult DeleteFiles(const base::FilePath& path,
15 const base::FilePath::StringType& pattern, 14 const base::FilePath::StringType& pattern,
16 int max_file_deleted) { 15 int max_file_deleted) {
17 int success_count = 0; 16 int success_count = 0;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 FolderDeleteResult DeleteDirectory(const base::FilePath& path, 92 FolderDeleteResult DeleteDirectory(const base::FilePath& path,
94 int max_file_deleted) { 93 int max_file_deleted) {
95 base::ThreadRestrictions::AssertIOAllowed(); 94 base::ThreadRestrictions::AssertIOAllowed();
96 // Delete at most |max_file_deleted| files in |path|. 95 // Delete at most |max_file_deleted| files in |path|.
97 FolderDeleteResult delete_status = 96 FolderDeleteResult delete_status =
98 DeleteDirectoryContent(path, max_file_deleted); 97 DeleteDirectoryContent(path, max_file_deleted);
99 // Since DeleteDirectoryContent() can only delete at most |max_file_deleted| 98 // Since DeleteDirectoryContent() can only delete at most |max_file_deleted|
100 // files, its return value cannot indicate if |path| is empty or not. 99 // files, its return value cannot indicate if |path| is empty or not.
101 // Instead, use PathIsDirectoryEmpty to check if |path| is empty and remove it 100 // Instead, use PathIsDirectoryEmpty to check if |path| is empty and remove it
102 // if it is. 101 // if it is.
103 if (::PathIsDirectoryEmpty(path.value().c_str()) && 102 if (base::IsDirectoryEmpty(path) &&
104 !::RemoveDirectory(path.value().c_str())) { 103 !::RemoveDirectory(path.value().c_str())) {
105 delete_status = FAIL_REMOVE_RAW_DIRECTORY; 104 delete_status = FAIL_REMOVE_RAW_DIRECTORY;
106 } 105 }
107 return delete_status; 106 return delete_status;
108 } 107 }
109 108
110 void DeleteDirectoryAndLogResults(const base::FilePath& path, 109 void DeleteDirectoryAndLogResults(const base::FilePath& path,
111 int max_file_deleted) { 110 int max_file_deleted) {
112 FolderDeleteResult delete_status = DeleteDirectory(path, max_file_deleted); 111 FolderDeleteResult delete_status = DeleteDirectory(path, max_file_deleted);
113 UMA_HISTOGRAM_ENUMERATION("WinJumplist.DeleteStatusJumpListIconsOld", 112 UMA_HISTOGRAM_ENUMERATION("WinJumplist.DeleteStatusJumpListIconsOld",
114 delete_status, END); 113 delete_status, END);
114
115 DirectoryStatus dir_status = NON_EXIST;
116 if (base::DirectoryExists(path)) {
grt (UTC plus 2) 2017/03/27 08:03:39 nit: omit braces
chengx 2017/03/27 18:32:41 Done.
117 dir_status = base::IsDirectoryEmpty(path) ? EMPTY : NON_EMPTY;
118 }
119 UMA_HISTOGRAM_ENUMERATION("WinJumplist.DirectoryStatusJumpListIconsOld",
120 dir_status, DIRECTORY_STATUS_END);
115 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698