| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_use_measurement/content/data_use_measurement.h" | 5 #include "components/data_use_measurement/content/data_use_measurement.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 data_use_measurement::DataUseUserData::SUGGESTIONS)); | 58 data_use_measurement::DataUseUserData::SUGGESTIONS)); |
| 59 } else { | 59 } else { |
| 60 content::ResourceRequestInfo::AllocateForTesting( | 60 content::ResourceRequestInfo::AllocateForTesting( |
| 61 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, | 61 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, |
| 62 true, false, true, true, false); | 62 true, false, true, true, false); |
| 63 } | 63 } |
| 64 | 64 |
| 65 request->Start(); | 65 request->Start(); |
| 66 loop_.RunUntilIdle(); | 66 loop_.RunUntilIdle(); |
| 67 | 67 |
| 68 data_use_measurement_.ReportDataUseUMA(request.get()); | 68 data_use_measurement_.OnCompleted(*request, true); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // This function makes a user request and confirms that its effect is | 71 // This function makes a user request and confirms that its effect is |
| 72 // reflected in proper histograms. | 72 // reflected in proper histograms. |
| 73 void TestForAUserRequest(const std::string& target_dimension) { | 73 void TestForAUserRequest(const std::string& target_dimension) { |
| 74 base::HistogramTester histogram_tester; | 74 base::HistogramTester histogram_tester; |
| 75 SendRequest(true); | 75 SendRequest(true); |
| 76 histogram_tester.ExpectTotalCount("DataUse.TrafficSize.System.Downstream." + | 76 histogram_tester.ExpectTotalCount("DataUse.TrafficSize.System.Downstream." + |
| 77 target_dimension + kConnectionType, | 77 target_dimension + kConnectionType, |
| 78 1); | 78 1); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 #endif | 159 #endif |
| 160 | 160 |
| 161 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) { | 161 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) { |
| 162 EXPECT_FALSE(IsDataUseForwarderCalled()); | 162 EXPECT_FALSE(IsDataUseForwarderCalled()); |
| 163 SendRequest(true); | 163 SendRequest(true); |
| 164 EXPECT_TRUE(IsDataUseForwarderCalled()); | 164 EXPECT_TRUE(IsDataUseForwarderCalled()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace data_use_measurement | 167 } // namespace data_use_measurement |
| OLD | NEW |