Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: net/dns/dns_transaction_unittest.cc

Issue 1147903003: Subsituting pattern ScopedVector push_back.(ptr.release()) with push_back(ptr.Pass()) in net/dns (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/address_sorter_posix.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 29 matching lines...) Expand all
40 IoMode mode, 40 IoMode mode,
41 bool use_tcp) 41 bool use_tcp)
42 : query_(new DnsQuery(id, DomainFromDot(dotted_name), qtype)), 42 : query_(new DnsQuery(id, DomainFromDot(dotted_name), qtype)),
43 use_tcp_(use_tcp) { 43 use_tcp_(use_tcp) {
44 if (use_tcp_) { 44 if (use_tcp_) {
45 scoped_ptr<uint16> length(new uint16); 45 scoped_ptr<uint16> length(new uint16);
46 *length = base::HostToNet16(query_->io_buffer()->size()); 46 *length = base::HostToNet16(query_->io_buffer()->size());
47 writes_.push_back(MockWrite(mode, 47 writes_.push_back(MockWrite(mode,
48 reinterpret_cast<const char*>(length.get()), 48 reinterpret_cast<const char*>(length.get()),
49 sizeof(uint16), num_reads_and_writes())); 49 sizeof(uint16), num_reads_and_writes()));
50 lengths_.push_back(length.release()); 50 lengths_.push_back(length.Pass());
51 } 51 }
52 writes_.push_back(MockWrite(mode, query_->io_buffer()->data(), 52 writes_.push_back(MockWrite(mode, query_->io_buffer()->data(),
53 query_->io_buffer()->size(), 53 query_->io_buffer()->size(),
54 num_reads_and_writes())); 54 num_reads_and_writes()));
55 } 55 }
56 ~DnsSocketData() {} 56 ~DnsSocketData() {}
57 57
58 // All responses must be added before GetProvider. 58 // All responses must be added before GetProvider.
59 59
60 // Adds pre-built DnsResponse. |tcp_length| will be used in TCP mode only. 60 // Adds pre-built DnsResponse. |tcp_length| will be used in TCP mode only.
61 void AddResponseWithLength(scoped_ptr<DnsResponse> response, IoMode mode, 61 void AddResponseWithLength(scoped_ptr<DnsResponse> response, IoMode mode,
62 uint16 tcp_length) { 62 uint16 tcp_length) {
63 CHECK(!provider_.get()); 63 CHECK(!provider_.get());
64 if (use_tcp_) { 64 if (use_tcp_) {
65 scoped_ptr<uint16> length(new uint16); 65 scoped_ptr<uint16> length(new uint16);
66 *length = base::HostToNet16(tcp_length); 66 *length = base::HostToNet16(tcp_length);
67 reads_.push_back(MockRead(mode, 67 reads_.push_back(MockRead(mode,
68 reinterpret_cast<const char*>(length.get()), 68 reinterpret_cast<const char*>(length.get()),
69 sizeof(uint16), num_reads_and_writes())); 69 sizeof(uint16), num_reads_and_writes()));
70 lengths_.push_back(length.release()); 70 lengths_.push_back(length.Pass());
71 } 71 }
72 reads_.push_back(MockRead(mode, response->io_buffer()->data(), 72 reads_.push_back(MockRead(mode, response->io_buffer()->data(),
73 response->io_buffer()->size(), 73 response->io_buffer()->size(),
74 num_reads_and_writes())); 74 num_reads_and_writes()));
75 responses_.push_back(response.release()); 75 responses_.push_back(response.Pass());
76 } 76 }
77 77
78 // Adds pre-built DnsResponse. 78 // Adds pre-built DnsResponse.
79 void AddResponse(scoped_ptr<DnsResponse> response, IoMode mode) { 79 void AddResponse(scoped_ptr<DnsResponse> response, IoMode mode) {
80 uint16 tcp_length = response->io_buffer()->size(); 80 uint16 tcp_length = response->io_buffer()->size();
81 AddResponseWithLength(response.Pass(), mode, tcp_length); 81 AddResponseWithLength(response.Pass(), mode, tcp_length);
82 } 82 }
83 83
84 // Adds pre-built response from |data| buffer. 84 // Adds pre-built response from |data| buffer.
85 void AddResponseData(const uint8* data, size_t length, IoMode mode) { 85 void AddResponseData(const uint8* data, size_t length, IoMode mode) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 DnsSocketPool::CreateNull(socket_factory_.get()), 352 DnsSocketPool::CreateNull(socket_factory_.get()),
353 base::Bind(&DnsTransactionTest::GetNextId, base::Unretained(this)), 353 base::Bind(&DnsTransactionTest::GetNextId, base::Unretained(this)),
354 NULL /* NetLog */); 354 NULL /* NetLog */);
355 transaction_factory_ = DnsTransactionFactory::CreateFactory(session_.get()); 355 transaction_factory_ = DnsTransactionFactory::CreateFactory(session_.get());
356 } 356 }
357 357
358 void AddSocketData(scoped_ptr<DnsSocketData> data) { 358 void AddSocketData(scoped_ptr<DnsSocketData> data) {
359 CHECK(socket_factory_.get()); 359 CHECK(socket_factory_.get());
360 transaction_ids_.push_back(data->query_id()); 360 transaction_ids_.push_back(data->query_id());
361 socket_factory_->AddSocketDataProvider(data->GetProvider()); 361 socket_factory_->AddSocketDataProvider(data->GetProvider());
362 socket_data_.push_back(data.release()); 362 socket_data_.push_back(data.Pass());
363 } 363 }
364 364
365 // Add expected query for |dotted_name| and |qtype| with |id| and response 365 // Add expected query for |dotted_name| and |qtype| with |id| and response
366 // taken verbatim from |data| of |data_length| bytes. The transaction id in 366 // taken verbatim from |data| of |data_length| bytes. The transaction id in
367 // |data| should equal |id|, unless testing mismatched response. 367 // |data| should equal |id|, unless testing mismatched response.
368 void AddQueryAndResponse(uint16 id, 368 void AddQueryAndResponse(uint16 id,
369 const char* dotted_name, 369 const char* dotted_name,
370 uint16 qtype, 370 uint16 qtype,
371 const uint8* response_data, 371 const uint8* response_data,
372 size_t response_length, 372 size_t response_length,
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 config_.timeout = TestTimeouts::tiny_timeout(); 1004 config_.timeout = TestTimeouts::tiny_timeout();
1005 ConfigureFactory(); 1005 ConfigureFactory();
1006 1006
1007 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); 1007 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT);
1008 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 1008 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
1009 } 1009 }
1010 1010
1011 } // namespace 1011 } // namespace
1012 1012
1013 } // namespace net 1013 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/address_sorter_posix.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698