OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.components.minidump_uploader; | 5 package org.chromium.components.minidump_uploader; |
6 | 6 |
7 import android.support.annotation.Nullable; | 7 import android.support.annotation.Nullable; |
8 | 8 |
9 import org.chromium.base.Log; | 9 import org.chromium.base.Log; |
10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
(...skipping 11 matching lines...) Expand all Loading... |
22 import java.util.HashSet; | 22 import java.util.HashSet; |
23 import java.util.List; | 23 import java.util.List; |
24 import java.util.NoSuchElementException; | 24 import java.util.NoSuchElementException; |
25 import java.util.Scanner; | 25 import java.util.Scanner; |
26 import java.util.Set; | 26 import java.util.Set; |
27 import java.util.UUID; | 27 import java.util.UUID; |
28 import java.util.concurrent.TimeUnit; | 28 import java.util.concurrent.TimeUnit; |
29 import java.util.regex.Pattern; | 29 import java.util.regex.Pattern; |
30 | 30 |
31 /** | 31 /** |
32 * Responsible for the Crash Report directory. It routinely scans the directory | 32 * The CrashFileManager is responsible for managing the "Crash Reports" director
y containing |
33 * for new Minidump files and takes appropriate actions by either uploading new | 33 * minidump files and shepherding them through a state machine represented by th
e file names. Note |
34 * crash dumps or deleting old ones. | 34 * that some of the steps are optional: |
| 35 * 1. foo.dmp is a minidump file, written to the directory by Breakpad. |
| 36 * (2) foo.dmpNNNNN is a minidump file, where NNNNN is the PID (process id) of t
he crashing |
| 37 * process. This step is optional -- that is, a minidump could fail to have
its PID included in |
| 38 * the filename. |
| 39 * (3) foo.dmpNNNNN.try0 is a minidump file with recent logcat output attached t
o it. This step is |
| 40 * optional -- that is, logcat output might fail to be extracted for the min
idump. Notably, |
| 41 * Webview-generated minidumps do not include logcat output. |
| 42 * 4. foo.dmpNNNNN.tryM for M > 0 is a minidump file that's been attempted to b
e uploaded to the |
| 43 * crash server, but for which M upload attempts have failed. |
| 44 * 5. foo.up, foo.upNNNNN, or foo.upNNNNN.tryM are all valid possible names for
a successfully |
| 45 * uploaded file. |
| 46 * 6. foo.skipped, foo.skippedNNNNN, or foo.skippedNNNNN.tryM are all valid pos
sible names for a |
| 47 * file whose upload was skipped. An upload may be skipped, for example, if
the user has not |
| 48 * consented to uploading crash reports. These files are marked as skipped r
ather than deleted |
| 49 * immediately to allow the user to manually initiate an upload. |
| 50 * 7. foo.forced, foo.forcedNNNNN, or foo.forcedNNNNN.tryM are all valid possib
le names for a file |
| 51 * that the user has manually requested to upload. |
| 52 * 8. foo.tmp is a temporary file. |
35 */ | 53 */ |
36 public class CrashFileManager { | 54 public class CrashFileManager { |
37 private static final String TAG = "CrashFileManager"; | 55 private static final String TAG = "CrashFileManager"; |
38 | 56 |
39 /** | 57 /** |
40 * The name of the crash directory. | 58 * The name of the crash directory. |
41 */ | 59 */ |
42 public static final String CRASH_DUMP_DIR = "Crash Reports"; | 60 public static final String CRASH_DUMP_DIR = "Crash Reports"; |
43 | 61 |
44 // This should mirror the C++ CrashUploadList::kReporterLogFilename variable
. | 62 // This should mirror the C++ CrashUploadList::kReporterLogFilename variable
. |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 /** | 600 /** |
583 * Create a temporary file to store a minidump in before renaming it with a
real minidump name. | 601 * Create a temporary file to store a minidump in before renaming it with a
real minidump name. |
584 * @return a new temporary file with prefix {@param prefix} stored in the di
rectory | 602 * @return a new temporary file with prefix {@param prefix} stored in the di
rectory |
585 * {@param directory}. | 603 * {@param directory}. |
586 * | 604 * |
587 */ | 605 */ |
588 private static File createMinidumpTmpFile(File directory) throws IOException
{ | 606 private static File createMinidumpTmpFile(File directory) throws IOException
{ |
589 return File.createTempFile("webview_minidump", TMP_SUFFIX, directory); | 607 return File.createTempFile("webview_minidump", TMP_SUFFIX, directory); |
590 } | 608 } |
591 } | 609 } |
OLD | NEW |