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

Unified Diff: tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java

Issue 2414363002: tools: Extend the CustomTabs benchmark scripts to speculative_prefetch. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java
diff --git a/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java b/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java
index 00d0cd7c219771b3fdc19e3167d8f6debdc1e29d..22006cd9c00ce4181352bafe529514e30ed3a36a 100644
--- a/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java
+++ b/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java
@@ -29,8 +29,11 @@ public class MainActivity extends Activity {
// Keep in sync with the same constants in CustomTabsConnection.
private static final String DEBUG_OVERRIDE_KEY =
"android.support.customtabs.maylaunchurl.DEBUG_OVERRIDE";
+ private static final int NO_OVERRIDE = 0;
private static final int NO_PRERENDERING = 1;
private static final int PREFETCH_ONLY = 2;
+ // Only for reporting.
+ private static final int NO_STATE_PREFETCH = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -49,23 +52,33 @@ public class MainActivity extends Activity {
int delayToMayLaunchUrl = intent.getIntExtra("delay_to_may_launch_url", -1);
int delayToLaunchUrl = intent.getIntExtra("delay_to_launch_url", -1);
- int prerenderMode = 0;
- switch(intent.getStringExtra("prerender_mode")) {
- case "disabled": prerenderMode = 0; break;
- case "enabled": prerenderMode = 1; break;
- case "prefetch": prerenderMode = 2; break;
+ int speculationMode = 0;
+ String speculationModeValue = intent.getStringExtra("speculation_mode");
+ switch (speculationModeValue) {
+ case "prerender":
+ speculationMode = NO_OVERRIDE;
+ break;
+ case "disabled":
+ speculationMode = NO_PRERENDERING;
+ break;
+ case "speculative_prefetch":
+ speculationMode = PREFETCH_ONLY;
+ break;
+ case "no_state_prefetch":
+ speculationMode = NO_STATE_PREFETCH;
+ break;
default:
throw new IllegalArgumentException(
- "Invalid prerender mode: " + intent.getStringExtra("prerender_mode"));
+ "Invalid prerender mode: " + speculationModeValue);
}
launchCustomTabs(
- packageName, url, warmup, prerenderMode, delayToMayLaunchUrl, delayToLaunchUrl);
+ packageName, url, warmup, speculationMode, delayToMayLaunchUrl, delayToLaunchUrl);
}
private static final class CustomCallback extends CustomTabsCallback {
private final boolean mWarmup;
- private final int mPrerenderMode;
+ private final int mSpeculationMode;
private final int mDelayToMayLaunchUrl;
private final int mDelayToLaunchUrl;
private long mIntentSentMs = 0;
@@ -74,10 +87,10 @@ public class MainActivity extends Activity {
private long mFirstContentfulPaintMs = -1;
private boolean mAlreadyLogged = false;
- public CustomCallback(boolean warmup, int prerenderMode, int delayToMayLaunchUrl,
+ public CustomCallback(boolean warmup, int speculationMode, int delayToMayLaunchUrl,
int delayToLaunchUrl) {
mWarmup = warmup;
- mPrerenderMode = prerenderMode;
+ mSpeculationMode = speculationMode;
mDelayToMayLaunchUrl = delayToMayLaunchUrl;
mDelayToLaunchUrl = delayToLaunchUrl;
}
@@ -124,7 +137,7 @@ public class MainActivity extends Activity {
private void logMetrics() {
if (mAlreadyLogged) return;
- String logLine = (mWarmup ? "1" : "0") + "," + mPrerenderMode + ","
+ String logLine = (mWarmup ? "1" : "0") + "," + mSpeculationMode + ","
+ mDelayToMayLaunchUrl + "," + mDelayToLaunchUrl + "," + mIntentSentMs + ","
+ mPageLoadStartedMs + "," + mPageLoadFinishedMs + ","
+ mFirstContentfulPaintMs;
@@ -150,7 +163,12 @@ public class MainActivity extends Activity {
@Override
public void run() {
Bundle extras = new Bundle();
- if (prerenderMode == 0) extras.putInt(DEBUG_OVERRIDE_KEY, NO_PRERENDERING);
+ if (prerenderMode == NO_PRERENDERING) {
+ extras.putInt(DEBUG_OVERRIDE_KEY, NO_PRERENDERING);
+ } else if (prerenderMode != NO_STATE_PREFETCH) {
+ extras.putInt(DEBUG_OVERRIDE_KEY, prerenderMode);
+ }
+
session.mayLaunchUrl(uri, extras, null);
handler.postDelayed(launchRunnable, delayToLaunchUrl);
}
@@ -165,10 +183,9 @@ public class MainActivity extends Activity {
}
private void launchCustomTabs(String packageName, String url, final boolean warmup,
- final int prerenderMode, final int delayToMayLaunchUrl,
- final int delayToLaunchUrl) {
+ final int speculationMode, final int delayToMayLaunchUrl, final int delayToLaunchUrl) {
final CustomCallback cb =
- new CustomCallback(warmup, prerenderMode, delayToMayLaunchUrl, delayToLaunchUrl);
+ new CustomCallback(warmup, speculationMode, delayToMayLaunchUrl, delayToLaunchUrl);
final Uri uri = Uri.parse(url);
CustomTabsClient.bindCustomTabsService(
this, packageName, new CustomTabsServiceConnection() {
@@ -176,7 +193,7 @@ public class MainActivity extends Activity {
public void onCustomTabsServiceConnected(
ComponentName name, final CustomTabsClient client) {
MainActivity.this.onCustomTabsServiceConnected(client, uri, cb, warmup,
- prerenderMode, delayToMayLaunchUrl, delayToLaunchUrl);
+ speculationMode, delayToMayLaunchUrl, delayToLaunchUrl);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698