OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/stl_util.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
16 #include "base/synchronization/condition_variable.h" | 17 #include "base/synchronization/condition_variable.h" |
17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
18 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "net/base/address_list.h" | 21 #include "net/base/address_list.h" |
21 #include "net/base/completion_callback.h" | 22 #include "net/base/completion_callback.h" |
22 #include "net/base/host_cache.h" | 23 #include "net/base/host_cache.h" |
23 #include "net/base/mock_host_resolver.h" | 24 #include "net/base/mock_host_resolver.h" |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 914 |
914 EXPECT_TRUE(resolver_proc->WaitFor(kMaxJobs + 1)); | 915 EXPECT_TRUE(resolver_proc->WaitFor(kMaxJobs + 1)); |
915 EXPECT_EQ(0u, delegate.num_completions()); | 916 EXPECT_EQ(0u, delegate.num_completions()); |
916 | 917 |
917 resolver_proc->SignalAll(); | 918 resolver_proc->SignalAll(); |
918 | 919 |
919 while (delegate.num_completions() < 2) | 920 while (delegate.num_completions() < 2) |
920 MessageLoop::current()->Run(); | 921 MessageLoop::current()->Run(); |
921 | 922 |
922 MessageLoop::current()->AssertIdle(); | 923 MessageLoop::current()->AssertIdle(); |
| 924 |
| 925 STLDeleteElements(&requests); |
923 } | 926 } |
924 | 927 |
925 // Helper class used by HostResolverImplTest.CancelWithinCallback. | 928 // Helper class used by HostResolverImplTest.CancelWithinCallback. |
926 class CancelWithinCallbackVerifier : public ResolveRequest::Delegate { | 929 class CancelWithinCallbackVerifier : public ResolveRequest::Delegate { |
927 public: | 930 public: |
928 CancelWithinCallbackVerifier() | 931 CancelWithinCallbackVerifier() |
929 : req_to_cancel1_(NULL), req_to_cancel2_(NULL), num_completions_(0) { | 932 : req_to_cancel1_(NULL), req_to_cancel2_(NULL), num_completions_(0) { |
930 } | 933 } |
931 | 934 |
932 virtual void OnCompleted(ResolveRequest* resolve) OVERRIDE { | 935 virtual void OnCompleted(ResolveRequest* resolve) OVERRIDE { |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 resolver_proc->WaitForAllAttemptsToFinish(TimeDelta::FromMilliseconds(60000)); | 1740 resolver_proc->WaitForAllAttemptsToFinish(TimeDelta::FromMilliseconds(60000)); |
1738 MessageLoop::current()->RunAllPending(); | 1741 MessageLoop::current()->RunAllPending(); |
1739 | 1742 |
1740 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts); | 1743 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts); |
1741 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve); | 1744 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve); |
1742 } | 1745 } |
1743 | 1746 |
1744 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1747 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. |
1745 | 1748 |
1746 } // namespace net | 1749 } // namespace net |
OLD | NEW |