| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/sys_byteorder.h" |
| 11 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 12 #include "net/base/big_endian.h" | 13 #include "net/base/big_endian.h" |
| 13 #include "net/base/dns_util.h" | 14 #include "net/base/dns_util.h" |
| 14 #include "net/base/net_log.h" | 15 #include "net/base/net_log.h" |
| 15 #include "net/base/sys_addrinfo.h" | 16 #include "net/base/sys_addrinfo.h" |
| 16 #include "net/dns/dns_protocol.h" | 17 #include "net/dns/dns_protocol.h" |
| 17 #include "net/dns/dns_query.h" | 18 #include "net/dns/dns_query.h" |
| 18 #include "net/dns/dns_response.h" | 19 #include "net/dns/dns_response.h" |
| 19 #include "net/dns/dns_session.h" | 20 #include "net/dns/dns_session.h" |
| 20 #include "net/dns/dns_test_util.h" | 21 #include "net/dns/dns_test_util.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 CHECK_NE(dns_protocol::kRcodeNOERROR, rcode); | 273 CHECK_NE(dns_protocol::kRcodeNOERROR, rcode); |
| 273 uint16 id = base::RandInt(0, kuint16max); | 274 uint16 id = base::RandInt(0, kuint16max); |
| 274 DnsQuery* query = new DnsQuery(id, DomainFromDot(dotted_name), qtype); | 275 DnsQuery* query = new DnsQuery(id, DomainFromDot(dotted_name), qtype); |
| 275 queries_.push_back(query); | 276 queries_.push_back(query); |
| 276 | 277 |
| 277 DnsResponse* response = new DnsResponse(query->io_buffer()->data(), | 278 DnsResponse* response = new DnsResponse(query->io_buffer()->data(), |
| 278 query->io_buffer()->size(), | 279 query->io_buffer()->size(), |
| 279 0); | 280 0); |
| 280 dns_protocol::Header* header = | 281 dns_protocol::Header* header = |
| 281 reinterpret_cast<dns_protocol::Header*>(response->io_buffer()->data()); | 282 reinterpret_cast<dns_protocol::Header*>(response->io_buffer()->data()); |
| 282 header->flags |= htons(dns_protocol::kFlagResponse | rcode); | 283 header->flags |= base::HostToNet16(dns_protocol::kFlagResponse | rcode); |
| 283 responses_.push_back(response); | 284 responses_.push_back(response); |
| 284 | 285 |
| 285 writes_.push_back(MockWrite(ASYNC, | 286 writes_.push_back(MockWrite(ASYNC, |
| 286 query->io_buffer()->data(), | 287 query->io_buffer()->data(), |
| 287 query->io_buffer()->size())); | 288 query->io_buffer()->size())); |
| 288 reads_.push_back(MockRead(ASYNC, | 289 reads_.push_back(MockRead(ASYNC, |
| 289 response->io_buffer()->data(), | 290 response->io_buffer()->data(), |
| 290 query->io_buffer()->size())); | 291 query->io_buffer()->size())); |
| 291 transaction_ids_.push_back(id); | 292 transaction_ids_.push_back(id); |
| 292 } | 293 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 PrepareSockets(); | 709 PrepareSockets(); |
| 709 | 710 |
| 710 TransactionHelper helper0("x.y.z", dns_protocol::kTypeA, 0 /* answers */); | 711 TransactionHelper helper0("x.y.z", dns_protocol::kTypeA, 0 /* answers */); |
| 711 | 712 |
| 712 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); | 713 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); |
| 713 } | 714 } |
| 714 | 715 |
| 715 } // namespace | 716 } // namespace |
| 716 | 717 |
| 717 } // namespace net | 718 } // namespace net |
| 718 | |
| OLD | NEW |