Chromium Code Reviews| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 raise ChromeProxyMetricException, ( | 254 raise ChromeProxyMetricException, ( |
| 255 'Expected at least one LoFi response, but zero such responses were ' | 255 'Expected at least one LoFi response, but zero such responses were ' |
| 256 'received.') | 256 'received.') |
| 257 | 257 |
| 258 results.AddValue(scalar.ScalarValue( | 258 results.AddValue(scalar.ScalarValue( |
| 259 results.current_page, 'lo_fi_request', 'count', lo_fi_request_count)) | 259 results.current_page, 'lo_fi_request', 'count', lo_fi_request_count)) |
| 260 results.AddValue(scalar.ScalarValue( | 260 results.AddValue(scalar.ScalarValue( |
| 261 results.current_page, 'lo_fi_response', 'count', lo_fi_response_count)) | 261 results.current_page, 'lo_fi_response', 'count', lo_fi_response_count)) |
| 262 super(ChromeProxyMetric, self).AddResults(tab, results) | 262 super(ChromeProxyMetric, self).AddResults(tab, results) |
| 263 | 263 |
| 264 def AddResultsForBypass(self, tab, results): | 264 def AddResultsForBypass(self, tab, results, url_pattern=""): |
| 265 bypass_count = 0 | 265 bypass_count = 0 |
| 266 skipped_count = 0 | |
| 266 | 267 |
| 267 for resp in self.IterResponses(tab): | 268 for resp in self.IterResponses(tab): |
| 269 # Only check the url's that contain the specified pattern | |
|
sclittle
2015/05/19 22:17:45
nit: add period at end of comment
bustamante
2015/05/19 22:26:08
Done.
| |
| 270 if url_pattern and url_pattern not in resp.response.url: | |
| 271 skipped_count += 1 | |
| 272 continue | |
| 273 | |
| 268 if resp.HasChromeProxyViaHeader(): | 274 if resp.HasChromeProxyViaHeader(): |
| 269 r = resp.response | 275 r = resp.response |
| 270 raise ChromeProxyMetricException, ( | 276 raise ChromeProxyMetricException, ( |
| 271 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( | 277 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( |
| 272 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) | 278 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
| 273 bypass_count += 1 | 279 bypass_count += 1 |
| 274 | 280 |
| 275 if bypass_count == 0: | 281 if bypass_count == 0: |
| 276 raise ChromeProxyMetricException, ( | 282 raise ChromeProxyMetricException, ( |
| 277 'Expected at least one response to be bypassed, but zero such ' | 283 'Expected at least one response to be bypassed, but zero such ' |
| 278 'responses were received.') | 284 'responses were received.') |
| 285 | |
| 279 results.AddValue(scalar.ScalarValue( | 286 results.AddValue(scalar.ScalarValue( |
| 280 results.current_page, 'bypass', 'count', bypass_count)) | 287 results.current_page, 'bypass', 'count', bypass_count)) |
| 288 results.AddValue(scalar.ScalarValue( | |
| 289 results.current_page, 'skipped', 'count', skipped_count)) | |
| 281 | 290 |
| 282 def AddResultsForCorsBypass(self, tab, results): | 291 def AddResultsForCorsBypass(self, tab, results): |
| 283 eligible_response_count = 0 | 292 eligible_response_count = 0 |
| 284 bypass_count = 0 | 293 bypass_count = 0 |
| 285 bypasses = {} | 294 bypasses = {} |
| 286 for resp in self.IterResponses(tab): | 295 for resp in self.IterResponses(tab): |
| 287 logging.warn('got a resource %s' % (resp.response.url)) | 296 logging.warn('got a resource %s' % (resp.response.url)) |
| 288 | 297 |
| 289 for resp in self.IterResponses(tab): | 298 for resp in self.IterResponses(tab): |
| 290 if resp.ShouldHaveChromeProxyViaHeader(): | 299 if resp.ShouldHaveChromeProxyViaHeader(): |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 via_count += 1 | 519 via_count += 1 |
| 511 if via_count == 0: | 520 if via_count == 0: |
| 512 raise ChromeProxyMetricException, ( | 521 raise ChromeProxyMetricException, ( |
| 513 'Expected at least one response through the proxy after the bypass ' | 522 'Expected at least one response through the proxy after the bypass ' |
| 514 'expired, but zero such responses were received.') | 523 'expired, but zero such responses were received.') |
| 515 | 524 |
| 516 results.AddValue(scalar.ScalarValue( | 525 results.AddValue(scalar.ScalarValue( |
| 517 results.current_page, 'bypass', 'count', bypass_count)) | 526 results.current_page, 'bypass', 'count', bypass_count)) |
| 518 results.AddValue(scalar.ScalarValue( | 527 results.AddValue(scalar.ScalarValue( |
| 519 results.current_page, 'via', 'count', via_count)) | 528 results.current_page, 'via', 'count', via_count)) |
| OLD | NEW |