Index: chrome/browser/win/jumplist_file_util.h |
diff --git a/chrome/browser/win/jumplist_file_util.h b/chrome/browser/win/jumplist_file_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..143e8a4ef1ec8703146085e762bcb94a9b867c2f |
--- /dev/null |
+++ b/chrome/browser/win/jumplist_file_util.h |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_WIN_JUMPLIST_FILE_UTIL_H_ |
+#define CHROME_BROWSER_WIN_JUMPLIST_FILE_UTIL_H_ |
+ |
+#include "base/files/file_path.h" |
+ |
+// Maximum number of icon files allowed to delete per jumplist update. |
+const int kMaxFilesDeleted = 100; |
+ |
+// Folder delete status enumeration, used in Delete* methods below. |
+// This is used for UMA. Do not delete entries, and keep in sync with |
+// histograms.xml. |
+enum FolderDeleteResult { |
+ SUCCEED = 0, |
+ // File name's length exceeds MAX_PATH. This won't happen. |
Ilya Sherman
2017/03/22 22:24:00
Why are there enum entries that won't happen? Do
chengx
2017/03/23 21:16:11
Yea, I mean "shouldn't happen". I have updated it
|
+ FAIL_INVALID_FILE_PATH, |
+ // JumpListIcons{,Old} directories are read-only. This may heppen. |
+ FAIL_READ_ONLY_DIRECTORY, |
+ // Since JumpListIcons{,Old} are directories, this won't happen. |
+ FAIL_DELETE_SINGLE_FILE, |
+ // JumpListIcons{,Old} should not have sub-directories, so this won't happen. |
+ // If this happens, the root cause must be found. |
+ FAIL_SUBDIRECTORY_EXISTS, |
+ // Delete maximum files allowed succeeds. However, in the process of deleting |
+ // these files, it fails to delete some other files. This may happen. |
+ FAIL_DELETE_MAX_FILES_WITH_ERRORS, |
+ // Fail to delete maximum files allowed when the maximum attempts allowed |
+ // have been used. This may heppen. |
+ FAIL_MAX_DELETE_FAILURES, |
+ // Fail to remove the raw empty directory. This may happen. |
+ FAIL_REMOVE_RAW_DIRECTORY, |
+ // Add new items before this one, always keep this one at the end. |
+ END |
+}; |
+ |
+// This method is similar to base::DeleteFileRecursive in |
+// file_util_win.cc with the following differences. |
+// 1) It deletes only the files in |path|. All sub-directories in |path| are |
+// untouched. The information that subdirectories exist is recorded. |
+// 2) It has an input parameter |max_file_deleted| to specify the maximum files |
+// allowed to delete as well as the maximum attempt failures allowd per run. |
+// 3) Failure cause is recored in |delete_status|. |
+const FolderDeleteResult DeleteFiles(const base::FilePath& path, |
+ const base::FilePath::StringType& pattern, |
+ const int max_file_deleted); |
+ |
+// This method is similar to base::DeleteFile in file_util_win.cc |
+// with the following differences. |
+// 1) It deletes only the files in |path|. All sub-directories in |path| are |
+// untouched. The information that subdirectories exist is recorded. |
+// 2) If |path| is a directory, it won't be deleted even if all its contents are |
+// deleted successfully. |
+// 3) It has an input parameter |max_file_deleted| to specify the maximum files |
+// allowed to delete as well as the maximum attempt failures allowd per run. |
+// 4) Failure cause is recored in |delete_status|. |
+const FolderDeleteResult DeleteDirectoryContent(const base::FilePath& path, |
+ const int max_file_deleted); |
+ |
+// This method firstly calls DeleteDirectoryContent() to delete the contents in |
+// |path|. If the resulting directory is empty, then remove the raw directory. |
+const FolderDeleteResult DeleteDirectory(const base::FilePath& path, |
+ const int max_file_deleted); |
+ |
+// Deletes the directory at |path| and records the result to UMA. |
+void DeleteDirectoryAndLogResults(const base::FilePath& path, |
+ const int max_file_deleted); |
+ |
+#endif // CHROME_BROWSER_WIN_JUMPLIST_FILE_UTIL_H_ |