Chromium Code Reviews| 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.Intent; | 8 import android.content.Intent; |
| 9 import android.content.SharedPreferences; | 9 import android.content.SharedPreferences; |
| 10 import android.content.pm.ResolveInfo; | 10 import android.content.pm.ResolveInfo; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 // Starts syncing with GSA. | 227 // Starts syncing with GSA. |
| 228 application.createGsaHelper().startSync(); | 228 application.createGsaHelper().startSync(); |
| 229 } | 229 } |
| 230 }); | 230 }); |
| 231 | 231 |
| 232 ProcessInitializationHandler.getInstance().initializeDeferredStartupTask s(); | 232 ProcessInitializationHandler.getInstance().initializeDeferredStartupTask s(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 private void initAsyncDiskTask() { | 235 private void initAsyncDiskTask() { |
| 236 new AsyncTask<Void, Void, Void>() { | 236 new AsyncTask<Void, Void, Void>() { |
| 237 private long mAsyncTaskStartTime; | |
| 238 | |
| 237 @Override | 239 @Override |
| 238 protected Void doInBackground(Void... params) { | 240 protected Void doInBackground(Void... params) { |
| 239 try { | 241 try { |
| 240 TraceEvent.begin("ChromeBrowserInitializer.onDeferredStartup .doInBackground"); | 242 TraceEvent.begin("ChromeBrowserInitializer.onDeferredStartup .doInBackground"); |
| 241 long asyncTaskStartTime = SystemClock.uptimeMillis(); | 243 mAsyncTaskStartTime = SystemClock.uptimeMillis(); |
| 242 | |
| 243 // Initialize the WebappRegistry if it's not already initial ized. Must be in | |
| 244 // async task due to shared preferences disk access on N. | |
| 245 WebappRegistry.getInstance(); | |
| 246 | 244 |
| 247 boolean crashDumpDisabled = CommandLine.getInstance().hasSwi tch( | 245 boolean crashDumpDisabled = CommandLine.getInstance().hasSwi tch( |
| 248 ChromeSwitches.DISABLE_CRASH_DUMP_UPLOAD); | 246 ChromeSwitches.DISABLE_CRASH_DUMP_UPLOAD); |
| 249 if (!crashDumpDisabled) { | 247 if (!crashDumpDisabled) { |
| 250 RecordHistogram.recordLongTimesHistogram( | 248 RecordHistogram.recordLongTimesHistogram( |
| 251 "UMA.Debug.EnableCrashUpload.Uptime3", | 249 "UMA.Debug.EnableCrashUpload.Uptime3", |
| 252 asyncTaskStartTime - UmaUtils.getForegroundStart Time(), | 250 mAsyncTaskStartTime - UmaUtils.getForegroundStar tTime(), |
| 253 TimeUnit.MILLISECONDS); | 251 TimeUnit.MILLISECONDS); |
| 254 PrivacyPreferencesManager.getInstance().enablePotentialC rashUploading(); | 252 PrivacyPreferencesManager.getInstance().enablePotentialC rashUploading(); |
| 255 MinidumpUploadService.tryUploadAllCrashDumps(mAppContext ); | 253 MinidumpUploadService.tryUploadAllCrashDumps(mAppContext ); |
| 256 } | 254 } |
| 257 CrashFileManager crashFileManager = | 255 CrashFileManager crashFileManager = |
| 258 new CrashFileManager(mAppContext.getCacheDir()); | 256 new CrashFileManager(mAppContext.getCacheDir()); |
| 259 crashFileManager.cleanOutAllNonFreshMinidumpFiles(); | 257 crashFileManager.cleanOutAllNonFreshMinidumpFiles(); |
| 260 | 258 |
| 261 MinidumpUploadService.storeBreakpadUploadStatsInUma( | 259 MinidumpUploadService.storeBreakpadUploadStatsInUma( |
| 262 ChromePreferenceManager.getInstance(mAppContext)); | 260 ChromePreferenceManager.getInstance(mAppContext)); |
| 263 | 261 |
| 262 // Initialize the WebappRegistry if it's not already initial ized. Must be in | |
| 263 // async task due to shared preferences disk access on N. | |
| 264 WebappRegistry.getInstance(); | |
| 265 | |
| 264 // Force a widget refresh in order to wake up any possible z ombie widgets. | 266 // Force a widget refresh in order to wake up any possible z ombie widgets. |
| 265 // This is needed to ensure the right behavior when the proc ess is suddenly | 267 // This is needed to ensure the right behavior when the proc ess is suddenly |
| 266 // killed. | 268 // killed. |
| 267 BookmarkWidgetProvider.refreshAllWidgets(mAppContext); | 269 BookmarkWidgetProvider.refreshAllWidgets(mAppContext); |
| 268 | 270 |
| 269 // Initialize whether or not precaching is enabled. | 271 // Initialize whether or not precaching is enabled. |
| 270 PrecacheLauncher.updatePrecachingEnabled(mAppContext); | 272 PrecacheLauncher.updatePrecachingEnabled(mAppContext); |
| 271 | 273 |
| 272 if (ChromeWebApkHost.isEnabled()) { | 274 if (ChromeWebApkHost.isEnabled()) { |
| 273 WebApkVersionManager.updateWebApksIfNeeded(); | 275 WebApkVersionManager.updateWebApksIfNeeded(); |
| 274 } | 276 } |
| 275 | 277 |
| 276 removeSnapshotDatabase(); | 278 removeSnapshotDatabase(); |
| 277 | 279 |
| 278 cacheIsChromeDefaultBrowser(); | 280 cacheIsChromeDefaultBrowser(); |
| 279 | 281 |
| 280 RecordHistogram.recordLongTimesHistogram( | |
| 281 "UMA.Debug.EnableCrashUpload.DeferredStartUpDuration Async", | |
| 282 SystemClock.uptimeMillis() - asyncTaskStartTime, | |
| 283 TimeUnit.MILLISECONDS); | |
| 284 | |
| 285 // Warm up all web app shared prefs. This must be run after the WebappRegistry | 282 // Warm up all web app shared prefs. This must be run after the WebappRegistry |
| 286 // instance is initialized. | 283 // instance is initialized. |
| 287 WebappRegistry.warmUpSharedPrefs(); | 284 WebappRegistry.warmUpSharedPrefs(); |
| 288 | 285 |
| 289 return null; | 286 return null; |
| 290 } finally { | 287 } finally { |
| 291 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d oInBackground"); | 288 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d oInBackground"); |
| 292 } | 289 } |
| 293 } | 290 } |
| 294 | 291 |
| 295 @Override | 292 @Override |
| 296 protected void onPostExecute(Void params) { | 293 protected void onPostExecute(Void params) { |
| 297 // Must be run on the UI thread after the WebappRegistry has bee n completely warmed. | 294 // Must be run on the UI thread after the WebappRegistry has bee n completely warmed. |
| 298 WebappRegistry.getInstance().unregisterOldWebapps(System.current TimeMillis()); | 295 WebappRegistry.getInstance().unregisterOldWebapps(System.current TimeMillis()); |
| 296 | |
| 297 RecordHistogram.recordLongTimesHistogram( | |
| 298 "UMA.Debug.EnableCrashUpload.DeferredStartUpDurationAsyn c", | |
|
Maria
2017/01/23 20:46:10
I think you should rename this so that we can tell
Peter Wen
2017/01/23 21:54:41
Done.
| |
| 299 SystemClock.uptimeMillis() - mAsyncTaskStartTime, | |
| 300 TimeUnit.MILLISECONDS); | |
| 299 } | 301 } |
| 300 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); | 302 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
| 301 } | 303 } |
| 302 | 304 |
| 303 private void startModerateBindingManagementIfNeeded() { | 305 private void startModerateBindingManagementIfNeeded() { |
| 304 // Moderate binding doesn't apply to low end devices. | 306 // Moderate binding doesn't apply to low end devices. |
| 305 if (SysUtils.isLowEndDevice()) return; | 307 if (SysUtils.isLowEndDevice()) return; |
| 306 | 308 |
| 307 boolean moderateBindingTillBackgrounded = | 309 boolean moderateBindingTillBackgrounded = |
| 308 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat ion") | 310 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat ion") |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 } | 373 } |
| 372 | 374 |
| 373 /** | 375 /** |
| 374 * @return Whether deferred startup has been completed. | 376 * @return Whether deferred startup has been completed. |
| 375 */ | 377 */ |
| 376 @VisibleForTesting | 378 @VisibleForTesting |
| 377 public boolean isDeferredStartupCompleteForApp() { | 379 public boolean isDeferredStartupCompleteForApp() { |
| 378 return mDeferredStartupCompletedForApp; | 380 return mDeferredStartupCompletedForApp; |
| 379 } | 381 } |
| 380 } | 382 } |
| OLD | NEW |