Index: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
index 8857a56e4cff95393360195f389fa1e3a96bc157..a20c23edd7b554e5b2d60470e434a4223720e4b2 100644 |
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
@@ -270,27 +270,44 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
results.AddValue(scalar.ScalarValue( |
results.current_page, 'bypass', 'count', bypass_count)) |
- def AddResultsForSafebrowsing(self, tab, results): |
- count = 0 |
- safebrowsing_count = 0 |
- |
+ def AddResultsForSafebrowsingMobile(self, tab, results): |
+ response_count = 0 |
for resp in self.IterResponses(tab): |
- count += 1 |
- if resp.IsSafebrowsingResponse(): |
- safebrowsing_count += 1 |
- else: |
+ response_count += 1 |
+ if not resp.IsSafebrowsingResponse(): |
r = resp.response |
raise ChromeProxyMetricException, ( |
'%s: Not a valid safe browsing response.\n' |
'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( |
r.url, r.status, r.status_text, r.headers)) |
- if count == safebrowsing_count: |
- results.AddValue(scalar.ScalarValue( |
- results.current_page, 'safebrowsing', 'boolean', True)) |
- else: |
+ |
+ if response_count == 0: |
raise ChromeProxyMetricException, ( |
- 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( |
- count, safebrowsing_count)) |
+ 'Safebrowsing failed: No valid responses received)\n') |
sclittle
2015/01/23 20:06:46
nit: remove ')\n' from the end
Not at Google. Contact bengr
2015/01/23 22:56:00
Done.
|
+ |
+ results.AddValue(scalar.ScalarValue( |
+ results.current_page, 'safebrowsing', 'responses', response_count)) |
+ |
+ |
+ def AddResultsForSafebrowsingDesktop(self, tab, results): |
+ response_count = 0 |
+ for resp in self.IterResponses(tab): |
+ # For desktop, data reduction proxy should return the real response for |
+ # sites with malware. |
+ response_count += 1 |
+ if not resp.HasChromeProxyViaHeader(): |
+ r = resp.response |
+ raise ChromeProxyMetricException, ( |
+ '%s: Safebrowsing feature should be off for desktop.\n' |
+ 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( |
+ r.url, r.status, r.status_text, r.headers)) |
+ |
+ if response_count == 0: |
+ raise ChromeProxyMetricException, ( |
+ 'Safebrowsing failed: No valid responses received\n') |
sclittle
2015/01/23 20:06:46
nit: remove '\n' from the end
Not at Google. Contact bengr
2015/01/23 22:56:00
Done.
|
+ |
+ results.AddValue(scalar.ScalarValue( |
+ results.current_page, 'safebrowsing', 'responses', response_count)) |
def AddResultsForHTTPFallback(self, tab, results): |
via_fallback_count = 0 |