OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
10 import android.os.Looper; | 10 import android.os.Looper; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // Likewise, there might be pending metrics from previous runs w
hen crash reporting | 318 // Likewise, there might be pending metrics from previous runs w
hen crash reporting |
319 // was enabled. | 319 // was enabled. |
320 MinidumpUploadService.storeBreakpadUploadStatsInUma( | 320 MinidumpUploadService.storeBreakpadUploadStatsInUma( |
321 ChromePreferenceManager.getInstance()); | 321 ChromePreferenceManager.getInstance()); |
322 | 322 |
323 // Now check whether crash reporting is enabled. If it is, broad
cast the appropriate | 323 // Now check whether crash reporting is enabled. If it is, broad
cast the appropriate |
324 // permission. | 324 // permission. |
325 boolean crashReportingDisabled = CommandLine.getInstance().hasSw
itch( | 325 boolean crashReportingDisabled = CommandLine.getInstance().hasSw
itch( |
326 ChromeSwitches.DISABLE_CRASH_DUMP_UPLOAD); | 326 ChromeSwitches.DISABLE_CRASH_DUMP_UPLOAD); |
327 if (crashReportingDisabled) return; | 327 if (crashReportingDisabled) return; |
| 328 PrivacyPreferencesManager.getInstance().enablePotentialCrashUplo
ading(); |
328 | 329 |
329 RecordHistogram.recordLongTimesHistogram("UMA.Debug.EnableCrashU
pload.Uptime3", | 330 RecordHistogram.recordLongTimesHistogram("UMA.Debug.EnableCrashU
pload.Uptime3", |
330 mAsyncTaskStartTime - UmaUtils.getForegroundStartTime(), | 331 mAsyncTaskStartTime - UmaUtils.getForegroundStartTime(), |
331 TimeUnit.MILLISECONDS); | 332 TimeUnit.MILLISECONDS); |
332 PrivacyPreferencesManager.getInstance().enablePotentialCrashUplo
ading(); | |
333 | 333 |
334 // Finally, uploading any pending crash reports. | 334 // Finally, uploading any pending crash reports. |
335 File[] minidumps = crashFileManager.getAllMinidumpFiles( | 335 File[] minidumps = crashFileManager.getAllMinidumpFiles( |
336 MinidumpUploadService.MAX_TRIES_ALLOWED); | 336 MinidumpUploadService.MAX_TRIES_ALLOWED); |
337 int numMinidumpsSansLogcat = 0; | 337 int numMinidumpsSansLogcat = 0; |
338 for (File minidump : minidumps) { | 338 for (File minidump : minidumps) { |
339 if (CrashFileManager.isMinidumpMIMEFirstTry(minidump.getName
())) { | 339 if (CrashFileManager.isMinidumpMIMEFirstTry(minidump.getName
())) { |
340 ++numMinidumpsSansLogcat; | 340 ++numMinidumpsSansLogcat; |
341 } | 341 } |
342 } | 342 } |
343 // TODO(isherman): These two histograms are intended to be tempo
rary, and can | 343 // TODO(isherman): These two histograms are intended to be tempo
rary, and can |
344 // probably be removed around the M60 timeframe: http://crbug.co
m/699785 | 344 // probably be removed around the M60 timeframe: http://crbug.co
m/699785 |
345 RecordHistogram.recordSparseSlowlyHistogram( | 345 RecordHistogram.recordSparseSlowlyHistogram( |
346 "Stability.Android.PendingMinidumpsOnStartup", minidumps
.length); | 346 "Stability.Android.PendingMinidumpsOnStartup", minidumps
.length); |
347 RecordHistogram.recordSparseSlowlyHistogram( | 347 RecordHistogram.recordSparseSlowlyHistogram( |
348 "Stability.Android.PendingMinidumpsOnStartup.SansLogcat"
, | 348 "Stability.Android.PendingMinidumpsOnStartup.SansLogcat"
, |
349 numMinidumpsSansLogcat); | 349 numMinidumpsSansLogcat); |
350 if (minidumps.length == 0) return; | 350 if (minidumps.length == 0) return; |
351 | 351 |
352 Log.i(TAG, "Attempting to upload %d accumulated crash dumps.", m
inidumps.length); | 352 Log.i(TAG, "Attempting to upload %d accumulated crash dumps.", m
inidumps.length); |
353 File mostRecentMinidump = minidumps[0]; | 353 File mostRecentMinidump = minidumps[0]; |
354 if (doesCrashMinidumpNeedLogcat(mostRecentMinidump)) { | 354 if (doesCrashMinidumpNeedLogcat(mostRecentMinidump)) { |
355 AsyncTask.THREAD_POOL_EXECUTOR.execute( | 355 AsyncTask.THREAD_POOL_EXECUTOR.execute( |
356 new LogcatExtractionRunnable(mAppContext, mostRecent
Minidump)); | 356 new LogcatExtractionRunnable(mAppContext, mostRecent
Minidump)); |
| 357 |
| 358 // The JobScheduler will schedule uploads for all of the ava
ilable minidumps |
| 359 // once the logcat is attached. But if the JobScheduler API
is not being used, |
| 360 // then the logcat extraction process will only initiate an
upload for the first |
| 361 // minidump; it's required to manually initiate uploads for
all of the remaining |
| 362 // minidumps. |
| 363 if (!MinidumpUploadService.shouldUseJobSchedulerForUploads()
) { |
| 364 List<File> remainingMinidumps = |
| 365 Arrays.asList(minidumps).subList(1, minidumps.le
ngth); |
| 366 for (File minidump : remainingMinidumps) { |
| 367 MinidumpUploadService.tryUploadCrashDump(mAppContext
, minidump); |
| 368 } |
| 369 } |
| 370 } else if (MinidumpUploadService.shouldUseJobSchedulerForUploads
()) { |
| 371 MinidumpUploadService.scheduleUploadJob(mAppContext); |
357 } else { | 372 } else { |
358 MinidumpUploadService.tryUploadCrashDump(mAppContext, mostRe
centMinidump); | 373 MinidumpUploadService.tryUploadAllCrashDumps(mAppContext); |
359 } | |
360 // TODO(isherman): Once there is support implemented for the Job
Scheduler API, | |
361 // we should only explicitly upload the remaining files here if
not using that | |
362 // API. If we *are* using the JobScheduler API, then the JobSche
duler will | |
363 // schedule uploads for all of the available minidumps once the
logcat is | |
364 // attached. | |
365 List<File> remainingMinidumps = | |
366 Arrays.asList(minidumps).subList(1, minidumps.length); | |
367 for (File minidump : remainingMinidumps) { | |
368 MinidumpUploadService.tryUploadCrashDump(mAppContext, minidu
mp); | |
369 } | 374 } |
370 } | 375 } |
371 | 376 |
372 /** | 377 /** |
373 * Returns whether or not it's appropriate to try to extract recent
logcat output and | 378 * Returns whether or not it's appropriate to try to extract recent
logcat output and |
374 * include that logcat output alongside the given {@param minidump}
in a crash report. | 379 * include that logcat output alongside the given {@param minidump}
in a crash report. |
375 * Logcat output should only be extracted if (a) it hasn't already b
een extracted for | 380 * Logcat output should only be extracted if (a) it hasn't already b
een extracted for |
376 * this minidump file, and (b) the minidump is fairly fresh. The fre
shness check is | 381 * this minidump file, and (b) the minidump is fairly fresh. The fre
shness check is |
377 * important for two reasons: (1) First of all, it helps avoid inclu
ding irrelevant | 382 * important for two reasons: (1) First of all, it helps avoid inclu
ding irrelevant |
378 * logcat output for a crash report. (2) Secondly, it provides an es
cape hatch that can | 383 * logcat output for a crash report. (2) Secondly, it provides an es
cape hatch that can |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 455 } |
451 | 456 |
452 /** | 457 /** |
453 * @return Whether deferred startup has been completed. | 458 * @return Whether deferred startup has been completed. |
454 */ | 459 */ |
455 @VisibleForTesting | 460 @VisibleForTesting |
456 public boolean isDeferredStartupCompleteForApp() { | 461 public boolean isDeferredStartupCompleteForApp() { |
457 return mDeferredStartupCompletedForApp; | 462 return mDeferredStartupCompletedForApp; |
458 } | 463 } |
459 } | 464 } |
OLD | NEW |