OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 825 |
826 virtual void OnCompleted(ResolveRequest* resolve) { | 826 virtual void OnCompleted(ResolveRequest* resolve) { |
827 EXPECT_EQ("a", resolve->hostname()); | 827 EXPECT_EQ("a", resolve->hostname()); |
828 EXPECT_EQ(80, resolve->port()); | 828 EXPECT_EQ(80, resolve->port()); |
829 | 829 |
830 // Deletes the host resolver. | 830 // Deletes the host resolver. |
831 host_resolver_.reset(); | 831 host_resolver_.reset(); |
832 | 832 |
833 // Quit after returning from OnCompleted (to give it a chance at | 833 // Quit after returning from OnCompleted (to give it a chance at |
834 // incorrectly running the cancelled tasks). | 834 // incorrectly running the cancelled tasks). |
835 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 835 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
836 } | 836 } |
837 | 837 |
838 private: | 838 private: |
839 scoped_ptr<HostResolver> host_resolver_; | 839 scoped_ptr<HostResolver> host_resolver_; |
840 DISALLOW_COPY_AND_ASSIGN(DeleteWithinCallbackVerifier); | 840 DISALLOW_COPY_AND_ASSIGN(DeleteWithinCallbackVerifier); |
841 }; | 841 }; |
842 | 842 |
843 TEST_F(HostResolverImplTest, DeleteWithinCallback) { | 843 TEST_F(HostResolverImplTest, DeleteWithinCallback) { |
844 // Use a capturing resolver_proc, since the verifier needs to know what calls | 844 // Use a capturing resolver_proc, since the verifier needs to know what calls |
845 // reached Resolver(). Also, the capturing resolver_proc is initially | 845 // reached Resolver(). Also, the capturing resolver_proc is initially |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 resolver_proc->WaitForAllAttemptsToFinish(TimeDelta::FromMilliseconds(60000)); | 1558 resolver_proc->WaitForAllAttemptsToFinish(TimeDelta::FromMilliseconds(60000)); |
1559 MessageLoop::current()->RunAllPending(); | 1559 MessageLoop::current()->RunAllPending(); |
1560 | 1560 |
1561 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts); | 1561 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts); |
1562 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve); | 1562 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve); |
1563 } | 1563 } |
1564 | 1564 |
1565 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1565 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. |
1566 | 1566 |
1567 } // namespace net | 1567 } // namespace net |
OLD | NEW |