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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java

Issue 2281373002: [Android] Do not immediately delete skipped crash dump uploads. (Closed)
Patch Set: Created 4 years, 4 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadCallable.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java b/chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java
index a1e5ac05161471449e7d326e31e628bc28a2e7a2..beb9c71c40ef026e6e09f5daadc257fbe97e1ac3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/crash/CrashFileManager.java
@@ -43,6 +43,8 @@ public class CrashFileManager {
private static final String UPLOADED_MINIDUMP_SUFFIX = ".up";
+ private static final String UPLOAD_SKIPPED_MINIDUMP_SUFFIX = ".skipped";
+
private static final String UPLOAD_ATTEMPT_DELIMITER = ".try";
@VisibleForTesting
@@ -126,10 +128,42 @@ public class CrashFileManager {
return 0;
}
- public static boolean tryMarkAsUploaded(File mFileToUpload) {
- return mFileToUpload.renameTo(
- new File(mFileToUpload.getPath().replaceAll(
- "\\.dmp", UPLOADED_MINIDUMP_SUFFIX)));
+ /**
+ * Marks a crash dump file as successfully uploaded, by renaming the file.
+ *
+ * Does not immediately delete the file, for testing reasons. However, if renaming fails,
+ * attempts to delete the file immediately.
+ */
+ public static void markUploadSuccess(File crashDumpFile) {
+ CrashFileManager.renameCrashDumpFollowingUpload(crashDumpFile, UPLOADED_MINIDUMP_SUFFIX);
+ }
+
+ /**
+ * Marks a crash dump file's upload being skipped. An upload might be skipped due to lack of
+ * user consent, or due to this client being excluded from the sample of clients reporting
+ * crashes.
+ *
+ * Renames the file rather than deleting it, so that the user can manually upload the file later
+ * (via chrome://crashes). However, if renaming fails, attempts to delete the file immediately.
+ */
+ public static void markUploadSkipped(File crashDumpFile) {
+ CrashFileManager.renameCrashDumpFollowingUpload(
+ crashDumpFile, UPLOAD_SKIPPED_MINIDUMP_SUFFIX);
+ }
+
+ /**
+ * Renames a crash dump file. However, if renaming fails, attempts to delete the file
+ * immediately.
+ */
+ private static void renameCrashDumpFollowingUpload(File crashDumpFile, String suffix) {
+ boolean renamed = crashDumpFile.renameTo(
+ new File(crashDumpFile.getPath().replaceAll("\\.dmp", suffix)));
+ if (!renamed) {
+ Log.w(TAG, "Failed to rename " + crashDumpFile);
+ if (!crashDumpFile.delete()) {
+ Log.w(TAG, "Failed to delete " + crashDumpFile);
+ }
+ }
}
private final File mCacheDir;
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadCallable.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698