| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" | 5 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 EXPECT_EQ(GURL("http://mobile.test.com"), recorder_entry.data_use().url()); | 207 EXPECT_EQ(GURL("http://mobile.test.com"), recorder_entry.data_use().url()); |
| 208 EXPECT_EQ(DataUse::TrafficType::USER_TRAFFIC, | 208 EXPECT_EQ(DataUse::TrafficType::USER_TRAFFIC, |
| 209 recorder_entry.data_use().traffic_type()); | 209 recorder_entry.data_use().traffic_type()); |
| 210 | 210 |
| 211 ascriber()->RenderFrameDeleted(kRenderProcessId, kRenderFrameId, -1, -1); | 211 ascriber()->RenderFrameDeleted(kRenderProcessId, kRenderFrameId, -1, -1); |
| 212 ascriber()->OnUrlRequestDestroyed(request.get()); | 212 ascriber()->OnUrlRequestDestroyed(request.get()); |
| 213 | 213 |
| 214 EXPECT_EQ(0u, recorders().size()); | 214 EXPECT_EQ(0u, recorders().size()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST_F(ChromeDataUseAscriberTest, FailedMainFrameNavigation) { |
| 218 if (content::IsBrowserSideNavigationEnabled()) |
| 219 return; |
| 220 |
| 221 std::unique_ptr<net::URLRequest> request = CreateNewRequest( |
| 222 "http://test.com", true, kRequestId, kRenderProcessId, kRenderFrameId); |
| 223 |
| 224 // Mainframe is created. |
| 225 ascriber()->RenderFrameCreated(kRenderProcessId, kRenderFrameId, -1, -1); |
| 226 EXPECT_EQ(1u, recorders().size()); |
| 227 |
| 228 // Request should cause a recorder to be created. |
| 229 ascriber()->OnBeforeUrlRequest(request.get()); |
| 230 EXPECT_EQ(2u, recorders().size()); |
| 231 |
| 232 // Failed request will remove the pending entry. |
| 233 request->Cancel(); |
| 234 ascriber()->OnUrlRequestCompleted(*request, false); |
| 235 |
| 236 ascriber()->RenderFrameDeleted(kRenderProcessId, kRenderFrameId, -1, -1); |
| 237 ascriber()->OnUrlRequestDestroyed(request.get()); |
| 238 |
| 239 EXPECT_EQ(0u, recorders().size()); |
| 240 } |
| 241 |
| 217 } // namespace data_use_measurement | 242 } // namespace data_use_measurement |
| OLD | NEW |