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 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <set> | 10 #include <set> |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
14 #include "base/prefs/testing_pref_service.h" | 18 #include "base/prefs/testing_pref_service.h" |
15 #include "base/test/histogram_tester.h" | 19 #include "base/test/histogram_tester.h" |
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 kFallbackHistogramName, test_cases[i].expected_fallback_sample, 1); | 323 kFallbackHistogramName, test_cases[i].expected_fallback_sample, 1); |
320 } | 324 } |
321 } | 325 } |
322 } | 326 } |
323 | 327 |
324 TEST_F(DataReductionProxyBypassStatsTest, RecordMissingViaHeaderBytes) { | 328 TEST_F(DataReductionProxyBypassStatsTest, RecordMissingViaHeaderBytes) { |
325 const std::string k4xxHistogramName = | 329 const std::string k4xxHistogramName = |
326 "DataReductionProxy.MissingViaHeader.Bytes.4xx"; | 330 "DataReductionProxy.MissingViaHeader.Bytes.4xx"; |
327 const std::string kOtherHistogramName = | 331 const std::string kOtherHistogramName = |
328 "DataReductionProxy.MissingViaHeader.Bytes.Other"; | 332 "DataReductionProxy.MissingViaHeader.Bytes.Other"; |
329 const int64 kResponseContentLength = 100; | 333 const int64_t kResponseContentLength = 100; |
330 | 334 |
331 struct TestCase { | 335 struct TestCase { |
332 bool was_proxy_used; | 336 bool was_proxy_used; |
333 const char* headers; | 337 const char* headers; |
334 bool is_4xx_sample_expected; | 338 bool is_4xx_sample_expected; |
335 bool is_other_sample_expected; | 339 bool is_other_sample_expected; |
336 }; | 340 }; |
337 const TestCase test_cases[] = { | 341 const TestCase test_cases[] = { |
338 // Nothing should be recorded for requests that don't use the proxy. | 342 // Nothing should be recorded for requests that don't use the proxy. |
339 { | 343 { |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 histogram_tester.ExpectUniqueSample( | 942 histogram_tester.ExpectUniqueSample( |
939 "DataReductionProxy.BypassedBytes.NetworkErrorOther", kBody.size(), 1); | 943 "DataReductionProxy.BypassedBytes.NetworkErrorOther", kBody.size(), 1); |
940 ExpectOtherBypassedBytesHistogramsEmpty( | 944 ExpectOtherBypassedBytesHistogramsEmpty( |
941 histogram_tester, "DataReductionProxy.BypassedBytes.NetworkErrorOther"); | 945 histogram_tester, "DataReductionProxy.BypassedBytes.NetworkErrorOther"); |
942 histogram_tester.ExpectUniqueSample( | 946 histogram_tester.ExpectUniqueSample( |
943 "DataReductionProxy.BypassOnNetworkErrorPrimary", | 947 "DataReductionProxy.BypassOnNetworkErrorPrimary", |
944 -net::ERR_PROXY_CONNECTION_FAILED, 1); | 948 -net::ERR_PROXY_CONNECTION_FAILED, 1); |
945 } | 949 } |
946 | 950 |
947 } // namespace data_reduction_proxy | 951 } // namespace data_reduction_proxy |
OLD | NEW |