| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 net::StaticSocketDataProvider socket_data(reads, arraysize(reads), nullptr, | 49 net::StaticSocketDataProvider socket_data(reads, arraysize(reads), nullptr, |
| 50 0); | 50 0); |
| 51 socket_factory_->AddSocketDataProvider(&socket_data); | 51 socket_factory_->AddSocketDataProvider(&socket_data); |
| 52 | 52 |
| 53 std::unique_ptr<net::URLRequest> request(context_->CreateRequest( | 53 std::unique_ptr<net::URLRequest> request(context_->CreateRequest( |
| 54 GURL("http://foo.com"), net::DEFAULT_PRIORITY, &test_delegate)); | 54 GURL("http://foo.com"), net::DEFAULT_PRIORITY, &test_delegate)); |
| 55 if (is_user_request) { | 55 if (is_user_request) { |
| 56 request->SetUserData( | 56 request->SetUserData( |
| 57 data_use_measurement::DataUseUserData::kUserDataKey, | 57 data_use_measurement::DataUseUserData::kUserDataKey, |
| 58 new data_use_measurement::DataUseUserData( | 58 new data_use_measurement::DataUseUserData( |
| 59 data_use_measurement::DataUseUserData::SUGGESTIONS)); | 59 data_use_measurement::DataUseUserData::SUGGESTIONS, |
| 60 data_use_measurement_.CurrentAppState() == |
| 61 DataUseMeasurement::FOREGROUND)); |
| 60 } else { | 62 } else { |
| 61 content::ResourceRequestInfo::AllocateForTesting( | 63 content::ResourceRequestInfo::AllocateForTesting( |
| 62 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, | 64 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, |
| 63 true, false, true, true, false); | 65 true, false, true, true, false); |
| 64 } | 66 } |
| 65 | 67 |
| 66 request->Start(); | 68 request->Start(); |
| 67 base::RunLoop().RunUntilIdle(); | 69 base::RunLoop().RunUntilIdle(); |
| 68 | 70 |
| 69 data_use_measurement_.OnCompleted(*request, true); | 71 data_use_measurement_.OnCompleted(*request, true); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 161 } |
| 160 #endif | 162 #endif |
| 161 | 163 |
| 162 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) { | 164 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) { |
| 163 EXPECT_FALSE(IsDataUseForwarderCalled()); | 165 EXPECT_FALSE(IsDataUseForwarderCalled()); |
| 164 SendRequest(true); | 166 SendRequest(true); |
| 165 EXPECT_TRUE(IsDataUseForwarderCalled()); | 167 EXPECT_TRUE(IsDataUseForwarderCalled()); |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace data_use_measurement | 170 } // namespace data_use_measurement |
| OLD | NEW |