Commit 1ad34d61 authored by mgersh's avatar mgersh Committed by Commit bot

Rename RequestFinishedInfo.Metrics.getResponseEnd() to getRequestEnd()

The timestamp is available even when there is no response, so this name
makes more sense.

BUG=629194

Review-Url: https://codereview.chromium.org/2401933002
Cr-Commit-Position: refs/heads/master@{#423872}
parent a9201644
...@@ -67,7 +67,7 @@ public final class RequestFinishedInfo { ...@@ -67,7 +67,7 @@ public final class RequestFinishedInfo {
* <li>{@link #getSendingStart sending start}</li> * <li>{@link #getSendingStart sending start}</li>
* <li>{@link #getSendingEnd sending end}</li> * <li>{@link #getSendingEnd sending end}</li>
* <li>{@link #getResponseStart response start}</li> * <li>{@link #getResponseStart response start}</li>
* <li>{@link #getResponseEnd response end}</li> * <li>{@link #getRequestEnd request end}</li>
* </ol> * </ol>
* *
* Start times are reported as the time when a request started blocking on event, not when the * Start times are reported as the time when a request started blocking on event, not when the
...@@ -196,12 +196,11 @@ public final class RequestFinishedInfo { ...@@ -196,12 +196,11 @@ public final class RequestFinishedInfo {
public abstract Date getResponseStart(); public abstract Date getResponseStart();
/** /**
* Returns time when last byte of response was received. * Returns time when the request finished.
* @return {@link java.util.Date} representing when the last byte of the response was * @return {@link java.util.Date} representing when the request finished.
* received.
*/ */
@Nullable @Nullable
public abstract Date getResponseEnd(); public abstract Date getRequestEnd();
/** /**
* Returns whether the socket was reused from a previous request. In HTTP/2 or QUIC, if * Returns whether the socket was reused from a previous request. In HTTP/2 or QUIC, if
......
...@@ -629,7 +629,7 @@ public class CronetBidirectionalStream extends BidirectionalStream { ...@@ -629,7 +629,7 @@ public class CronetBidirectionalStream extends BidirectionalStream {
private void onMetricsCollected(long requestStartMs, long dnsStartMs, long dnsEndMs, private void onMetricsCollected(long requestStartMs, long dnsStartMs, long dnsEndMs,
long connectStartMs, long connectEndMs, long sslStartMs, long sslEndMs, long connectStartMs, long connectEndMs, long sslStartMs, long sslEndMs,
long sendingStartMs, long sendingEndMs, long pushStartMs, long pushEndMs, long sendingStartMs, long sendingEndMs, long pushStartMs, long pushEndMs,
long responseStartMs, long responseEndMs, boolean socketReused, long sentBytesCount, long responseStartMs, long requestEndMs, boolean socketReused, long sentBytesCount,
long receivedBytesCount) { long receivedBytesCount) {
synchronized (mNativeStreamLock) { synchronized (mNativeStreamLock) {
if (mMetrics != null) { if (mMetrics != null) {
...@@ -637,7 +637,7 @@ public class CronetBidirectionalStream extends BidirectionalStream { ...@@ -637,7 +637,7 @@ public class CronetBidirectionalStream extends BidirectionalStream {
} }
mMetrics = new CronetMetrics(requestStartMs, dnsStartMs, dnsEndMs, connectStartMs, mMetrics = new CronetMetrics(requestStartMs, dnsStartMs, dnsEndMs, connectStartMs,
connectEndMs, sslStartMs, sslEndMs, sendingStartMs, sendingEndMs, pushStartMs, connectEndMs, sslStartMs, sslEndMs, sendingStartMs, sendingEndMs, pushStartMs,
pushEndMs, responseStartMs, responseEndMs, socketReused, sentBytesCount, pushEndMs, responseStartMs, requestEndMs, socketReused, sentBytesCount,
receivedBytesCount); receivedBytesCount);
// TODO(xunjieli): Fill this with real values. // TODO(xunjieli): Fill this with real values.
final RequestFinishedInfo requestFinishedInfo = final RequestFinishedInfo requestFinishedInfo =
......
...@@ -28,7 +28,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -28,7 +28,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
private final long mPushStartMs; private final long mPushStartMs;
private final long mPushEndMs; private final long mPushEndMs;
private final long mResponseStartMs; private final long mResponseStartMs;
private final long mResponseEndMs; private final long mRequestEndMs;
private final boolean mSocketReused; private final boolean mSocketReused;
// TODO(mgersh): Delete after the switch to the new API http://crbug.com/629194 // TODO(mgersh): Delete after the switch to the new API http://crbug.com/629194
...@@ -80,7 +80,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -80,7 +80,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
mPushStartMs = -1; mPushStartMs = -1;
mPushEndMs = -1; mPushEndMs = -1;
mResponseStartMs = -1; mResponseStartMs = -1;
mResponseEndMs = -1; mRequestEndMs = -1;
mSocketReused = false; mSocketReused = false;
} }
...@@ -90,8 +90,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -90,8 +90,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
public CronetMetrics(long requestStartMs, long dnsStartMs, long dnsEndMs, long connectStartMs, public CronetMetrics(long requestStartMs, long dnsStartMs, long dnsEndMs, long connectStartMs,
long connectEndMs, long sslStartMs, long sslEndMs, long sendingStartMs, long connectEndMs, long sslStartMs, long sslEndMs, long sendingStartMs,
long sendingEndMs, long pushStartMs, long pushEndMs, long responseStartMs, long sendingEndMs, long pushStartMs, long pushEndMs, long responseStartMs,
long responseEndMs, boolean socketReused, long sentBytesCount, long requestEndMs, boolean socketReused, long sentBytesCount, long receivedBytesCount) {
long receivedBytesCount) {
// Check that no end times are before corresponding start times, // Check that no end times are before corresponding start times,
// or exist when start time doesn't. // or exist when start time doesn't.
assert checkOrder(dnsStartMs, dnsEndMs); assert checkOrder(dnsStartMs, dnsEndMs);
...@@ -99,8 +98,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -99,8 +98,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
assert checkOrder(sslStartMs, sslEndMs); assert checkOrder(sslStartMs, sslEndMs);
assert checkOrder(sendingStartMs, sendingEndMs); assert checkOrder(sendingStartMs, sendingEndMs);
assert checkOrder(pushStartMs, pushEndMs); assert checkOrder(pushStartMs, pushEndMs);
// responseEnd always exists, so just check that it's after start // requestEnd always exists, so just check that it's after start
assert responseEndMs >= responseStartMs; assert requestEndMs >= responseStartMs;
// Spot-check some of the other orderings // Spot-check some of the other orderings
assert dnsStartMs >= requestStartMs || dnsStartMs == -1; assert dnsStartMs >= requestStartMs || dnsStartMs == -1;
assert sendingStartMs >= requestStartMs || sendingStartMs == -1; assert sendingStartMs >= requestStartMs || sendingStartMs == -1;
...@@ -118,7 +117,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -118,7 +117,7 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
mPushStartMs = pushStartMs; mPushStartMs = pushStartMs;
mPushEndMs = pushEndMs; mPushEndMs = pushEndMs;
mResponseStartMs = responseStartMs; mResponseStartMs = responseStartMs;
mResponseEndMs = responseEndMs; mRequestEndMs = requestEndMs;
mSocketReused = socketReused; mSocketReused = socketReused;
mSentBytesCount = sentBytesCount; mSentBytesCount = sentBytesCount;
mReceivedBytesCount = receivedBytesCount; mReceivedBytesCount = receivedBytesCount;
...@@ -129,8 +128,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -129,8 +128,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
} else { } else {
mTtfbMs = null; mTtfbMs = null;
} }
if (requestStartMs != -1 && responseEndMs != -1) { if (requestStartMs != -1 && requestEndMs != -1) {
mTotalTimeMs = responseEndMs - requestStartMs; mTotalTimeMs = requestEndMs - requestStartMs;
} else { } else {
mTotalTimeMs = null; mTotalTimeMs = null;
} }
...@@ -197,8 +196,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics { ...@@ -197,8 +196,8 @@ public final class CronetMetrics extends RequestFinishedInfo.Metrics {
} }
@Nullable @Nullable
public Date getResponseEnd() { public Date getRequestEnd() {
return toDate(mResponseEndMs); return toDate(mRequestEndMs);
} }
@Nullable @Nullable
......
...@@ -697,7 +697,7 @@ public final class CronetUrlRequest implements UrlRequest { ...@@ -697,7 +697,7 @@ public final class CronetUrlRequest implements UrlRequest {
private void onMetricsCollected(long requestStartMs, long dnsStartMs, long dnsEndMs, private void onMetricsCollected(long requestStartMs, long dnsStartMs, long dnsEndMs,
long connectStartMs, long connectEndMs, long sslStartMs, long sslEndMs, long connectStartMs, long connectEndMs, long sslStartMs, long sslEndMs,
long sendingStartMs, long sendingEndMs, long pushStartMs, long pushEndMs, long sendingStartMs, long sendingEndMs, long pushStartMs, long pushEndMs,
long responseStartMs, long responseEndMs, boolean socketReused, long sentBytesCount, long responseStartMs, long requestEndMs, boolean socketReused, long sentBytesCount,
long receivedBytesCount) { long receivedBytesCount) {
synchronized (mUrlRequestAdapterLock) { synchronized (mUrlRequestAdapterLock) {
if (mMetrics != null) { if (mMetrics != null) {
...@@ -705,7 +705,7 @@ public final class CronetUrlRequest implements UrlRequest { ...@@ -705,7 +705,7 @@ public final class CronetUrlRequest implements UrlRequest {
} }
mMetrics = new CronetMetrics(requestStartMs, dnsStartMs, dnsEndMs, connectStartMs, mMetrics = new CronetMetrics(requestStartMs, dnsStartMs, dnsEndMs, connectStartMs,
connectEndMs, sslStartMs, sslEndMs, sendingStartMs, sendingEndMs, pushStartMs, connectEndMs, sslStartMs, sslEndMs, sendingStartMs, sendingEndMs, pushStartMs,
pushEndMs, responseStartMs, responseEndMs, socketReused, sentBytesCount, pushEndMs, responseStartMs, requestEndMs, socketReused, sentBytesCount,
receivedBytesCount); receivedBytesCount);
} }
mRequestContext.reportFinished(getRequestFinishedInfo()); mRequestContext.reportFinished(getRequestFinishedInfo());
......
...@@ -1205,11 +1205,10 @@ public class BidirectionalStreamTest extends CronetTestBase { ...@@ -1205,11 +1205,10 @@ public class BidirectionalStreamTest extends CronetTestBase {
// metrics.getResponseStart() can be null or non null // metrics.getResponseStart() can be null or non null
// TODO(xunjieli): It's weird to have a null response start but a // TODO(xunjieli): It's weird to have a null response start but a
// non-null response end. // non-null response end.
assertNotNull(metrics.getResponseEnd()); assertNotNull(metrics.getRequestEnd());
MetricsTestUtil.assertAfter(endTime, metrics.getResponseEnd()); MetricsTestUtil.assertAfter(endTime, metrics.getRequestEnd());
// Entire request should take more than 0 ms // Entire request should take more than 0 ms
assertTrue( assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestStart().getTime() > 0);
metrics.getResponseEnd().getTime() - metrics.getRequestStart().getTime() > 0);
} }
assertEquals(expectError, callback.mError != null); assertEquals(expectError, callback.mError != null);
assertEquals(expectError, callback.mOnErrorCalled); assertEquals(expectError, callback.mOnErrorCalled);
......
...@@ -109,10 +109,10 @@ public class MetricsTestUtil { ...@@ -109,10 +109,10 @@ public class MetricsTestUtil {
assertTrue(metrics.getSendingEnd().before(endTime)); assertTrue(metrics.getSendingEnd().before(endTime));
assertNotNull(metrics.getResponseStart()); assertNotNull(metrics.getResponseStart());
assertTrue(metrics.getResponseStart().after(startTime)); assertTrue(metrics.getResponseStart().after(startTime));
assertNotNull(metrics.getResponseEnd()); assertNotNull(metrics.getRequestEnd());
assertAfter(endTime, metrics.getResponseEnd()); assertAfter(endTime, metrics.getRequestEnd());
// Entire request should take more than 0 ms // Entire request should take more than 0 ms
assertTrue(metrics.getResponseEnd().getTime() - metrics.getRequestStart().getTime() > 0); assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestStart().getTime() > 0);
} }
/** /**
......
...@@ -259,11 +259,11 @@ public class RequestFinishedInfoTest extends CronetTestBase { ...@@ -259,11 +259,11 @@ public class RequestFinishedInfoTest extends CronetTestBase {
assertNull(metrics.getSendingStart()); assertNull(metrics.getSendingStart());
assertNull(metrics.getSendingEnd()); assertNull(metrics.getSendingEnd());
assertNull(metrics.getResponseStart()); assertNull(metrics.getResponseStart());
assertNotNull(metrics.getResponseEnd()); assertNotNull(metrics.getRequestEnd());
assertTrue(metrics.getResponseEnd().before(endTime) assertTrue(
|| metrics.getResponseEnd().equals(endTime)); metrics.getRequestEnd().before(endTime) || metrics.getRequestEnd().equals(endTime));
// Entire request should take more than 0 ms // Entire request should take more than 0 ms
assertTrue(metrics.getResponseEnd().getTime() - metrics.getRequestStart().getTime() > 0); assertTrue(metrics.getRequestEnd().getTime() - metrics.getRequestStart().getTime() > 0);
assertTrue(metrics.getSentBytesCount() == 0); assertTrue(metrics.getSentBytesCount() == 0);
assertTrue(metrics.getReceivedBytesCount() == 0); assertTrue(metrics.getReceivedBytesCount() == 0);
mTestFramework.mCronetEngine.shutdown(); mTestFramework.mCronetEngine.shutdown();
...@@ -355,14 +355,14 @@ public class RequestFinishedInfoTest extends CronetTestBase { ...@@ -355,14 +355,14 @@ public class RequestFinishedInfoTest extends CronetTestBase {
long pushStart = 10; long pushStart = 10;
long pushEnd = 11; long pushEnd = 11;
long responseStart = 12; long responseStart = 12;
long responseEnd = 13; long requestEnd = 13;
boolean socketReused = true; boolean socketReused = true;
long sentBytesCount = 14; long sentBytesCount = 14;
long receivedBytesCount = 15; long receivedBytesCount = 15;
// Make sure nothing gets reordered inside the Metrics class // Make sure nothing gets reordered inside the Metrics class
RequestFinishedInfo.Metrics metrics = new CronetMetrics(requestStart, dnsStart, dnsEnd, RequestFinishedInfo.Metrics metrics = new CronetMetrics(requestStart, dnsStart, dnsEnd,
connectStart, connectEnd, sslStart, sslEnd, sendingStart, sendingEnd, pushStart, connectStart, connectEnd, sslStart, sslEnd, sendingStart, sendingEnd, pushStart,
pushEnd, responseStart, responseEnd, socketReused, sentBytesCount, pushEnd, responseStart, requestEnd, socketReused, sentBytesCount,
receivedBytesCount); receivedBytesCount);
assertEquals(new Date(requestStart), metrics.getRequestStart()); assertEquals(new Date(requestStart), metrics.getRequestStart());
// -1 timestamp should translate to null // -1 timestamp should translate to null
...@@ -375,7 +375,7 @@ public class RequestFinishedInfoTest extends CronetTestBase { ...@@ -375,7 +375,7 @@ public class RequestFinishedInfoTest extends CronetTestBase {
assertEquals(new Date(pushStart), metrics.getPushStart()); assertEquals(new Date(pushStart), metrics.getPushStart());
assertEquals(new Date(pushEnd), metrics.getPushEnd()); assertEquals(new Date(pushEnd), metrics.getPushEnd());
assertEquals(new Date(responseStart), metrics.getResponseStart()); assertEquals(new Date(responseStart), metrics.getResponseStart());
assertEquals(new Date(responseEnd), metrics.getResponseEnd()); assertEquals(new Date(requestEnd), metrics.getRequestEnd());
assertEquals(socketReused, metrics.getSocketReused()); assertEquals(socketReused, metrics.getSocketReused());
assertEquals(sentBytesCount, (long) metrics.getSentBytesCount()); assertEquals(sentBytesCount, (long) metrics.getSentBytesCount());
assertEquals(receivedBytesCount, (long) metrics.getReceivedBytesCount()); assertEquals(receivedBytesCount, (long) metrics.getReceivedBytesCount());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment