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/dns/dns_transaction.h" | 5 #include "net/dns/dns_transaction.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/sys_byteorder.h" | 18 #include "base/sys_byteorder.h" |
19 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
20 #include "net/base/ip_address.h" | 20 #include "net/base/ip_address.h" |
21 #include "net/dns/dns_protocol.h" | 21 #include "net/dns/dns_protocol.h" |
22 #include "net/dns/dns_query.h" | 22 #include "net/dns/dns_query.h" |
23 #include "net/dns/dns_response.h" | 23 #include "net/dns/dns_response.h" |
24 #include "net/dns/dns_session.h" | 24 #include "net/dns/dns_session.h" |
25 #include "net/dns/dns_test_util.h" | 25 #include "net/dns/dns_test_util.h" |
26 #include "net/dns/dns_util.h" | 26 #include "net/dns/dns_util.h" |
tfarina
2016/10/03 15:29:11
Can you foward declare? The parameter looks unused
mikecirone
2016/10/03 17:33:29
The include is needed. I spotted a NetLogWithSourc
| |
27 #include "net/log/net_log.h" | 27 #include "net/log/net_log_with_source.h" |
28 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
29 #include "net/test/gtest_util.h" | 29 #include "net/test/gtest_util.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
33 using net::test::IsOk; | 33 using net::test::IsOk; |
34 | 34 |
35 namespace net { | 35 namespace net { |
36 | 36 |
37 class NetLog; | |
38 | |
37 namespace { | 39 namespace { |
38 | 40 |
39 std::string DomainFromDot(const base::StringPiece& dotted) { | 41 std::string DomainFromDot(const base::StringPiece& dotted) { |
40 std::string out; | 42 std::string out; |
41 EXPECT_TRUE(DNSDomainFromDot(dotted, &out)); | 43 EXPECT_TRUE(DNSDomainFromDot(dotted, &out)); |
42 return out; | 44 return out; |
43 } | 45 } |
44 | 46 |
45 // A SocketDataProvider builder. | 47 // A SocketDataProvider builder. |
46 class DnsSocketData { | 48 class DnsSocketData { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect. | 190 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect. |
189 class TestSocketFactory : public MockClientSocketFactory { | 191 class TestSocketFactory : public MockClientSocketFactory { |
190 public: | 192 public: |
191 TestSocketFactory() : fail_next_socket_(false) {} | 193 TestSocketFactory() : fail_next_socket_(false) {} |
192 ~TestSocketFactory() override {} | 194 ~TestSocketFactory() override {} |
193 | 195 |
194 std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( | 196 std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
195 DatagramSocket::BindType bind_type, | 197 DatagramSocket::BindType bind_type, |
196 const RandIntCallback& rand_int_cb, | 198 const RandIntCallback& rand_int_cb, |
197 NetLog* net_log, | 199 NetLog* net_log, |
198 const NetLog::Source& source) override { | 200 const NetLogSource& source) override { |
199 if (fail_next_socket_) { | 201 if (fail_next_socket_) { |
200 fail_next_socket_ = false; | 202 fail_next_socket_ = false; |
201 return std::unique_ptr<DatagramClientSocket>( | 203 return std::unique_ptr<DatagramClientSocket>( |
202 new FailingUDPClientSocket(&empty_data_, net_log)); | 204 new FailingUDPClientSocket(&empty_data_, net_log)); |
203 } | 205 } |
204 SocketDataProvider* data_provider = mock_data().GetNext(); | 206 SocketDataProvider* data_provider = mock_data().GetNext(); |
205 std::unique_ptr<TestUDPClientSocket> socket( | 207 std::unique_ptr<TestUDPClientSocket> socket( |
206 new TestUDPClientSocket(this, data_provider, net_log)); | 208 new TestUDPClientSocket(this, data_provider, net_log)); |
207 return std::move(socket); | 209 return std::move(socket); |
208 } | 210 } |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
996 config_.timeout = TestTimeouts::tiny_timeout(); | 998 config_.timeout = TestTimeouts::tiny_timeout(); |
997 ConfigureFactory(); | 999 ConfigureFactory(); |
998 | 1000 |
999 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); | 1001 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); |
1000 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); | 1002 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); |
1001 } | 1003 } |
1002 | 1004 |
1003 } // namespace | 1005 } // namespace |
1004 | 1006 |
1005 } // namespace net | 1007 } // namespace net |
OLD | NEW |