OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net.impl; | 5 package org.chromium.net.impl; |
6 | 6 |
7 import android.support.annotation.Nullable; | 7 import android.support.annotation.Nullable; |
8 | 8 |
9 import org.chromium.base.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
10 import org.chromium.net.RequestFinishedInfo; | 10 import org.chromium.net.RequestFinishedInfo; |
(...skipping 10 matching lines...) Expand all Loading... |
21 private final long mDnsEndMs; | 21 private final long mDnsEndMs; |
22 private final long mConnectStartMs; | 22 private final long mConnectStartMs; |
23 private final long mConnectEndMs; | 23 private final long mConnectEndMs; |
24 private final long mSslStartMs; | 24 private final long mSslStartMs; |
25 private final long mSslEndMs; | 25 private final long mSslEndMs; |
26 private final long mSendingStartMs; | 26 private final long mSendingStartMs; |
27 private final long mSendingEndMs; | 27 private final long mSendingEndMs; |
28 private final long mPushStartMs; | 28 private final long mPushStartMs; |
29 private final long mPushEndMs; | 29 private final long mPushEndMs; |
30 private final long mResponseStartMs; | 30 private final long mResponseStartMs; |
31 private final long mResponseEndMs; | 31 private final long mRequestEndMs; |
32 private final boolean mSocketReused; | 32 private final boolean mSocketReused; |
33 | 33 |
34 // TODO(mgersh): Delete after the switch to the new API http://crbug.com/629
194 | 34 // TODO(mgersh): Delete after the switch to the new API http://crbug.com/629
194 |
35 @Nullable | 35 @Nullable |
36 private final Long mTtfbMs; | 36 private final Long mTtfbMs; |
37 // TODO(mgersh): Delete after the switch to the new API http://crbug.com/629
194 | 37 // TODO(mgersh): Delete after the switch to the new API http://crbug.com/629
194 |
38 @Nullable | 38 @Nullable |
39 private final Long mTotalTimeMs; | 39 private final Long mTotalTimeMs; |
40 @Nullable | 40 @Nullable |
41 private final Long mSentBytesCount; | 41 private final Long mSentBytesCount; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 mDnsEndMs = -1; | 73 mDnsEndMs = -1; |
74 mConnectStartMs = -1; | 74 mConnectStartMs = -1; |
75 mConnectEndMs = -1; | 75 mConnectEndMs = -1; |
76 mSslStartMs = -1; | 76 mSslStartMs = -1; |
77 mSslEndMs = -1; | 77 mSslEndMs = -1; |
78 mSendingStartMs = -1; | 78 mSendingStartMs = -1; |
79 mSendingEndMs = -1; | 79 mSendingEndMs = -1; |
80 mPushStartMs = -1; | 80 mPushStartMs = -1; |
81 mPushEndMs = -1; | 81 mPushEndMs = -1; |
82 mResponseStartMs = -1; | 82 mResponseStartMs = -1; |
83 mResponseEndMs = -1; | 83 mRequestEndMs = -1; |
84 mSocketReused = false; | 84 mSocketReused = false; |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * New-style constructor | 88 * New-style constructor |
89 */ | 89 */ |
90 public CronetMetrics(long requestStartMs, long dnsStartMs, long dnsEndMs, lo
ng connectStartMs, | 90 public CronetMetrics(long requestStartMs, long dnsStartMs, long dnsEndMs, lo
ng connectStartMs, |
91 long connectEndMs, long sslStartMs, long sslEndMs, long sendingStart
Ms, | 91 long connectEndMs, long sslStartMs, long sslEndMs, long sendingStart
Ms, |
92 long sendingEndMs, long pushStartMs, long pushEndMs, long responseSt
artMs, | 92 long sendingEndMs, long pushStartMs, long pushEndMs, long responseSt
artMs, |
93 long responseEndMs, boolean socketReused, long sentBytesCount, | 93 long requestEndMs, boolean socketReused, long sentBytesCount, long r
eceivedBytesCount) { |
94 long receivedBytesCount) { | |
95 // Check that no end times are before corresponding start times, | 94 // Check that no end times are before corresponding start times, |
96 // or exist when start time doesn't. | 95 // or exist when start time doesn't. |
97 assert checkOrder(dnsStartMs, dnsEndMs); | 96 assert checkOrder(dnsStartMs, dnsEndMs); |
98 assert checkOrder(connectStartMs, connectEndMs); | 97 assert checkOrder(connectStartMs, connectEndMs); |
99 assert checkOrder(sslStartMs, sslEndMs); | 98 assert checkOrder(sslStartMs, sslEndMs); |
100 assert checkOrder(sendingStartMs, sendingEndMs); | 99 assert checkOrder(sendingStartMs, sendingEndMs); |
101 assert checkOrder(pushStartMs, pushEndMs); | 100 assert checkOrder(pushStartMs, pushEndMs); |
102 // responseEnd always exists, so just check that it's after start | 101 // requestEnd always exists, so just check that it's after start |
103 assert responseEndMs >= responseStartMs; | 102 assert requestEndMs >= responseStartMs; |
104 // Spot-check some of the other orderings | 103 // Spot-check some of the other orderings |
105 assert dnsStartMs >= requestStartMs || dnsStartMs == -1; | 104 assert dnsStartMs >= requestStartMs || dnsStartMs == -1; |
106 assert sendingStartMs >= requestStartMs || sendingStartMs == -1; | 105 assert sendingStartMs >= requestStartMs || sendingStartMs == -1; |
107 assert sslStartMs >= connectStartMs || sslStartMs == -1; | 106 assert sslStartMs >= connectStartMs || sslStartMs == -1; |
108 assert responseStartMs >= sendingStartMs || responseStartMs == -1; | 107 assert responseStartMs >= sendingStartMs || responseStartMs == -1; |
109 mRequestStartMs = requestStartMs; | 108 mRequestStartMs = requestStartMs; |
110 mDnsStartMs = dnsStartMs; | 109 mDnsStartMs = dnsStartMs; |
111 mDnsEndMs = dnsEndMs; | 110 mDnsEndMs = dnsEndMs; |
112 mConnectStartMs = connectStartMs; | 111 mConnectStartMs = connectStartMs; |
113 mConnectEndMs = connectEndMs; | 112 mConnectEndMs = connectEndMs; |
114 mSslStartMs = sslStartMs; | 113 mSslStartMs = sslStartMs; |
115 mSslEndMs = sslEndMs; | 114 mSslEndMs = sslEndMs; |
116 mSendingStartMs = sendingStartMs; | 115 mSendingStartMs = sendingStartMs; |
117 mSendingEndMs = sendingEndMs; | 116 mSendingEndMs = sendingEndMs; |
118 mPushStartMs = pushStartMs; | 117 mPushStartMs = pushStartMs; |
119 mPushEndMs = pushEndMs; | 118 mPushEndMs = pushEndMs; |
120 mResponseStartMs = responseStartMs; | 119 mResponseStartMs = responseStartMs; |
121 mResponseEndMs = responseEndMs; | 120 mRequestEndMs = requestEndMs; |
122 mSocketReused = socketReused; | 121 mSocketReused = socketReused; |
123 mSentBytesCount = sentBytesCount; | 122 mSentBytesCount = sentBytesCount; |
124 mReceivedBytesCount = receivedBytesCount; | 123 mReceivedBytesCount = receivedBytesCount; |
125 | 124 |
126 // TODO(mgersh): delete these after embedders stop using them http://crb
ug.com/629194 | 125 // TODO(mgersh): delete these after embedders stop using them http://crb
ug.com/629194 |
127 if (requestStartMs != -1 && responseStartMs != -1) { | 126 if (requestStartMs != -1 && responseStartMs != -1) { |
128 mTtfbMs = responseStartMs - requestStartMs; | 127 mTtfbMs = responseStartMs - requestStartMs; |
129 } else { | 128 } else { |
130 mTtfbMs = null; | 129 mTtfbMs = null; |
131 } | 130 } |
132 if (requestStartMs != -1 && responseEndMs != -1) { | 131 if (requestStartMs != -1 && requestEndMs != -1) { |
133 mTotalTimeMs = responseEndMs - requestStartMs; | 132 mTotalTimeMs = requestEndMs - requestStartMs; |
134 } else { | 133 } else { |
135 mTotalTimeMs = null; | 134 mTotalTimeMs = null; |
136 } | 135 } |
137 } | 136 } |
138 | 137 |
139 @Nullable | 138 @Nullable |
140 public Date getRequestStart() { | 139 public Date getRequestStart() { |
141 return toDate(mRequestStartMs); | 140 return toDate(mRequestStartMs); |
142 } | 141 } |
143 | 142 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 public Date getPushEnd() { | 189 public Date getPushEnd() { |
191 return toDate(mPushEndMs); | 190 return toDate(mPushEndMs); |
192 } | 191 } |
193 | 192 |
194 @Nullable | 193 @Nullable |
195 public Date getResponseStart() { | 194 public Date getResponseStart() { |
196 return toDate(mResponseStartMs); | 195 return toDate(mResponseStartMs); |
197 } | 196 } |
198 | 197 |
199 @Nullable | 198 @Nullable |
200 public Date getResponseEnd() { | 199 public Date getRequestEnd() { |
201 return toDate(mResponseEndMs); | 200 return toDate(mRequestEndMs); |
202 } | 201 } |
203 | 202 |
204 @Nullable | 203 @Nullable |
205 public boolean getSocketReused() { | 204 public boolean getSocketReused() { |
206 return mSocketReused; | 205 return mSocketReused; |
207 } | 206 } |
208 | 207 |
209 @Nullable | 208 @Nullable |
210 public Long getTtfbMs() { | 209 public Long getTtfbMs() { |
211 return mTtfbMs; | 210 return mTtfbMs; |
212 } | 211 } |
213 | 212 |
214 @Nullable | 213 @Nullable |
215 public Long getTotalTimeMs() { | 214 public Long getTotalTimeMs() { |
216 return mTotalTimeMs; | 215 return mTotalTimeMs; |
217 } | 216 } |
218 | 217 |
219 @Nullable | 218 @Nullable |
220 public Long getSentBytesCount() { | 219 public Long getSentBytesCount() { |
221 return mSentBytesCount; | 220 return mSentBytesCount; |
222 } | 221 } |
223 | 222 |
224 @Nullable | 223 @Nullable |
225 public Long getReceivedBytesCount() { | 224 public Long getReceivedBytesCount() { |
226 return mReceivedBytesCount; | 225 return mReceivedBytesCount; |
227 } | 226 } |
228 } | 227 } |
OLD | NEW |