Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
index db7e028e99f864c66be81f4bf3dff57784c686d6..9e5dd7fae8b76b1b4aea2b7892ba6447f9487cd9 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
@@ -242,7 +242,8 @@ class TestLoFiDecider : public LoFiDecider { |
std::string header_value; |
if (headers.GetHeader(chrome_proxy_accept_transform_header(), |
&header_value)) { |
- return header_value == empty_image_directive(); |
+ return header_value == empty_image_directive() || |
+ header_value == lite_page_directive(); |
} |
return false; |
} |
@@ -2164,6 +2165,89 @@ TEST_F(DataReductionProxyNetworkDelegateClientLoFiTest, DataSavingsThroughDRP) { |
GetSavings()); |
} |
+TEST_F(DataReductionProxyNetworkDelegateTest, TestAcceptTransformHistogram) { |
+ Init(USE_INSECURE_PROXY, false); |
+ base::HistogramTester histogram_tester; |
+ |
+ // Verify lite page request. |
+ net::HttpRequestHeaders request_headers; |
+ request_headers.SetHeader("chrome-proxy-accept-transform", "lite-page"); |
+ FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0); |
+ histogram_tester.ExpectTotalCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", 1); |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", |
+ 0 /* ACCEPT_LITE_PAGE_SENT */, 1); |
+ // Check legacy histogram too: |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.LoFi.TransformationType", |
+ NO_TRANSFORMATION_LITE_PAGE_REQUESTED, 1); |
+ |
+ // Verify empty image request. |
+ request_headers.SetHeader("chrome-proxy-accept-transform", "empty-image"); |
+ FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0); |
+ histogram_tester.ExpectTotalCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", 2); |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", |
+ 3 /* ACCEPT_EMPTY_IMAGE_SENT */, 1); |
+ |
+ // Verify lite page response. |
+ std::string response_headers = |
+ "HTTP/1.1 200 OK\r\n" |
+ "Chrome-Proxy-Content-Transform: lite-page\r\n" |
+ "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" |
+ "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\r\n" |
+ "x-original-content-length: 200\r\n" |
+ "\r\n"; |
+ auto request = |
+ FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); |
+ EXPECT_TRUE(DataReductionProxyData::GetData(*request)->lite_page_received()); |
+ histogram_tester.ExpectTotalCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", 3); |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", |
+ 1 /* TRANSFORM_LITE_PAGE_RECEIVED */, 1); |
+ // Check legacy histogram too: |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.LoFi.TransformationType", LITE_PAGE, 1); |
+ |
+ // Verify page policy response. |
+ response_headers = |
+ "HTTP/1.1 200 OK\r\n" |
+ "Chrome-Proxy: page-policies=empty-image\r\n" |
+ "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" |
+ "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\r\n" |
+ "x-original-content-length: 200\r\n" |
+ "\r\n"; |
+ request = FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); |
+ EXPECT_FALSE(DataReductionProxyData::GetData(*request)->lite_page_received()); |
+ histogram_tester.ExpectTotalCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", 4); |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", |
+ 2 /* POLICY_EMPTY_IMAGE_RECEIVED */, 1); |
+ |
+ // Verify empty image response. |
+ response_headers = |
+ "HTTP/1.1 200 OK\r\n" |
+ "Chrome-Proxy-Content-Transform: empty-image\r\n" |
+ "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" |
+ "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\r\n" |
+ "x-original-content-length: 200\r\n" |
+ "\r\n"; |
+ request = FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); |
+ EXPECT_TRUE(DataReductionProxyData::GetData(*request)->lofi_received()); |
+ histogram_tester.ExpectTotalCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", 5); |
+ histogram_tester.ExpectBucketCount( |
+ "DataReductionProxy.Protocol.AcceptTransform", |
+ 4 /* TRANSFORM_EMPTY_IMAGE_RECEIVED */, 1); |
+} |
+ |
} // namespace |
} // namespace data_reduction_proxy |