| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/common/throttling_url_loader.h" | 5 #include "content/common/throttling_url_loader.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/common/url_loader.mojom.h" | 10 #include "content/common/url_loader.mojom.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 protected: | 201 protected: |
| 202 // testing::Test implementation. | 202 // testing::Test implementation. |
| 203 void SetUp() override { | 203 void SetUp() override { |
| 204 auto throttle = base::MakeUnique<TestURLLoaderThrottle>(); | 204 auto throttle = base::MakeUnique<TestURLLoaderThrottle>(); |
| 205 throttle_ = throttle.get(); | 205 throttle_ = throttle.get(); |
| 206 | 206 |
| 207 throttles_.push_back(std::move(throttle)); | 207 throttles_.push_back(std::move(throttle)); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void CreateLoaderAndStart() { | 210 void CreateLoaderAndStart() { |
| 211 auto request = base::MakeUnique<ResourceRequest>(); | 211 ResourceRequest request; |
| 212 request->url = GURL("http://example.org"); | 212 request.url = GURL("http://example.org"); |
| 213 loader_ = ThrottlingURLLoader::CreateLoaderAndStart( | 213 loader_ = ThrottlingURLLoader::CreateLoaderAndStart( |
| 214 factory_.factory_ptr().get(), std::move(throttles_), 0, 0, 0, | 214 factory_.factory_ptr().get(), std::move(throttles_), 0, 0, 0, request, |
| 215 std::move(request), &client_, | 215 &client_, |
| 216 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS)); | 216 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS)); |
| 217 factory_.factory_ptr().FlushForTesting(); | 217 factory_.factory_ptr().FlushForTesting(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 // Be the first member so it is destroyed last. | 220 // Be the first member so it is destroyed last. |
| 221 base::MessageLoop message_loop_; | 221 base::MessageLoop message_loop_; |
| 222 | 222 |
| 223 std::unique_ptr<ThrottlingURLLoader> loader_; | 223 std::unique_ptr<ThrottlingURLLoader> loader_; |
| 224 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_; | 224 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_; |
| 225 | 225 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 EXPECT_EQ(0u, throttle_->will_redirect_request_called()); | 555 EXPECT_EQ(0u, throttle_->will_redirect_request_called()); |
| 556 EXPECT_EQ(1u, throttle_->will_process_response_called()); | 556 EXPECT_EQ(1u, throttle_->will_process_response_called()); |
| 557 | 557 |
| 558 EXPECT_EQ(0u, client_.on_received_response_called()); | 558 EXPECT_EQ(0u, client_.on_received_response_called()); |
| 559 EXPECT_EQ(0u, client_.on_received_redirect_called()); | 559 EXPECT_EQ(0u, client_.on_received_redirect_called()); |
| 560 EXPECT_EQ(1u, client_.on_complete_called()); | 560 EXPECT_EQ(1u, client_.on_complete_called()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 } // namespace | 563 } // namespace |
| 564 } // namespace content | 564 } // namespace content |
| OLD | NEW |