| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/base/layered_network_delegate.h" | 5 #include "net/base/layered_network_delegate.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "net/base/auth.h" | 15 #include "net/base/auth.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/base/network_delegate_impl.h" | 17 #include "net/base/network_delegate_impl.h" |
| 17 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 mutable CountersMap counters_; | 168 mutable CountersMap counters_; |
| 168 mutable CountersMap* layered_network_delegate_counters_; | 169 mutable CountersMap* layered_network_delegate_counters_; |
| 169 | 170 |
| 170 DISALLOW_COPY_AND_ASSIGN(TestNetworkDelegateImpl); | 171 DISALLOW_COPY_AND_ASSIGN(TestNetworkDelegateImpl); |
| 171 }; | 172 }; |
| 172 | 173 |
| 173 class TestLayeredNetworkDelegate : public LayeredNetworkDelegate { | 174 class TestLayeredNetworkDelegate : public LayeredNetworkDelegate { |
| 174 public: | 175 public: |
| 175 TestLayeredNetworkDelegate(scoped_ptr<NetworkDelegate> network_delegate, | 176 TestLayeredNetworkDelegate(scoped_ptr<NetworkDelegate> network_delegate, |
| 176 CountersMap* counters) | 177 CountersMap* counters) |
| 177 : LayeredNetworkDelegate(network_delegate.Pass()), | 178 : LayeredNetworkDelegate(std::move(network_delegate)), |
| 178 context_(true), | 179 context_(true), |
| 179 counters_(counters) { | 180 counters_(counters) { |
| 180 context_.Init(); | 181 context_.Init(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 ~TestLayeredNetworkDelegate() override {} | 184 ~TestLayeredNetworkDelegate() override {} |
| 184 | 185 |
| 185 void CallAndVerify() { | 186 void CallAndVerify() { |
| 186 scoped_refptr<AuthChallengeInfo> auth_challenge(new AuthChallengeInfo()); | 187 scoped_refptr<AuthChallengeInfo> auth_challenge(new AuthChallengeInfo()); |
| 187 scoped_ptr<URLRequest> request = | 188 scoped_ptr<URLRequest> request = |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 }; | 367 }; |
| 367 | 368 |
| 368 } // namespace | 369 } // namespace |
| 369 | 370 |
| 370 class LayeredNetworkDelegateTest : public testing::Test { | 371 class LayeredNetworkDelegateTest : public testing::Test { |
| 371 public: | 372 public: |
| 372 LayeredNetworkDelegateTest() { | 373 LayeredNetworkDelegateTest() { |
| 373 scoped_ptr<TestNetworkDelegateImpl> test_network_delegate( | 374 scoped_ptr<TestNetworkDelegateImpl> test_network_delegate( |
| 374 new TestNetworkDelegateImpl(&layered_network_delegate_counters)); | 375 new TestNetworkDelegateImpl(&layered_network_delegate_counters)); |
| 375 test_network_delegate_ = test_network_delegate.get(); | 376 test_network_delegate_ = test_network_delegate.get(); |
| 376 layered_network_delegate_ = | 377 layered_network_delegate_ = scoped_ptr<TestLayeredNetworkDelegate>( |
| 377 scoped_ptr<TestLayeredNetworkDelegate>(new TestLayeredNetworkDelegate( | 378 new TestLayeredNetworkDelegate(std::move(test_network_delegate), |
| 378 test_network_delegate.Pass(), &layered_network_delegate_counters)); | 379 &layered_network_delegate_counters)); |
| 379 } | 380 } |
| 380 | 381 |
| 381 CountersMap layered_network_delegate_counters; | 382 CountersMap layered_network_delegate_counters; |
| 382 TestNetworkDelegateImpl* test_network_delegate_; | 383 TestNetworkDelegateImpl* test_network_delegate_; |
| 383 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; | 384 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; |
| 384 }; | 385 }; |
| 385 | 386 |
| 386 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { | 387 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { |
| 387 layered_network_delegate_->CallAndVerify(); | 388 layered_network_delegate_->CallAndVerify(); |
| 388 } | 389 } |
| 389 | 390 |
| 390 } // namespace net | 391 } // namespace net |
| OLD | NEW |