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, ( |
| 284 '%s: Not a valid safe browsing response.\n' | 284 '%s: Not a valid safe browsing response.\n' |
| 285 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | 285 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( |
| 286 r.url, r.status, r.status_text, r.headers)) | 286 r.url, r.status, r.status_text, r.headers)) |
| 287 if count == safebrowsing_count: | 287 if count == safebrowsing_count: |
|
sclittle
2015/01/23 19:01:58
The for loop above already raises an exception if
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 288 results.AddValue(scalar.ScalarValue( | 288 results.AddValue(scalar.ScalarValue( |
| 289 results.current_page, 'safebrowsing', 'boolean', True)) | 289 results.current_page, 'safebrowsing', 'url requests', count)) |
|
sclittle
2015/01/23 19:01:58
For consistency, the units here for this ScalarVal
Not at Google. Contact bengr
2015/01/23 20:02:47
Discussed in person. Calling it 'count' everywhere
| |
| 290 else: | 290 else: |
| 291 raise ChromeProxyMetricException, ( | 291 raise ChromeProxyMetricException, ( |
| 292 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( | 292 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( |
|
sclittle
2015/01/23 19:01:58
nit: change this message to be more descriptive (e
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 293 count, safebrowsing_count)) | 293 count, safebrowsing_count)) |
| 294 | 294 |
| 295 def AddResultsForSafebrowsingDesktop(self, tab, results): | |
| 296 count = 0 | |
|
sclittle
2015/01/23 19:01:58
nit: maybe rename to response_count
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 297 viaheader_count = 0 | |
| 298 for resp in self.IterResponses(tab): | |
| 299 count += 1 | |
| 300 # For desktop, Flywheel should return the real response for sites with | |
|
sclittle
2015/01/23 19:01:57
s/Flywheel/the data reduction proxy/
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 301 # malware. | |
| 302 if resp.HasChromeProxyViaHeader(): | |
| 303 viaheader_count += 1 | |
| 304 else: | |
| 305 r = resp.response | |
| 306 raise ChromeProxyMetricException, ( | |
| 307 '%s: Safebrowsing feature should be off for desktop.\n' | |
| 308 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | |
| 309 r.url, r.status, r.status_text, r.headers)) | |
| 310 if count == viaheader_count: | |
|
sclittle
2015/01/23 19:01:58
This will always be true, because the for loop wou
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 311 results.AddValue(scalar.ScalarValue( | |
| 312 results.current_page, 'safebrowsing', 'url requests', count)) | |
|
sclittle
2015/01/23 19:01:58
Change the last two parameters to 'count' and safe
Not at Google. Contact bengr
2015/01/23 20:02:47
:)
| |
| 313 else: | |
| 314 raise ChromeProxyMetricException, ( | |
| 315 'Safebrowsing failed (count=%d, viaheader_count=%d)\n' % ( | |
|
sclittle
2015/01/23 19:01:58
Change this failure message to be more descriptive
Not at Google. Contact bengr
2015/01/23 20:02:47
Done.
| |
| 316 count, viaheader_count)) | |
| 317 | |
| 295 def AddResultsForHTTPFallback(self, tab, results): | 318 def AddResultsForHTTPFallback(self, tab, results): |
| 296 via_fallback_count = 0 | 319 via_fallback_count = 0 |
| 297 | 320 |
| 298 for resp in self.IterResponses(tab): | 321 for resp in self.IterResponses(tab): |
| 299 if resp.ShouldHaveChromeProxyViaHeader(): | 322 if resp.ShouldHaveChromeProxyViaHeader(): |
| 300 # All responses should have come through the HTTP fallback proxy, which | 323 # All responses should have come through the HTTP fallback proxy, which |
| 301 # means that they should have the via header, and if a remote port is | 324 # means that they should have the via header, and if a remote port is |
| 302 # defined, it should be port 80. | 325 # defined, it should be port 80. |
| 303 if (not resp.HasChromeProxyViaHeader() or | 326 if (not resp.HasChromeProxyViaHeader() or |
| 304 (resp.remote_port and resp.remote_port != 80)): | 327 (resp.remote_port and resp.remote_port != 80)): |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 'Response for %s should have via header; proxy should no longer ' | 435 'Response for %s should have via header; proxy should no longer ' |
| 413 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( | 436 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( |
| 414 r.url, r.status, r.status_text, r.headers)) | 437 r.url, r.status, r.status_text, r.headers)) |
| 415 else: | 438 else: |
| 416 via_count += 1 | 439 via_count += 1 |
| 417 | 440 |
| 418 results.AddValue(scalar.ScalarValue( | 441 results.AddValue(scalar.ScalarValue( |
| 419 results.current_page, 'bypass', 'count', bypass_count)) | 442 results.current_page, 'bypass', 'count', bypass_count)) |
| 420 results.AddValue(scalar.ScalarValue( | 443 results.AddValue(scalar.ScalarValue( |
| 421 results.current_page, 'via', 'count', via_count)) | 444 results.current_page, 'via', 'count', via_count)) |
| OLD | NEW |