Index: components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java |
diff --git a/components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java b/components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java |
index ae3deaf665f5adc500b441fcc4ef17771131ec95..2b08d2ec4e86b7cf8193c6ec12dd1bfa3225b877 100644 |
--- a/components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java |
+++ b/components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java |
@@ -49,8 +49,10 @@ public class CrashFileManager { |
Pattern.compile("\\.dmp([0-9]+)$\\z"); |
private static final Pattern MINIDUMP_PATTERN = |
- Pattern.compile("\\.dmp([0-9]*)(\\.try([0-9]+))?\\z"); |
+ Pattern.compile("\\.(dmp|forced)([0-9]*)(\\.try([0-9]+))?\\z"); |
+ // TODO(isherman): Is this pattern incorrect? Typical uploaded filenames include a ".tryN" |
+ // suffix... |
private static final Pattern UPLOADED_MINIDUMP_PATTERN = Pattern.compile("\\.up([0-9]*)\\z"); |
private static final String NOT_YET_UPLOADED_MINIDUMP_SUFFIX = ".dmp"; |
@@ -137,15 +139,15 @@ public class CrashFileManager { |
*/ |
@VisibleForTesting |
public static String filenameWithIncrementedAttemptNumber(String filename) { |
- int numTried = readAttemptNumber(filename); |
+ int numTried = readAttemptNumberInternal(filename); |
if (numTried >= 0) { |
int newCount = numTried + 1; |
return filename.replace( |
UPLOAD_ATTEMPT_DELIMITER + numTried, UPLOAD_ATTEMPT_DELIMITER + newCount); |
} else { |
- // readAttemptNumber returning -1 means there is no UPLOAD_ATTEMPT_DELIMITER in the file |
- // name (or that there is a delimiter but no attempt number). So, we have to add the |
- // delimiter and attempt number ourselves. |
+ // readAttemptNumberInternal returning -1 means there is no UPLOAD_ATTEMPT_DELIMITER in |
+ // the file name (or that there is a delimiter but no attempt number). So, we have to |
+ // add the delimiter and attempt number ourselves. |
return filename + UPLOAD_ATTEMPT_DELIMITER + "1"; |
} |
} |
@@ -189,12 +191,22 @@ public class CrashFileManager { |
} |
/** |
- * Returns how many times we've tried to upload a certain Minidump file. |
- * @return the number of attempts to upload the given Minidump file, parsed from its file name, |
- * returns -1 if an attempt-number cannot be parsed from the file-name. |
+ * Returns how many times we've tried to upload a certain minidump file. |
+ * @return The number of attempts to upload the given minidump file, parsed from its filename. |
+ * Returns 0 if an attempt number cannot be parsed from the filename. |
*/ |
- @VisibleForTesting |
public static int readAttemptNumber(String filename) { |
+ int numTries = readAttemptNumberInternal(filename); |
+ return numTries >= 0 ? numTries : 0; |
+ } |
+ |
+ /** |
+ * Returns how many times we've tried to upload a certain minidump file. |
+ * @return The number of attempts to upload the given minidump file, parsed from its filename, |
+ * Returns -1 if an attempt number cannot be parsed from the filename. |
+ */ |
+ @VisibleForTesting |
+ static int readAttemptNumberInternal(String filename) { |
int tryIndex = filename.lastIndexOf(UPLOAD_ATTEMPT_DELIMITER); |
if (tryIndex >= 0) { |
tryIndex += UPLOAD_ATTEMPT_DELIMITER.length(); |