| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 protected: | 198 protected: |
| 199 // testing::Test implementation. | 199 // testing::Test implementation. |
| 200 void SetUp() override { | 200 void SetUp() override { |
| 201 auto throttle = base::MakeUnique<TestURLLoaderThrottle>(); | 201 auto throttle = base::MakeUnique<TestURLLoaderThrottle>(); |
| 202 throttle_ = throttle.get(); | 202 throttle_ = throttle.get(); |
| 203 | 203 |
| 204 throttles_.push_back(std::move(throttle)); | 204 throttles_.push_back(std::move(throttle)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void CreateLoaderAndStart() { | 207 void CreateLoaderAndStart() { |
| 208 auto request = base::MakeUnique<ResourceRequest>(); | 208 ResourceRequest request; |
| 209 request->url = GURL("http://example.org"); | 209 request.url = GURL("http://example.org"); |
| 210 loader_ = ThrottlingURLLoader::CreateLoaderAndStart( | 210 loader_ = ThrottlingURLLoader::CreateLoaderAndStart( |
| 211 factory_.factory_ptr().get(), std::move(throttles_), 0, 0, 0, | 211 factory_.factory_ptr().get(), std::move(throttles_), 0, 0, 0, request, |
| 212 std::move(request), &client_); | 212 &client_); |
| 213 factory_.factory_ptr().FlushForTesting(); | 213 factory_.factory_ptr().FlushForTesting(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Be the first member so it is destroyed last. | 216 // Be the first member so it is destroyed last. |
| 217 base::MessageLoop message_loop_; | 217 base::MessageLoop message_loop_; |
| 218 | 218 |
| 219 std::unique_ptr<ThrottlingURLLoader> loader_; | 219 std::unique_ptr<ThrottlingURLLoader> loader_; |
| 220 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_; | 220 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_; |
| 221 | 221 |
| 222 TestURLLoaderFactory factory_; | 222 TestURLLoaderFactory factory_; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 EXPECT_EQ(0u, throttle_->will_redirect_request_called()); | 551 EXPECT_EQ(0u, throttle_->will_redirect_request_called()); |
| 552 EXPECT_EQ(1u, throttle_->will_process_response_called()); | 552 EXPECT_EQ(1u, throttle_->will_process_response_called()); |
| 553 | 553 |
| 554 EXPECT_EQ(0u, client_.on_received_response_called()); | 554 EXPECT_EQ(0u, client_.on_received_response_called()); |
| 555 EXPECT_EQ(0u, client_.on_received_redirect_called()); | 555 EXPECT_EQ(0u, client_.on_received_redirect_called()); |
| 556 EXPECT_EQ(1u, client_.on_complete_called()); | 556 EXPECT_EQ(1u, client_.on_complete_called()); |
| 557 } | 557 } |
| 558 | 558 |
| 559 } // namespace | 559 } // namespace |
| 560 } // namespace content | 560 } // namespace content |
| OLD | NEW |