Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
| index fb7304208aed6c5c8f4111530b8e4c5d3a30651d..c2f865d27cac81523a76b89603df8e5b8d65747b 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
| @@ -33,6 +33,7 @@ import org.chromium.base.Log; |
| import org.chromium.base.SysUtils; |
| import org.chromium.base.ThreadUtils; |
| import org.chromium.base.TimeUtils; |
| +import org.chromium.base.TraceEvent; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.annotations.SuppressFBWarnings; |
| import org.chromium.base.library_loader.ProcessInitException; |
| @@ -246,19 +247,26 @@ public class CustomTabsConnection { |
| ThreadUtils.postOnUiThread(new Runnable() { |
| @Override |
| public void run() { |
|
pasko
2016/11/21 17:33:02
this easier to read at least to me:
try {
Trace
|
| - if (!initialized) initializeBrowser(mApplication); |
| - if (mayCreateSpareWebContents && mSpeculation == null |
| - && !SysUtils.isLowEndDevice()) { |
| - WarmupManager.getInstance().createSpareWebContents(); |
| - // The throttling database uses shared preferences, that can cause a StrictMode |
| - // violation on the first access. Make sure that this access is not in |
| - // mayLauchUrl. |
| - RequestThrottler.getForUid(mApplication, uid); |
| - |
| - Profile profile = Profile.getLastUsedProfile(); |
| - new ResourcePrefetchPredictor(profile).startInitialization(); |
| + TraceEvent.begin("CustomTabsConnection.warmupInternal()"); |
| + try { |
| + if (!initialized) initializeBrowser(mApplication); |
| + if (mayCreateSpareWebContents && mSpeculation == null |
| + && !SysUtils.isLowEndDevice()) { |
| + WarmupManager.getInstance().createSpareWebContents(); |
| + } |
| + if (!initialized) { |
| + // The throttling database uses shared preferences, that can cause a |
| + // StrictMode violation on the first access. Make sure that this access is |
| + // not in mayLauchUrl. |
| + RequestThrottler.getForUid(mApplication, uid); |
| + |
| + Profile profile = Profile.getLastUsedProfile(); |
| + new ResourcePrefetchPredictor(profile).startInitialization(); |
| + } |
| + mWarmupHasBeenFinished.set(true); |
| + } finally { |
| + TraceEvent.end("CustomTabsConnection.warmupInternal()"); |
| } |
| - mWarmupHasBeenFinished.set(true); |
| } |
| }); |
| return true; |
| @@ -347,9 +355,14 @@ public class CustomTabsConnection { |
| public boolean mayLaunchUrl(CustomTabsSessionToken session, Uri url, Bundle extras, |
| List<Bundle> otherLikelyBundles) { |
| - boolean success = mayLaunchUrlInternal(session, url, extras, otherLikelyBundles); |
| - logCall("mayLaunchUrl()", success); |
| - return success; |
| + TraceEvent.begin("CustomTabsConnection.mayLaunchUrl()"); |
| + try { |
| + boolean success = mayLaunchUrlInternal(session, url, extras, otherLikelyBundles); |
| + logCall("mayLaunchUrl()", success); |
| + return success; |
| + } finally { |
| + TraceEvent.end("CustomTabsConnection.mayLaunchUrl()"); |
| + } |
| } |
| private boolean mayLaunchUrlInternal(final CustomTabsSessionToken session, Uri url, |
| @@ -375,10 +388,16 @@ public class CustomTabsConnection { |
| ThreadUtils.postOnUiThread(new Runnable() { |
| @Override |
| public void run() { |
| - if (lowConfidence) { |
| - lowConfidenceMayLaunchUrl(otherLikelyBundles); |
| - } else { |
| - highConfidenceMayLaunchUrl(session, uid, urlString, extras, otherLikelyBundles); |
| + TraceEvent.begin("CustomTabsConnection.mayLaunchUrlInternal()"); |
| + try { |
| + if (lowConfidence) { |
| + lowConfidenceMayLaunchUrl(otherLikelyBundles); |
| + } else { |
| + highConfidenceMayLaunchUrl( |
| + session, uid, urlString, extras, otherLikelyBundles); |
| + } |
| + } finally { |
| + TraceEvent.end("CustomTabsConnection.mayLaunchUrlInternal()"); |
| } |
| } |
| }); |