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

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

Issue 1352233002: Returning scoped_ptr<> instead of raw pointer in DnsQuery::CloneWithNewId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/dns_query.h ('k') | net/dns/dns_query_unittest.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_query.h" 5 #include "net/dns/dns_query.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/big_endian.h" 9 #include "base/big_endian.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 25 matching lines...) Expand all
36 base::BigEndianWriter writer(reinterpret_cast<char*>(header + 1), 36 base::BigEndianWriter writer(reinterpret_cast<char*>(header + 1),
37 question_size); 37 question_size);
38 writer.WriteBytes(qname.data(), qname.size()); 38 writer.WriteBytes(qname.data(), qname.size());
39 writer.WriteU16(qtype); 39 writer.WriteU16(qtype);
40 writer.WriteU16(dns_protocol::kClassIN); 40 writer.WriteU16(dns_protocol::kClassIN);
41 } 41 }
42 42
43 DnsQuery::~DnsQuery() { 43 DnsQuery::~DnsQuery() {
44 } 44 }
45 45
46 DnsQuery* DnsQuery::CloneWithNewId(uint16 id) const { 46 scoped_ptr<DnsQuery> DnsQuery::CloneWithNewId(uint16 id) const {
47 return new DnsQuery(*this, id); 47 return make_scoped_ptr(new DnsQuery(*this, id));
48 } 48 }
49 49
50 uint16 DnsQuery::id() const { 50 uint16 DnsQuery::id() const {
51 const dns_protocol::Header* header = 51 const dns_protocol::Header* header =
52 reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data()); 52 reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data());
53 return base::NetToHost16(header->id); 53 return base::NetToHost16(header->id);
54 } 54 }
55 55
56 base::StringPiece DnsQuery::qname() const { 56 base::StringPiece DnsQuery::qname() const {
57 return base::StringPiece(io_buffer_->data() + sizeof(dns_protocol::Header), 57 return base::StringPiece(io_buffer_->data() + sizeof(dns_protocol::Header),
(...skipping 22 matching lines...) Expand all
80 header->id = base::HostToNet16(id); 80 header->id = base::HostToNet16(id);
81 } 81 }
82 82
83 void DnsQuery::set_flags(uint16 flags) { 83 void DnsQuery::set_flags(uint16 flags) {
84 dns_protocol::Header* header = 84 dns_protocol::Header* header =
85 reinterpret_cast<dns_protocol::Header*>(io_buffer_->data()); 85 reinterpret_cast<dns_protocol::Header*>(io_buffer_->data());
86 header->flags = flags; 86 header->flags = flags;
87 } 87 }
88 88
89 } // namespace net 89 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_query.h ('k') | net/dns/dns_query_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698