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: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java

Issue 2139243003: customtabs: Send time to first contentful paint to the caller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 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: 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 a8df5211de0d040a2abf091b6cd20d2de820fde3..b71e2c2d6cef81763a7867617648f20445d9303c 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
@@ -69,6 +69,9 @@ import java.util.concurrent.atomic.AtomicReference;
public class CustomTabsConnection {
private static final String TAG = "ChromeConnection";
private static final String LOG_SERVICE_REQUESTS = "custom-tabs-log-service-requests";
+ // TODO(lizeb): Switch to a proper notification for page load metrics.
+ public static final int PAGE_LOAD_METRIC = 42;
+
@VisibleForTesting
static final String NO_PRERENDERING_KEY =
"android.support.customtabs.maylaunchurl.NO_PRERENDERING";
@@ -103,6 +106,8 @@ public class CustomTabsConnection {
private final AtomicBoolean mWarmupHasBeenFinished = new AtomicBoolean();
private ExternalPrerenderHandler mExternalPrerenderHandler;
private WebContents mSpareWebContents;
+ // TODO(lizeb): Remove once crbug.com/630303 is fixed.
+ private boolean mPageLoadMetricsEnabled;
/**
* <strong>DO NOT CALL</strong>
@@ -551,6 +556,37 @@ public class CustomTabsConnection {
return true;
}
+ // TODO(lizeb): Remove once crbug.com/630303 is fixed.
+ @VisibleForTesting
+ void enablePageLoadMetricsCallbacks() {
+ mPageLoadMetricsEnabled = true;
+ }
+
+ /**
+ * Notifies the application of a page load metric.
+ *
+ * TODD(lizeb): Move this to a proper method in {@link CustomTabsCallback} once one is
+ * available.
+ *
+ * @param session Session identifier.
+ * @param metricName Name of the page load metric.
+ * @param offsetMs Offset in ms from navigationStart.
+ */
+ boolean notifyPageLoadMetric(CustomTabsSessionToken session, String metricName, long offsetMs) {
+ CustomTabsCallback callback = mClientManager.getCallbackForSession(session);
+ if (!mPageLoadMetricsEnabled) return false;
+ if (callback == null) return false;
+ Bundle args = new Bundle();
+ args.putLong(metricName, offsetMs);
+ try {
+ callback.onNavigationEvent(PAGE_LOAD_METRIC, args);
+ } catch (Exception e) {
+ // Pokemon exception handling, see above and crbug.com/517023.
+ return false;
+ }
+ return true;
+ }
+
/**
* Keeps the application linked with a given session alive.
*

Powered by Google App Engine
This is Rietveld 408576698