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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/DeferredStartupHandler.java

Issue 2784353002: Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Fix tests Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 // Crash reports can be uploaded as part of a background service even while the main 328 // Crash reports can be uploaded as part of a background service even while the main
329 // Chrome activity is not running, and hence regular metrics rep orting is not 329 // Chrome activity is not running, and hence regular metrics rep orting is not
330 // possible. Instead, metrics are temporarily written to prefs; export those prefs 330 // possible. Instead, metrics are temporarily written to prefs; export those prefs
331 // to UMA metrics here. 331 // to UMA metrics here.
332 MinidumpUploadService.storeBreakpadUploadStatsInUma( 332 MinidumpUploadService.storeBreakpadUploadStatsInUma(
333 ChromePreferenceManager.getInstance()); 333 ChromePreferenceManager.getInstance());
334 334
335 // Likewise, this is a good time to process and clean up any pen ding or stale crash 335 // Likewise, this is a good time to process and clean up any pen ding or stale crash
336 // reports left behind by previous runs. 336 // reports left behind by previous runs.
337 CrashFileManager crashFileManager = new CrashFileManager(mAppCon text.getCacheDir()); 337 CrashFileManager crashFileManager =
338 new CrashFileManager(ContextUtils.getApplicationContext( ).getCacheDir());
338 crashFileManager.cleanOutAllNonFreshMinidumpFiles(); 339 crashFileManager.cleanOutAllNonFreshMinidumpFiles();
339 340
340 // Finally, uploading any pending crash reports. 341 // Finally, uploading any pending crash reports.
341 File[] minidumps = crashFileManager.getAllMinidumpFiles( 342 File[] minidumps = crashFileManager.getAllMinidumpFiles(
342 MinidumpUploadService.MAX_TRIES_ALLOWED); 343 MinidumpUploadService.MAX_TRIES_ALLOWED);
343 int numMinidumpsSansLogcat = 0; 344 int numMinidumpsSansLogcat = 0;
344 for (File minidump : minidumps) { 345 for (File minidump : minidumps) {
345 if (CrashFileManager.isMinidumpMIMEFirstTry(minidump.getName ())) { 346 if (CrashFileManager.isMinidumpMIMEFirstTry(minidump.getName ())) {
346 ++numMinidumpsSansLogcat; 347 ++numMinidumpsSansLogcat;
347 } 348 }
348 } 349 }
349 // TODO(isherman): These two histograms are intended to be tempo rary, and can 350 // TODO(isherman): These two histograms are intended to be tempo rary, and can
350 // probably be removed around the M60 timeframe: http://crbug.co m/699785 351 // probably be removed around the M60 timeframe: http://crbug.co m/699785
351 RecordHistogram.recordSparseSlowlyHistogram( 352 RecordHistogram.recordSparseSlowlyHistogram(
352 "Stability.Android.PendingMinidumpsOnStartup", minidumps .length); 353 "Stability.Android.PendingMinidumpsOnStartup", minidumps .length);
353 RecordHistogram.recordSparseSlowlyHistogram( 354 RecordHistogram.recordSparseSlowlyHistogram(
354 "Stability.Android.PendingMinidumpsOnStartup.SansLogcat" , 355 "Stability.Android.PendingMinidumpsOnStartup.SansLogcat" ,
355 numMinidumpsSansLogcat); 356 numMinidumpsSansLogcat);
356 if (minidumps.length == 0) return; 357 if (minidumps.length == 0) return;
357 358
358 Log.i(TAG, "Attempting to upload %d accumulated crash dumps.", m inidumps.length); 359 Log.i(TAG, "Attempting to upload %d accumulated crash dumps.", m inidumps.length);
359 File mostRecentMinidump = minidumps[0]; 360 File mostRecentMinidump = minidumps[0];
360 if (doesCrashMinidumpNeedLogcat(mostRecentMinidump)) { 361 if (doesCrashMinidumpNeedLogcat(mostRecentMinidump)) {
361 AsyncTask.THREAD_POOL_EXECUTOR.execute( 362 AsyncTask.THREAD_POOL_EXECUTOR.execute(
362 new LogcatExtractionRunnable(mAppContext, mostRecent Minidump)); 363 new LogcatExtractionRunnable(mostRecentMinidump));
363 364
364 // The JobScheduler will schedule uploads for all of the ava ilable minidumps 365 // The JobScheduler will schedule uploads for all of the ava ilable minidumps
365 // once the logcat is attached. But if the JobScheduler API is not being used, 366 // once the logcat is attached. But if the JobScheduler API is not being used,
366 // then the logcat extraction process will only initiate an upload for the first 367 // then the logcat extraction process will only initiate an upload for the first
367 // minidump; it's required to manually initiate uploads for all of the remaining 368 // minidump; it's required to manually initiate uploads for all of the remaining
368 // minidumps. 369 // minidumps.
369 if (!MinidumpUploadService.shouldUseJobSchedulerForUploads() ) { 370 if (!MinidumpUploadService.shouldUseJobSchedulerForUploads() ) {
370 List<File> remainingMinidumps = 371 List<File> remainingMinidumps =
371 Arrays.asList(minidumps).subList(1, minidumps.le ngth); 372 Arrays.asList(minidumps).subList(1, minidumps.le ngth);
372 for (File minidump : remainingMinidumps) { 373 for (File minidump : remainingMinidumps) {
373 MinidumpUploadService.tryUploadCrashDump(mAppContext , minidump); 374 MinidumpUploadService.tryUploadCrashDump(minidump);
374 } 375 }
375 } 376 }
376 } else if (MinidumpUploadService.shouldUseJobSchedulerForUploads ()) { 377 } else if (MinidumpUploadService.shouldUseJobSchedulerForUploads ()) {
377 MinidumpUploadService.scheduleUploadJob(mAppContext); 378 MinidumpUploadService.scheduleUploadJob();
378 } else { 379 } else {
379 MinidumpUploadService.tryUploadAllCrashDumps(mAppContext); 380 MinidumpUploadService.tryUploadAllCrashDumps();
380 } 381 }
381 } 382 }
382 383
383 /** 384 /**
384 * Returns whether or not it's appropriate to try to extract recent logcat output and 385 * Returns whether or not it's appropriate to try to extract recent logcat output and
385 * include that logcat output alongside the given {@param minidump} in a crash report. 386 * include that logcat output alongside the given {@param minidump} in a crash report.
386 * Logcat output should only be extracted if (a) it hasn't already b een extracted for 387 * Logcat output should only be extracted if (a) it hasn't already b een extracted for
387 * this minidump file, and (b) the minidump is fairly fresh. The fre shness check is 388 * this minidump file, and (b) the minidump is fairly fresh. The fre shness check is
388 * important for two reasons: (1) First of all, it helps avoid inclu ding irrelevant 389 * important for two reasons: (1) First of all, it helps avoid inclu ding irrelevant
389 * logcat output for a crash report. (2) Secondly, it provides an es cape hatch that can 390 * logcat output for a crash report. (2) Secondly, it provides an es cape hatch that can
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 457 }
457 458
458 /** 459 /**
459 * @return Whether deferred startup has been completed. 460 * @return Whether deferred startup has been completed.
460 */ 461 */
461 @VisibleForTesting 462 @VisibleForTesting
462 public boolean isDeferredStartupCompleteForApp() { 463 public boolean isDeferredStartupCompleteForApp() {
463 return mDeferredStartupCompletedForApp; 464 return mDeferredStartupCompletedForApp;
464 } 465 }
465 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698