| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 CHECK_NE(dns_protocol::kRcodeNOERROR, rcode); | 275 CHECK_NE(dns_protocol::kRcodeNOERROR, rcode); |
| 275 uint16 id = base::RandInt(0, kuint16max); | 276 uint16 id = base::RandInt(0, kuint16max); |
| 276 DnsQuery* query = new DnsQuery(id, DomainFromDot(dotted_name), qtype); | 277 DnsQuery* query = new DnsQuery(id, DomainFromDot(dotted_name), qtype); |
| 277 queries_.push_back(query); | 278 queries_.push_back(query); |
| 278 | 279 |
| 279 DnsResponse* response = new DnsResponse(query->io_buffer()->data(), | 280 DnsResponse* response = new DnsResponse(query->io_buffer()->data(), |
| 280 query->io_buffer()->size(), | 281 query->io_buffer()->size(), |
| 281 0); | 282 0); |
| 282 dns_protocol::Header* header = | 283 dns_protocol::Header* header = |
| 283 reinterpret_cast<dns_protocol::Header*>(response->io_buffer()->data()); | 284 reinterpret_cast<dns_protocol::Header*>(response->io_buffer()->data()); |
| 284 header->flags |= htons(dns_protocol::kFlagResponse | rcode); | 285 header->flags |= base::HostToNet16(dns_protocol::kFlagResponse | rcode); |
| 285 responses_.push_back(response); | 286 responses_.push_back(response); |
| 286 | 287 |
| 287 writes_.push_back(MockWrite(ASYNC, | 288 writes_.push_back(MockWrite(ASYNC, |
| 288 query->io_buffer()->data(), | 289 query->io_buffer()->data(), |
| 289 query->io_buffer()->size())); | 290 query->io_buffer()->size())); |
| 290 reads_.push_back(MockRead(ASYNC, | 291 reads_.push_back(MockRead(ASYNC, |
| 291 response->io_buffer()->data(), | 292 response->io_buffer()->data(), |
| 292 query->io_buffer()->size())); | 293 query->io_buffer()->size())); |
| 293 transaction_ids_.push_back(id); | 294 transaction_ids_.push_back(id); |
| 294 } | 295 } |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 675 |
| 675 TransactionHelper helper2("x", | 676 TransactionHelper helper2("x", |
| 676 dns_protocol::kTypeA, | 677 dns_protocol::kTypeA, |
| 677 ERR_NAME_NOT_RESOLVED); | 678 ERR_NAME_NOT_RESOLVED); |
| 678 EXPECT_TRUE(helper2.Run(transaction_factory_.get())); | 679 EXPECT_TRUE(helper2.Run(transaction_factory_.get())); |
| 679 } | 680 } |
| 680 | 681 |
| 681 } // namespace | 682 } // namespace |
| 682 | 683 |
| 683 } // namespace net | 684 } // namespace net |
| 684 | |
| OLD | NEW |