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

Unified Diff: components/minidump_uploader/android/java/src/org/chromium/components/minidump_uploader/CrashFileManager.java

Issue 2737263006: [Android Crash Reporting] Allow uploading minidumps via the JobScheduler (Closed)
Patch Set: Use shared prefs 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 side-by-side diff with in-line comments
Download patch
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 d905db4adb9eddbe08e8f885d1ef5d21a4ba2d3a..579e1d2e1f663bc6545ce9dc4dd8e7d9482d1412 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...
Ilya Sherman 2017/03/14 02:22:03 By the way, Gustav, I noticed that uploaded files
gsennton 2017/03/14 18:17:28 Huh, that would indeed be important to fix for 58
Ilya Sherman 2017/03/15 02:13:35 One better: I sent you a CL =) https://codereview.
gsennton 2017/03/15 12:57:43 Awesome, thanks a lot! :) (you can remove this com
Ilya Sherman 2017/03/16 01:36:57 Done.
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";
}
}
@@ -195,6 +197,17 @@ public class CrashFileManager {
*/
@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 file name,
+ * returns -1 if an attempt-number cannot be parsed from the file-name.
+ */
+ @VisibleForTesting
+ public static int readAttemptNumberInternal(String filename) {
Maria 2017/03/14 19:03:32 can this be package-visible instead?
Ilya Sherman 2017/03/15 02:13:35 Done.
int tryIndex = filename.lastIndexOf(UPLOAD_ATTEMPT_DELIMITER);
if (tryIndex >= 0) {
tryIndex += UPLOAD_ATTEMPT_DELIMITER.length();

Powered by Google App Engine
This is Rietveld 408576698