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

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

Issue 2472163003: [CustomTabs] Report the navigation start as absolute time (Closed)
Patch Set: Cache tick offset 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 8a586b14d79574446bd4eed4ac43f8c9d10a8883..0078629cdfe3d22481f932d07c498d4f5edabd9e 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
@@ -19,6 +19,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.StrictMode;
+import android.os.SystemClock;
import android.support.customtabs.CustomTabsCallback;
import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsService;
@@ -30,6 +31,7 @@ import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.SysUtils;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.TimeUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.library_loader.ProcessInitException;
@@ -41,6 +43,7 @@ import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.WarmupManager;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
+import org.chromium.chrome.browser.metrics.PageLoadMetrics;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler;
@@ -127,6 +130,8 @@ public class CustomTabsConnection {
private final AtomicBoolean mWarmupHasBeenCalled = new AtomicBoolean();
private final AtomicBoolean mWarmupHasBeenFinished = new AtomicBoolean();
private ExternalPrerenderHandler mExternalPrerenderHandler;
+ private long mOffsetTick;
pasko 2016/11/21 17:16:37 saw this in Benoit's rebase, thoughts: 1. s/mOffs
+ private boolean mOffsetTickComputed = false;
/**
* <strong>DO NOT CALL</strong>
@@ -680,12 +685,24 @@ public class CustomTabsConnection {
*
* @param session Session identifier.
* @param metricName Name of the page load metric.
+ * @param navigationStartTick Absolute navigation start time, as TimeTicks.
pasko 2016/11/21 17:16:37 3. I guess it needs to say something about the tic
* @param offsetMs Offset in ms from navigationStart.
*/
- boolean notifyPageLoadMetric(CustomTabsSessionToken session, String metricName, long offsetMs) {
+ boolean notifyPageLoadMetric(CustomTabsSessionToken session, String metricName,
+ long navigationStartTick, long offsetMs) {
CustomTabsCallback callback = mClientManager.getCallbackForSession(session);
if (callback == null) return false;
+
+ if (!mOffsetTickComputed) {
+ // Compute offset from time ticks to uptimeMillis.
+ mOffsetTickComputed = true;
+ long nativeNowUs = TimeUtils.nativeGetTimeTicksNowUs();
+ long javaNowUs = SystemClock.uptimeMillis() * 1000;
+ mOffsetTick = nativeNowUs - javaNowUs;
pasko 2016/11/21 17:16:37 aren't these two coming from different syscalls? A
droger 2016/11/21 17:28:02 In practice, they will stay the same, although thi
pasko 2016/11/21 18:56:11 I do not quite remember the details of the discuss
Bryan McQuade 2016/11/21 19:05:53 Yeah - I think the conclusion was that though both
+ }
+
Bundle args = new Bundle();
+ args.putLong(PageLoadMetrics.NAVIGATION_START, (navigationStartTick - mOffsetTick) / 1000);
args.putLong(metricName, offsetMs);
try {
callback.extraCallback(PAGE_LOAD_METRICS_CALLBACK, args);

Powered by Google App Engine
This is Rietveld 408576698