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

Side by Side Diff: cloud_print/gcp20/prototype/dns_packet_parser.cc

Issue 145873006: ui/base/resource: Roll our own version of ReadBigEndian() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cloud_print/gcp20/prototype/dns_packet_parser.h" 5 #include "cloud_print/gcp20/prototype/dns_packet_parser.h"
6 6
7 #include "net/base/big_endian.h" 7 #include "base/big_endian.h"
8 8
9 DnsPacketParser::DnsPacketParser(const char* packet, size_t length) 9 DnsPacketParser::DnsPacketParser(const char* packet, size_t length)
10 : packet_(packet), 10 : packet_(packet),
11 length_(length), 11 length_(length),
12 record_parser_(packet, length, sizeof(header_)) { 12 record_parser_(packet, length, sizeof(header_)) {
13 net::BigEndianReader reader(packet, length); 13 base::BigEndianReader reader(packet, length);
14 is_header_read_ = reader.ReadU16(&header_.id) && 14 is_header_read_ = reader.ReadU16(&header_.id) &&
15 reader.ReadU16(&header_.flags) && 15 reader.ReadU16(&header_.flags) &&
16 reader.ReadU16(&header_.qdcount) && 16 reader.ReadU16(&header_.qdcount) &&
17 reader.ReadU16(&header_.ancount) && 17 reader.ReadU16(&header_.ancount) &&
18 reader.ReadU16(&header_.nscount) && 18 reader.ReadU16(&header_.nscount) &&
19 reader.ReadU16(&header_.arcount); 19 reader.ReadU16(&header_.arcount);
20 } 20 }
21 21
22 bool DnsPacketParser::ReadRecord(DnsQueryRecord* out) { 22 bool DnsPacketParser::ReadRecord(DnsQueryRecord* out) {
23 DCHECK(packet_); 23 DCHECK(packet_);
24 DnsQueryRecord result; 24 DnsQueryRecord result;
25 size_t consumed = ReadName(&result.qname); 25 size_t consumed = ReadName(&result.qname);
26 if (!consumed) 26 if (!consumed)
27 return false; 27 return false;
28 net::BigEndianReader reader(packet_ + GetOffset() + consumed, 28 base::BigEndianReader reader(packet_ + GetOffset() + consumed,
29 length_ - (GetOffset() + consumed)); 29 length_ - (GetOffset() + consumed));
30 if (reader.ReadU16(&result.qtype) && reader.ReadU16(&result.qclass) && 30 if (reader.ReadU16(&result.qtype) && reader.ReadU16(&result.qclass) &&
31 record_parser_.SkipQuestion()) { // instead of |cur_ = reader.ptr();| 31 record_parser_.SkipQuestion()) { // instead of |cur_ = reader.ptr();|
32 *out = result; 32 *out = result;
33 return true; 33 return true;
34 } 34 }
35 35
36 return false; 36 return false;
37 } 37 }
38 38
OLDNEW
« no previous file with comments | « chrome/utility/cloud_print/pwg_encoder.cc ('k') | cloud_print/gcp20/prototype/dns_response_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698