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

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..cea82fde8e9994c7cd2957611a9f061d29bd18f3 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,8 @@ 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";
+ public static final int PAGE_LOAD_METRIC = 42;
+
@VisibleForTesting
static final String NO_PRERENDERING_KEY =
"android.support.customtabs.maylaunchurl.NO_PRERENDERING";
@@ -552,6 +554,30 @@ public class CustomTabsConnection {
}
/**
+ * 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 (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.
*
* The application is kept alive (that is, raised to at least the current

Powered by Google App Engine
This is Rietveld 408576698