Skip to content

Commit

Permalink
[Cleanup] Run git cl format on minidump uploader files.
Browse files Browse the repository at this point in the history
BUG=694884
TEST=none
R=mariakhomenko@chromium.org

Review-Url: https://codereview.chromium.org/2735133003
Cr-Commit-Position: refs/heads/master@{#455412}
  • Loading branch information
ishermandom authored and Commit bot committed Mar 8, 2017
1 parent 5bcb8c2 commit 5b444f2
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ public boolean queueIdle() {

private void recordDeferredStartupStats() {
RecordHistogram.recordLongTimesHistogram(
"UMA.Debug.EnableCrashUpload.DeferredStartUpDuration",
mDeferredStartupDuration,
"UMA.Debug.EnableCrashUpload.DeferredStartUpDuration", mDeferredStartupDuration,
TimeUnit.MILLISECONDS);
RecordHistogram.recordLongTimesHistogram(
"UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration",
mMaxTaskDuration,
"UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration", mMaxTaskDuration,
TimeUnit.MILLISECONDS);
RecordHistogram.recordLongTimesHistogram(
"UMA.Debug.EnableCrashUpload.DeferredStartUpCompleteTime",
Expand Down Expand Up @@ -162,8 +160,7 @@ public void initDeferredStartupForApp() {
mDeferredStartupInitializedForApp = true;
ThreadUtils.assertOnUiThread();

RecordHistogram.recordLongTimesHistogram(
"UMA.Debug.EnableCrashUpload.DeferredStartUptime2",
RecordHistogram.recordLongTimesHistogram("UMA.Debug.EnableCrashUpload.DeferredStartUptime2",
SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
TimeUnit.MILLISECONDS);

Expand Down Expand Up @@ -297,8 +294,7 @@ protected void onPostExecute(Void params) {

RecordHistogram.recordLongTimesHistogram(
"UMA.Debug.EnableCrashUpload.DeferredStartUpAsyncTaskDuration",
SystemClock.uptimeMillis() - mAsyncTaskStartTime,
TimeUnit.MILLISECONDS);
SystemClock.uptimeMillis() - mAsyncTaskStartTime, TimeUnit.MILLISECONDS);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Expand All @@ -321,8 +317,7 @@ private void startModerateBindingManagementIfNeeded() {
@WorkerThread
private void removeSnapshotDatabase() {
synchronized (SNAPSHOT_DATABASE_LOCK) {
SharedPreferences prefs =
ContextUtils.getAppSharedPreferences();
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
if (!prefs.getBoolean(SNAPSHOT_DATABASE_REMOVED, false)) {
mAppContext.deleteDatabase(SNAPSHOT_DATABASE_NAME);
prefs.edit().putBoolean(SNAPSHOT_DATABASE_REMOVED, true).apply();
Expand Down Expand Up @@ -360,8 +355,8 @@ private void recordKeyboardLocaleUma() {
}

/**
* @return Whether deferred startup has been completed.
*/
* @return Whether deferred startup has been completed.
*/
@VisibleForTesting
public boolean isDeferredStartupCompleteForApp() {
return mDeferredStartupCompletedForApp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* along with the intent provided here.
*/
public class LogcatExtractionCallable implements Callable<Boolean> {

private static final String TAG = "LogcatExtraction";
private static final long HALF_SECOND = 500;

Expand All @@ -55,8 +54,7 @@ public class LogcatExtractionCallable implements Callable<Boolean> {
@VisibleForTesting
protected static final String URL_ELISION = "HTTP://WEBADDRESS.ELIDED";

private static final String GOOD_IRI_CHAR =
"a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
private static final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";

private static final Pattern IP_ADDRESS = Pattern.compile(
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
Expand All @@ -65,27 +63,25 @@ public class LogcatExtractionCallable implements Callable<Boolean> {
+ "|[1-9][0-9]|[0-9]))");

private static final String IRI =
"[" + GOOD_IRI_CHAR + "]([" + GOOD_IRI_CHAR + "\\-]{0,61}["
+ GOOD_IRI_CHAR + "]){0,1}";
"[" + GOOD_IRI_CHAR + "]([" + GOOD_IRI_CHAR + "\\-]{0,61}[" + GOOD_IRI_CHAR + "]){0,1}";

private static final String GOOD_GTLD_CHAR =
"a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
private static final String GOOD_GTLD_CHAR = "a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
private static final String GTLD = "[" + GOOD_GTLD_CHAR + "]{2,63}";
private static final String HOST_NAME = "(" + IRI + "\\.)+" + GTLD;

private static final Pattern DOMAIN_NAME =
Pattern.compile("(" + HOST_NAME + "|" + IP_ADDRESS + ")");

private static final Pattern WEB_URL = Pattern.compile(
"(?:\\b|^)((?:(http|https|Http|Https|rtsp|Rtsp):"
+ "\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ "(?:" + DOMAIN_NAME + ")"
+ "(?:\\:\\d{1,5})?)"
+ "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~"
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ "(?:\\b|$)");
private static final Pattern WEB_URL =
Pattern.compile("(?:\\b|^)((?:(http|https|Http|Https|rtsp|Rtsp):"
+ "\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ "(?:" + DOMAIN_NAME + ")"
+ "(?:\\:\\d{1,5})?)"
+ "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~"
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ "(?:\\b|$)");

@VisibleForTesting
protected static final String BEGIN_MICRODUMP = "-----BEGIN BREAKPAD MICRODUMP-----";
Expand All @@ -104,35 +100,30 @@ public class LogcatExtractionCallable implements Callable<Boolean> {
private static final String LOGCAT_EXTENSION = ".logcat";

@VisibleForTesting
protected static final String CONSOLE_ELISION =
"[ELIDED:CONSOLE(0)] ELIDED CONSOLE MESSAGE";
protected static final String CONSOLE_ELISION = "[ELIDED:CONSOLE(0)] ELIDED CONSOLE MESSAGE";

private static final Pattern MAC_ADDRESS =
Pattern.compile("([0-9a-fA-F]{2}[-:]+){5}[0-9a-fA-F]{2}");

private static final Pattern CONSOLE_MSG =
Pattern.compile("\\[\\w*:CONSOLE.*\\].*");
private static final Pattern CONSOLE_MSG = Pattern.compile("\\[\\w*:CONSOLE.*\\].*");

private static final Pattern MINIDUMP_EXTENSION = Pattern.compile("\\.dmp");

private static final String[] CHROME_NAMESPACE = new String[] {
"org.chromium.", "com.google."
};

private static final String[] SYSTEM_NAMESPACE = new String[] {
"android.accessibilityservice", "android.accounts", "android.animation",
"android.annotation", "android.app", "android.appwidget", "android.bluetooth",
"android.content", "android.database", "android.databinding", "android.drm",
"android.gesture", "android.graphics", "android.hardware",
"android.inputmethodservice", "android.location", "android.media", "android.mtp",
"android.net", "android.nfc", "android.opengl", "android.os", "android.preference",
"android.print", "android.printservice", "android.provider", "android.renderscript",
"android.sax", "android.security", "android.service", "android.speech",
"android.support", "android.system", "android.telecom", "android.telephony",
"android.test", "android.text", "android.transition", "android.util", "android.view",
"android.webkit", "android.widget", "com.android.", "dalvik.", "java.", "javax.",
"org.apache.", "org.json.", "org.w3c.dom.", "org.xml.", "org.xmlpull."
};
private static final String[] CHROME_NAMESPACE = new String[] {"org.chromium.", "com.google."};

private static final String[] SYSTEM_NAMESPACE = new String[] {"android.accessibilityservice",
"android.accounts", "android.animation", "android.annotation", "android.app",
"android.appwidget", "android.bluetooth", "android.content", "android.database",
"android.databinding", "android.drm", "android.gesture", "android.graphics",
"android.hardware", "android.inputmethodservice", "android.location", "android.media",
"android.mtp", "android.net", "android.nfc", "android.opengl", "android.os",
"android.preference", "android.print", "android.printservice", "android.provider",
"android.renderscript", "android.sax", "android.security", "android.service",
"android.speech", "android.support", "android.system", "android.telecom",
"android.telephony", "android.test", "android.text", "android.transition",
"android.util", "android.view", "android.webkit", "android.widget", "com.android.",
"dalvik.", "java.", "javax.", "org.apache.", "org.json.", "org.w3c.dom.", "org.xml.",
"org.xmlpull."};

private final Context mContext;
private final String[] mMinidumpFilenames;
Expand Down Expand Up @@ -175,8 +166,8 @@ public Boolean call() {
}
}

private void processMinidump(File logcatFile, String name,
CrashFileManager manager, boolean isLast) throws IOException {
private void processMinidump(File logcatFile, String name, CrashFileManager manager,
boolean isLast) throws IOException {
String toPath = MINIDUMP_EXTENSION.matcher(name).replaceAll(LOGCAT_EXTENSION);
File toFile = manager.createNewTempFile(toPath);

Expand All @@ -186,20 +177,19 @@ private void processMinidump(File logcatFile, String name,
Intent intent = null;
if (isLast) {
move(logcatFile, toFile);
intent = MinidumpPreparationService.createMinidumpPreparationIntent(mContext,
manager.getCrashFile(name), toFile, mRedirectIntent);
intent = MinidumpPreparationService.createMinidumpPreparationIntent(
mContext, manager.getCrashFile(name), toFile, mRedirectIntent);
} else {
copy(logcatFile, toFile);
intent = MinidumpPreparationService.createMinidumpPreparationIntent(mContext,
manager.getCrashFile(name), toFile, null);
intent = MinidumpPreparationService.createMinidumpPreparationIntent(
mContext, manager.getCrashFile(name), toFile, null);
}
mContext.startService(intent);
}

private File getElidedLogcat() throws IOException, InterruptedException {
List<String> rawLogcat = getLogcat();
List<String> elidedLogcat =
Collections.unmodifiableList(processLogcat(rawLogcat));
List<String> elidedLogcat = Collections.unmodifiableList(processLogcat(rawLogcat));
return writeLogcat(elidedLogcat);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
* The FileObserver to monitor the minidump directory.
*/
public class MinidumpDirectoryObserver extends FileObserver {

private static final String TAG = "MinidumpDirObserver";

public MinidumpDirectoryObserver() {
// The file observer detects MOVED_TO for child processes.
super(new File(PathUtils.getCacheDirectory(),
CrashFileManager.CRASH_DUMP_DIR).toString(), FileObserver.MOVED_TO);
super(new File(PathUtils.getCacheDirectory(), CrashFileManager.CRASH_DUMP_DIR).toString(),
FileObserver.MOVED_TO);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@
* This class will append a logcat file to a minidump file for upload.
*/
public class MinidumpPreparationCallable implements Callable<Boolean> {

private static final String TAG = "DumpPrepCallable";

private static final String LOGCAT_CONTENT_DISPOSITION =
"Content-Disposition: form-data; name=\"logcat\"; filename=\"logcat\"";

private static final String LOGCAT_CONTENT_TYPE =
"Content-Type: text/plain";
private static final String LOGCAT_CONTENT_TYPE = "Content-Type: text/plain";

private final File mLogcatFile;
private final File mMinidumpFile;
Expand All @@ -47,10 +45,7 @@ public class MinidumpPreparationCallable implements Callable<Boolean> {
private final CrashFileManager mFileManager;

public MinidumpPreparationCallable(
Context context,
File miniDumpFile,
File logcatFile,
Intent redirectIntent) {
Context context, File miniDumpFile, File logcatFile, Intent redirectIntent) {
mContext = context;
mLogcatFile = logcatFile;
mMinidumpFile = miniDumpFile;
Expand Down Expand Up @@ -115,8 +110,8 @@ private static void writeLogcat(File targetFile, List<String> logcat, String bou
* @param targetFile File to which data should be appended.
* @throws IOException when standard IO errors occur.
*/
private static void appendMinidump(
File processMinidumpFile, File targetFile) throws IOException {
private static void appendMinidump(File processMinidumpFile, File targetFile)
throws IOException {
BufferedInputStream bIn = null;
BufferedOutputStream bOut = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public class MinidumpPreparationService extends IntentService {
private static final String REDIRECT_INTENT_KEY = "redirect_intent";

public static Intent createMinidumpPreparationIntent(
Context context,
File minidumpFile,
File logcatFile,
Intent redirectIntent) {
Context context, File minidumpFile, File logcatFile, Intent redirectIntent) {
Intent intent = new Intent(context, MinidumpPreparationService.class);
if (minidumpFile != null) {
intent.putExtra(MINIDUMP_FILE_KEY, minidumpFile.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ private void tryPopulateLogcat(Intent redirectAction) {
onHandleIntent(redirectAction);
return;
}
context.startService(LogcatExtractionService.createLogcatExtractionTask(
context, dumps, redirectAction));
context.startService(
LogcatExtractionService.createLogcatExtractionTask(context, dumps, redirectAction));
}

@Override
Expand Down Expand Up @@ -138,15 +138,11 @@ public static void storeBreakpadUploadStatsInUma(ChromePreferenceManager pref) {
for (String type : TYPES) {
for (int success = pref.getCrashSuccessUploadCount(type); success > 0; success--) {
RecordHistogram.recordEnumeratedHistogram(
HISTOGRAM_NAME_PREFIX + type,
SUCCESS,
HISTOGRAM_MAX);
HISTOGRAM_NAME_PREFIX + type, SUCCESS, HISTOGRAM_MAX);
}
for (int fail = pref.getCrashFailureUploadCount(type); fail > 0; fail--) {
RecordHistogram.recordEnumeratedHistogram(
HISTOGRAM_NAME_PREFIX + type,
FAILURE,
HISTOGRAM_MAX);
HISTOGRAM_NAME_PREFIX + type, FAILURE, HISTOGRAM_MAX);
}

pref.setCrashSuccessUploadCount(type, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public ComponentName startService(Intent intentToCheck) {
}
};

LogcatExtractionCallable callable = new LogcatExtractionCallable(
testContext, dumps, testIntent) {
@Override
protected List<String> getLogcat() throws IOException, InterruptedException {
List<String> result = new ArrayList<String>();
result.add(logContent);
return result;
}
};
LogcatExtractionCallable callable =
new LogcatExtractionCallable(testContext, dumps, testIntent) {
@Override
protected List<String> getLogcat() throws IOException, InterruptedException {
List<String> result = new ArrayList<String>();
result.add(logContent);
return result;
}
};

callable.call();

Expand Down
Loading

0 comments on commit 5b444f2

Please sign in to comment.