| 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 e80b933ab9e93f0ba690aae0dd53614c0e346f49..dba17a0559f50d23adc33892e5834b191a9d7510 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 /* LITE_PAGE_REQUESTED */, 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 /* EMPTY_IMAGE_REQUESTED */, 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 /* LITE_PAGE_TRANSFORM_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 /* EMPTY_IMAGE_POLICY_DIRECTIVE_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 /* EMPTY_IMAGE_TRANSFORM_RECEIVED */, 1);
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace data_reduction_proxy
|
|
|