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

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

Issue 2121863002: Separate deferred startup into tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Longer timeout. Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.SharedPreferences; 10 import android.content.SharedPreferences;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 cacheNativeFlags(); 268 cacheNativeFlags();
269 } 269 }
270 270
271 /** 271 /**
272 * Called when a top-level Chrome activity (ChromeTabbedActivity, Fullscreen Activity) is 272 * Called when a top-level Chrome activity (ChromeTabbedActivity, Fullscreen Activity) is
273 * started in foreground. It will not be called again when other Chrome acti vities take over 273 * started in foreground. It will not be called again when other Chrome acti vities take over
274 * (see onStart()), that is, when correct activity calls startActivity() for another Chrome 274 * (see onStart()), that is, when correct activity calls startActivity() for another Chrome
275 * activity. 275 * activity.
276 */ 276 */
277 private void onForegroundSessionStart() { 277 private void onForegroundSessionStart() {
278 UmaUtils.recordForegroundStartTime();
278 ChildProcessLauncher.onBroughtToForeground(); 279 ChildProcessLauncher.onBroughtToForeground();
279 mBackgroundProcessing.startTimers(); 280 mBackgroundProcessing.startTimers();
280 updatePasswordEchoState(); 281 updatePasswordEchoState();
281 FontSizePrefs.getInstance(this).onSystemFontScaleChanged(); 282 FontSizePrefs.getInstance(this).onSystemFontScaleChanged();
282 updateAcceptLanguages(); 283 updateAcceptLanguages();
283 mVariationsSession.start(getApplicationContext()); 284 mVariationsSession.start(getApplicationContext());
284 mPowerBroadcastReceiver.onForegroundSessionStart(); 285 mPowerBroadcastReceiver.onForegroundSessionStart();
285 286
286 // Track the ratio of Chrome startups that are caused by notification cl icks. 287 // Track the ratio of Chrome startups that are caused by notification cl icks.
287 // TODO(johnme): Add other reasons (and switch to recordEnumeratedHistog ram). 288 // TODO(johnme): Add other reasons (and switch to recordEnumeratedHistog ram).
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 441 }
441 442
442 /** 443 /**
443 * The host activity should call this after the native library has loaded to ensure classes 444 * The host activity should call this after the native library has loaded to ensure classes
444 * shared by Activities in the same process are properly initialized. 445 * shared by Activities in the same process are properly initialized.
445 */ 446 */
446 public void initializeSharedClasses() { 447 public void initializeSharedClasses() {
447 if (mInitializedSharedClasses) return; 448 if (mInitializedSharedClasses) return;
448 mInitializedSharedClasses = true; 449 mInitializedSharedClasses = true;
449 450
450 ForcedSigninProcessor.start(this); 451 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() {
451 AccountsChangedReceiver.addObserver(new AccountsChangedReceiver.Accounts ChangedObserver() {
452 @Override 452 @Override
453 public void onAccountsChanged(Context context, Intent intent) { 453 public void run() {
454 ThreadUtils.runOnUiThread(new Runnable() { 454 ForcedSigninProcessor.start(getApplicationContext());
455 @Override 455 AccountsChangedReceiver.addObserver(
456 public void run() { 456 new AccountsChangedReceiver.AccountsChangedObserver() {
457 ForcedSigninProcessor.start(ChromeApplication.this); 457 @Override
458 } 458 public void onAccountsChanged(Context context, Inten t intent) {
459 }); 459 ThreadUtils.runOnUiThread(new Runnable() {
460 @Override
461 public void run() {
462 ForcedSigninProcessor.start(getApplicati onContext());
463 }
464 });
465 }
466 });
460 } 467 }
461 }); 468 });
462 GoogleServicesManager.get(this).onMainActivityStart();
463 RevenueStats.getInstance();
464 469
465 mDevToolsServer = new DevToolsServer(DEV_TOOLS_SERVER_SOCKET_PREFIX); 470 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() {
466 mDevToolsServer.setRemoteDebuggingEnabled( 471 @Override
467 true, DevToolsServer.Security.ALLOW_DEBUG_PERMISSION); 472 public void run() {
473 GoogleServicesManager.get(getApplicationContext()).onMainActivit yStart();
474 RevenueStats.getInstance();
475 }
476 });
468 477
469 startApplicationActivityTracker(); 478 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() {
479 @Override
480 public void run() {
481 mDevToolsServer = new DevToolsServer(DEV_TOOLS_SERVER_SOCKET_PRE FIX);
482 mDevToolsServer.setRemoteDebuggingEnabled(
483 true, DevToolsServer.Security.ALLOW_DEBUG_PERMISSION);
470 484
471 // Add process check to diagnose http://crbug.com/606309. Remove this af ter the bug is 485 startApplicationActivityTracker();
472 // fixed. 486 }
473 assert !CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_PROCE SS_TYPE); 487 });
474 if (!CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_PROCESS_ TYPE)) {
475 DownloadController.setDownloadNotificationService(
476 DownloadManagerService.getDownloadManagerService(this));
477 }
478 488
479 if (ApiCompatibilityUtils.isPrintingSupported()) { 489 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() {
480 mPrintingController = PrintingControllerFactory.create(getApplicatio nContext()); 490 @Override
481 } 491 public void run() {
492 // Add process check to diagnose http://crbug.com/606309. Remove this after the bug
493 // is fixed.
494 assert !CommandLine.getInstance().hasSwitch(ContentSwitches.SWIT CH_PROCESS_TYPE);
495 if (!CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_ PROCESS_TYPE)) {
496 DownloadController.setDownloadNotificationService(
497 DownloadManagerService.getDownloadManagerService(
498 getApplicationContext()));
499 }
500
501 if (ApiCompatibilityUtils.isPrintingSupported()) {
502 mPrintingController = PrintingControllerFactory.create(getAp plicationContext());
503 }
504 }
505 });
482 } 506 }
483 507
484 /** 508 /**
485 * For extending classes to carry out tasks that initialize the browser proc ess. 509 * For extending classes to carry out tasks that initialize the browser proc ess.
486 * Should be called almost immediately after the native library has loaded t o initialize things 510 * Should be called almost immediately after the native library has loaded t o initialize things
487 * that really, really have to be set up early. Avoid putting any long task s here. 511 * that really, really have to be set up early. Avoid putting any long task s here.
488 */ 512 */
489 public void initializeProcess() { 513 public void initializeProcess() {
490 if (mIsProcessInitialized) return; 514 if (mIsProcessInitialized) return;
491 mIsProcessInitialized = true; 515 mIsProcessInitialized = true;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 * Caches flags that are needed by Activities that launch before the native library is loaded 886 * Caches flags that are needed by Activities that launch before the native library is loaded
863 * and stores them in SharedPreferences. Because this function is called dur ing launch after the 887 * and stores them in SharedPreferences. Because this function is called dur ing launch after the
864 * library has loaded, they won't affect the next launch until Chrome is res tarted. 888 * library has loaded, they won't affect the next launch until Chrome is res tarted.
865 */ 889 */
866 private void cacheNativeFlags() { 890 private void cacheNativeFlags() {
867 if (sIsFinishedCachingNativeFlags) return; 891 if (sIsFinishedCachingNativeFlags) return;
868 FeatureUtilities.cacheNativeFlags(this); 892 FeatureUtilities.cacheNativeFlags(this);
869 sIsFinishedCachingNativeFlags = true; 893 sIsFinishedCachingNativeFlags = true;
870 } 894 }
871 } 895 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698