OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import logging | 5 import logging |
6 import time | 6 import time |
7 | 7 |
8 from common import chrome_proxy_metrics | 8 from common import chrome_proxy_metrics |
9 from common import network_metrics | 9 from common import network_metrics |
10 from common.chrome_proxy_metrics import ChromeProxyMetricException | 10 from common.chrome_proxy_metrics import ChromeProxyMetricException |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 raise ChromeProxyMetricException, ( | 218 raise ChromeProxyMetricException, ( |
219 'Expected at least one response that was eligible to be proxied, but ' | 219 'Expected at least one response that was eligible to be proxied, but ' |
220 'zero such responses were received.') | 220 'zero such responses were received.') |
221 | 221 |
222 results.AddValue(scalar.ScalarValue( | 222 results.AddValue(scalar.ScalarValue( |
223 results.current_page, 'via', 'count', via_count)) | 223 results.current_page, 'via', 'count', via_count)) |
224 results.AddValue(scalar.ScalarValue( | 224 results.AddValue(scalar.ScalarValue( |
225 results.current_page, 'bypass', 'count', bypass_count)) | 225 results.current_page, 'bypass', 'count', bypass_count)) |
226 | 226 |
227 def AddResultsForLoFi(self, tab, results): | 227 def AddResultsForLoFi(self, tab, results): |
228 lo_fi_count = 0 | 228 lo_fi_request_count = 0 |
| 229 lo_fi_response_count = 0 |
229 | 230 |
230 for resp in self.IterResponses(tab): | 231 for resp in self.IterResponses(tab): |
231 if resp.HasChromeProxyLoFi(): | 232 if resp.HasChromeProxyLoFiRequest(): |
232 lo_fi_count += 1 | 233 lo_fi_request_count += 1 |
233 else: | 234 else: |
234 raise ChromeProxyMetricException, ( | 235 raise ChromeProxyMetricException, ( |
235 '%s: LoFi not in request header.' % (resp.response.url)) | 236 '%s: LoFi not in request header.' % (resp.response.url)) |
236 | 237 |
| 238 if resp.HasChromeProxyLoFiResponse(): |
| 239 lo_fi_response_count += 1 |
| 240 else: |
| 241 raise ChromeProxyMetricException, ( |
| 242 '%s: LoFi not in response header.' % (resp.response.url)) |
| 243 |
237 if resp.content_length > 100: | 244 if resp.content_length > 100: |
238 raise ChromeProxyMetricException, ( | 245 raise ChromeProxyMetricException, ( |
239 'Image %s is %d bytes. Expecting less than 100 bytes.' % | 246 'Image %s is %d bytes. Expecting less than 100 bytes.' % |
240 (resp.response.url, resp.content_length)) | 247 (resp.response.url, resp.content_length)) |
241 | 248 |
242 if lo_fi_count == 0: | 249 if lo_fi_request_count == 0: |
| 250 raise ChromeProxyMetricException, ( |
| 251 'Expected at least one LoFi request, but zero such requests were ' |
| 252 'sent.') |
| 253 if lo_fi_response_count == 0: |
243 raise ChromeProxyMetricException, ( | 254 raise ChromeProxyMetricException, ( |
244 'Expected at least one LoFi response, but zero such responses were ' | 255 'Expected at least one LoFi response, but zero such responses were ' |
245 'received.') | 256 'received.') |
246 | 257 |
247 results.AddValue(scalar.ScalarValue( | 258 results.AddValue(scalar.ScalarValue( |
248 results.current_page, 'lo_fi', 'count', lo_fi_count)) | 259 results.current_page, 'lo_fi_request', 'count', lo_fi_request_count)) |
| 260 results.AddValue(scalar.ScalarValue( |
| 261 results.current_page, 'lo_fi_response', 'count', lo_fi_response_count)) |
249 super(ChromeProxyMetric, self).AddResults(tab, results) | 262 super(ChromeProxyMetric, self).AddResults(tab, results) |
250 | 263 |
251 def AddResultsForBypass(self, tab, results): | 264 def AddResultsForBypass(self, tab, results): |
252 bypass_count = 0 | 265 bypass_count = 0 |
253 | 266 |
254 for resp in self.IterResponses(tab): | 267 for resp in self.IterResponses(tab): |
255 if resp.HasChromeProxyViaHeader(): | 268 if resp.HasChromeProxyViaHeader(): |
256 r = resp.response | 269 r = resp.response |
257 raise ChromeProxyMetricException, ( | 270 raise ChromeProxyMetricException, ( |
258 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( | 271 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 via_count += 1 | 510 via_count += 1 |
498 if via_count == 0: | 511 if via_count == 0: |
499 raise ChromeProxyMetricException, ( | 512 raise ChromeProxyMetricException, ( |
500 'Expected at least one response through the proxy after the bypass ' | 513 'Expected at least one response through the proxy after the bypass ' |
501 'expired, but zero such responses were received.') | 514 'expired, but zero such responses were received.') |
502 | 515 |
503 results.AddValue(scalar.ScalarValue( | 516 results.AddValue(scalar.ScalarValue( |
504 results.current_page, 'bypass', 'count', bypass_count)) | 517 results.current_page, 'bypass', 'count', bypass_count)) |
505 results.AddValue(scalar.ScalarValue( | 518 results.AddValue(scalar.ScalarValue( |
506 results.current_page, 'via', 'count', via_count)) | 519 results.current_page, 'via', 'count', via_count)) |
OLD | NEW |