Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 * session and calls onForegroundSessionStart(). Subsequent calls are noops until | 257 * session and calls onForegroundSessionStart(). Subsequent calls are noops until |
| 258 * onForegroundSessionEnd() is called, to handle changing top-level Chrome a ctivities in one | 258 * onForegroundSessionEnd() is called, to handle changing top-level Chrome a ctivities in one |
| 259 * foreground session. | 259 * foreground session. |
| 260 */ | 260 */ |
| 261 public void onStartWithNative() { | 261 public void onStartWithNative() { |
| 262 if (mIsStarted) return; | 262 if (mIsStarted) return; |
| 263 mIsStarted = true; | 263 mIsStarted = true; |
| 264 | 264 |
| 265 assert mIsProcessInitialized; | 265 assert mIsProcessInitialized; |
| 266 | 266 |
| 267 UmaUtils.recordForegroundStartTime(); | |
|
Yusuf
2016/07/12 18:00:19
I would say this is a bit misleading. The previous
Peter Wen
2016/07/12 19:02:13
This is currently used only by deferred startup an
| |
| 267 onForegroundSessionStart(); | 268 onForegroundSessionStart(); |
| 268 cacheNativeFlags(); | 269 cacheNativeFlags(); |
| 269 } | 270 } |
| 270 | 271 |
| 271 /** | 272 /** |
| 272 * Called when a top-level Chrome activity (ChromeTabbedActivity, Fullscreen Activity) is | 273 * 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 | 274 * 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 | 275 * (see onStart()), that is, when correct activity calls startActivity() for another Chrome |
| 275 * activity. | 276 * activity. |
| 276 */ | 277 */ |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()) | |
|
Yusuf
2016/07/12 18:00:19
this can fit in one line?
Peter Wen
2016/07/12 19:02:13
Done.
| |
| 474 .onMainActivityStart(); | |
| 475 RevenueStats.getInstance(); | |
| 476 } | |
| 477 }); | |
| 468 | 478 |
| 469 startApplicationActivityTracker(); | 479 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() { |
| 480 @Override | |
| 481 public void run() { | |
| 482 mDevToolsServer = new DevToolsServer(DEV_TOOLS_SERVER_SOCKET_PRE FIX); | |
| 483 mDevToolsServer.setRemoteDebuggingEnabled( | |
| 484 true, DevToolsServer.Security.ALLOW_DEBUG_PERMISSION); | |
| 470 | 485 |
| 471 // Add process check to diagnose http://crbug.com/606309. Remove this af ter the bug is | 486 startApplicationActivityTracker(); |
| 472 // fixed. | 487 } |
| 473 assert !CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_PROCE SS_TYPE); | 488 }); |
| 474 if (!CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_PROCESS_ TYPE)) { | |
| 475 DownloadController.setDownloadNotificationService( | |
| 476 DownloadManagerService.getDownloadManagerService(this)); | |
| 477 } | |
| 478 | 489 |
| 479 if (ApiCompatibilityUtils.isPrintingSupported()) { | 490 DeferredStartupHandler.getInstance().addDeferredTask(new Runnable() { |
| 480 mPrintingController = PrintingControllerFactory.create(getApplicatio nContext()); | 491 @Override |
| 481 } | 492 public void run() { |
| 493 // Add process check to diagnose http://crbug.com/606309. Remove this after the bug | |
| 494 // is fixed. | |
| 495 assert !CommandLine.getInstance().hasSwitch(ContentSwitches.SWIT CH_PROCESS_TYPE); | |
| 496 if (!CommandLine.getInstance().hasSwitch(ContentSwitches.SWITCH_ PROCESS_TYPE)) { | |
| 497 DownloadController.setDownloadNotificationService( | |
| 498 DownloadManagerService.getDownloadManagerService( | |
| 499 getApplicationContext())); | |
| 500 } | |
| 501 | |
| 502 if (ApiCompatibilityUtils.isPrintingSupported()) { | |
| 503 mPrintingController = PrintingControllerFactory.create(getAp plicationContext()); | |
| 504 } | |
| 505 } | |
| 506 }); | |
| 482 } | 507 } |
| 483 | 508 |
| 484 /** | 509 /** |
| 485 * For extending classes to carry out tasks that initialize the browser proc ess. | 510 * 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 | 511 * 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. | 512 * that really, really have to be set up early. Avoid putting any long task s here. |
| 488 */ | 513 */ |
| 489 public void initializeProcess() { | 514 public void initializeProcess() { |
| 490 if (mIsProcessInitialized) return; | 515 if (mIsProcessInitialized) return; |
| 491 mIsProcessInitialized = true; | 516 mIsProcessInitialized = true; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 * Caches flags that are needed by Activities that launch before the native library is loaded | 887 * 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 | 888 * 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. | 889 * library has loaded, they won't affect the next launch until Chrome is res tarted. |
| 865 */ | 890 */ |
| 866 private void cacheNativeFlags() { | 891 private void cacheNativeFlags() { |
| 867 if (sIsFinishedCachingNativeFlags) return; | 892 if (sIsFinishedCachingNativeFlags) return; |
| 868 FeatureUtilities.cacheNativeFlags(this); | 893 FeatureUtilities.cacheNativeFlags(this); |
| 869 sIsFinishedCachingNativeFlags = true; | 894 sIsFinishedCachingNativeFlags = true; |
| 870 } | 895 } |
| 871 } | 896 } |
| OLD | NEW |