| 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 os | 6 import os |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from common import chrome_proxy_metrics | 9 from common import chrome_proxy_metrics |
| 10 from common import network_metrics | 10 from common import network_metrics |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 if resp.HasExtraViaHeader(extra_via_header): | 163 if resp.HasExtraViaHeader(extra_via_header): |
| 164 extra_via_count += 1 | 164 extra_via_count += 1 |
| 165 else: | 165 else: |
| 166 raise ChromeProxyMetricException, ( | 166 raise ChromeProxyMetricException, ( |
| 167 '%s: Should have via header %s.' % (resp.response.url, | 167 '%s: Should have via header %s.' % (resp.response.url, |
| 168 extra_via_header)) | 168 extra_via_header)) |
| 169 | 169 |
| 170 results.AddValue(scalar.ScalarValue( | 170 results.AddValue(scalar.ScalarValue( |
| 171 results.current_page, 'extra_via_header', 'count', extra_via_count)) | 171 results.current_page, 'extra_via_header', 'count', extra_via_count)) |
| 172 | 172 |
| 173 def AddResultsForClientVersion(self, tab, results): | |
| 174 via_count = 0 | |
| 175 for resp in self.IterResponses(tab): | |
| 176 r = resp.response | |
| 177 if resp.response.status != 200: | |
| 178 raise ChromeProxyMetricException, ('%s: Response is not 200: %d' % | |
| 179 (r.url, r.status)) | |
| 180 if not resp.IsValidByViaHeader(): | |
| 181 raise ChromeProxyMetricException, ('%s: Response missing via header' % | |
| 182 (r.url)) | |
| 183 via_count += 1 | |
| 184 | |
| 185 if via_count == 0: | |
| 186 raise ChromeProxyMetricException, ( | |
| 187 'Expected at least one response through the proxy, but zero such ' | |
| 188 'responses were received.') | |
| 189 results.AddValue(scalar.ScalarValue( | |
| 190 results.current_page, 'responses_via_proxy', 'count', via_count)) | |
| 191 | |
| 192 def GetClientTypeFromRequests(self, tab): | 173 def GetClientTypeFromRequests(self, tab): |
| 193 """Get the Chrome-Proxy client type value from requests made in this tab. | 174 """Get the Chrome-Proxy client type value from requests made in this tab. |
| 194 | 175 |
| 195 Returns: | 176 Returns: |
| 196 The client type value from the first request made in this tab that | 177 The client type value from the first request made in this tab that |
| 197 specifies a client type in the Chrome-Proxy request header. See | 178 specifies a client type in the Chrome-Proxy request header. See |
| 198 ChromeProxyResponse.GetChromeProxyClientType for more details about the | 179 ChromeProxyResponse.GetChromeProxyClientType for more details about the |
| 199 Chrome-Proxy client type. Returns None if none of the requests made in | 180 Chrome-Proxy client type. Returns None if none of the requests made in |
| 200 this tab specify a client type. | 181 this tab specify a client type. |
| 201 """ | 182 """ |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 except KeyError: | 889 except KeyError: |
| 909 raise ChromeProxyMetricException, 'No metrics found' | 890 raise ChromeProxyMetricException, 'No metrics found' |
| 910 | 891 |
| 911 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been | 892 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been |
| 912 # configured to always return block-once for these URLs. | 893 # configured to always return block-once for these URLs. |
| 913 def IsTestUrlForBlockOnce(url): | 894 def IsTestUrlForBlockOnce(url): |
| 914 return (url == 'http://check.googlezip.net/blocksingle/' or | 895 return (url == 'http://check.googlezip.net/blocksingle/' or |
| 915 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' | 896 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' |
| 916 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' | 897 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' |
| 917 'dfQ==&respStatus=200&flywheelAction=block-once')) | 898 'dfQ==&respStatus=200&flywheelAction=block-once')) |
| OLD | NEW |