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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java

Issue 2508933002: tools: Local tests for the speculative prefetch predictor. (Closed)
Patch Set: Rebase/ Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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()");
}
}
});

Powered by Google App Engine
This is Rietveld 408576698