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 integration_tests import network_metrics | 8 from integration_tests import network_metrics |
| 9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
| 10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 'Exactly one response should be bypassed. ' | 263 'Exactly one response should be bypassed. ' |
| 264 '(eligible_response_count=%d, bypass_count=%d)\n' % ( | 264 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| 265 eligible_response_count, bypass_count)) | 265 eligible_response_count, bypass_count)) |
| 266 else: | 266 else: |
| 267 results.AddValue(scalar.ScalarValue( | 267 results.AddValue(scalar.ScalarValue( |
| 268 results.current_page, 'eligible_responses', 'count', | 268 results.current_page, 'eligible_responses', 'count', |
| 269 eligible_response_count)) | 269 eligible_response_count)) |
| 270 results.AddValue(scalar.ScalarValue( | 270 results.AddValue(scalar.ScalarValue( |
| 271 results.current_page, 'bypass', 'count', bypass_count)) | 271 results.current_page, 'bypass', 'count', bypass_count)) |
| 272 | 272 |
| 273 def AddResultsForSafebrowsing(self, tab, results): | 273 def AddResultsForSafebrowsingMobile(self, tab, results): |
| 274 count = 0 | 274 count = 0 |
| 275 safebrowsing_count = 0 | 275 safebrowsing_count = 0 |
| 276 | 276 |
| 277 for resp in self.IterResponses(tab): | 277 for resp in self.IterResponses(tab): |
| 278 count += 1 | 278 count += 1 |
| 279 if resp.IsSafebrowsingResponse(): | 279 if resp.IsSafebrowsingResponse(): |
| 280 safebrowsing_count += 1 | 280 safebrowsing_count += 1 |
| 281 else: | 281 else: |
| 282 r = resp.response | 282 r = resp.response |
| 283 raise ChromeProxyMetricException, ( | 283 raise ChromeProxyMetricException, ( |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 303 if (not resp.HasChromeProxyViaHeader() or | 303 if (not resp.HasChromeProxyViaHeader() or |
| 304 (resp.remote_port and resp.remote_port != 80)): | 304 (resp.remote_port and resp.remote_port != 80)): |
| 305 r = resp.response | 305 r = resp.response |
| 306 raise ChromeProxyMetricException, ( | 306 raise ChromeProxyMetricException, ( |
| 307 '%s: Should have come through the fallback proxy.\n' | 307 '%s: Should have come through the fallback proxy.\n' |
| 308 'Reponse: remote_port=%s status=(%d, %s)\nHeaders:\n %s' % ( | 308 'Reponse: remote_port=%s status=(%d, %s)\nHeaders:\n %s' % ( |
| 309 r.url, str(resp.remote_port), r.status, r.status_text, | 309 r.url, str(resp.remote_port), r.status, r.status_text, |
| 310 r.headers)) | 310 r.headers)) |
| 311 via_fallback_count += 1 | 311 via_fallback_count += 1 |
| 312 | 312 |
| 313 results.AddValue(scalar.ScalarValue( | 313 def AddResultsForSafebrowsingDesktop(self, tab, results): |
|
sclittle
2015/01/22 23:15:14
Move this method definition up above AddResultsFor
Not at Google. Contact bengr
2015/01/23 17:11:34
Done.
| |
| 314 results.current_page, 'via_fallback', 'count', via_fallback_count)) | 314 count = 0 |
| 315 safebrowsing_count = 0 | |
| 316 for resp in self.IterResponses(tab): | |
|
sclittle
2015/01/22 23:15:14
What do you actually expect to happen here? Should
Not at Google. Contact bengr
2015/01/23 17:11:34
Done.
| |
| 317 count += 1 | |
| 318 if resp.HasChromeProxyViaHeader(): | |
| 319 safebrowsing_count += 1 | |
|
sclittle
2015/01/22 23:15:14
Why is this called safebrowsing_count if you're co
Not at Google. Contact bengr
2015/01/23 17:11:34
Changed to viaheader_count. Had originally kept it
| |
| 320 else: | |
| 321 r = resp.response | |
| 322 raise ChromeProxyMetricException, ( | |
| 323 '%s: Safebrowsing feature should be off for desktop.\n' | |
| 324 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | |
| 325 r.url, r.status, r.status_text, r.headers)) | |
| 326 if count == safebrowsing_count: | |
| 327 results.AddValue(scalar.ScalarValue( | |
| 328 results.current_page, 'safebrowsing', 'boolean', True)) | |
|
sclittle
2015/01/22 23:15:14
Instead of just a boolean, how about adding both c
Not at Google. Contact bengr
2015/01/23 17:11:34
Done. Added count. safebrowsing_count is redundant
| |
| 329 else: | |
| 330 raise ChromeProxyMetricException, ( | |
| 331 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( | |
| 332 count, safebrowsing_count)) | |
| 315 | 333 |
| 316 def AddResultsForHTTPToDirectFallback(self, tab, results): | 334 def AddResultsForHTTPToDirectFallback(self, tab, results): |
| 317 via_fallback_count = 0 | 335 via_fallback_count = 0 |
| 318 bypass_count = 0 | 336 bypass_count = 0 |
| 319 responses = self.IterResponses(tab) | 337 responses = self.IterResponses(tab) |
| 320 | 338 |
| 321 # The very first response should be through the HTTP fallback proxy. | 339 # The very first response should be through the HTTP fallback proxy. |
| 322 fallback_resp = next(responses, None) | 340 fallback_resp = next(responses, None) |
| 323 if not fallback_resp: | 341 if not fallback_resp: |
| 324 raise ChromeProxyMetricException, 'There should be at least one response.' | 342 raise ChromeProxyMetricException, 'There should be at least one response.' |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 'Response for %s should have via header; proxy should no longer ' | 430 'Response for %s should have via header; proxy should no longer ' |
| 413 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( | 431 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( |
| 414 r.url, r.status, r.status_text, r.headers)) | 432 r.url, r.status, r.status_text, r.headers)) |
| 415 else: | 433 else: |
| 416 via_count += 1 | 434 via_count += 1 |
| 417 | 435 |
| 418 results.AddValue(scalar.ScalarValue( | 436 results.AddValue(scalar.ScalarValue( |
| 419 results.current_page, 'bypass', 'count', bypass_count)) | 437 results.current_page, 'bypass', 'count', bypass_count)) |
| 420 results.AddValue(scalar.ScalarValue( | 438 results.AddValue(scalar.ScalarValue( |
| 421 results.current_page, 'via', 'count', via_count)) | 439 results.current_page, 'via', 'count', via_count)) |
| OLD | NEW |