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

Side by Side Diff: base/big_endian.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
« no previous file with comments | « base/big_endian.h ('k') | base/big_endian_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/big_endian.h" 5 #include "base/big_endian.h"
6 6
7 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 8
9 namespace net { 9 namespace base {
10 10
11 BigEndianReader::BigEndianReader(const void* buf, size_t len) 11 BigEndianReader::BigEndianReader(const char* buf, size_t len)
12 : ptr_(reinterpret_cast<const char*>(buf)), end_(ptr_ + len) {} 12 : ptr_(buf), end_(ptr_ + len) {}
13 13
14 bool BigEndianReader::Skip(size_t len) { 14 bool BigEndianReader::Skip(size_t len) {
15 if (ptr_ + len > end_) 15 if (ptr_ + len > end_)
16 return false; 16 return false;
17 ptr_ += len; 17 ptr_ += len;
18 return true; 18 return true;
19 } 19 }
20 20
21 bool BigEndianReader::ReadBytes(void* out, size_t len) { 21 bool BigEndianReader::ReadBytes(void* out, size_t len) {
22 if (ptr_ + len > end_) 22 if (ptr_ + len > end_)
(...skipping 25 matching lines...) Expand all
48 } 48 }
49 49
50 bool BigEndianReader::ReadU16(uint16* value) { 50 bool BigEndianReader::ReadU16(uint16* value) {
51 return Read(value); 51 return Read(value);
52 } 52 }
53 53
54 bool BigEndianReader::ReadU32(uint32* value) { 54 bool BigEndianReader::ReadU32(uint32* value) {
55 return Read(value); 55 return Read(value);
56 } 56 }
57 57
58 BigEndianWriter::BigEndianWriter(void* buf, size_t len) 58 BigEndianWriter::BigEndianWriter(char* buf, size_t len)
59 : ptr_(reinterpret_cast<char*>(buf)), end_(ptr_ + len) {} 59 : ptr_(buf), end_(ptr_ + len) {}
60 60
61 bool BigEndianWriter::Skip(size_t len) { 61 bool BigEndianWriter::Skip(size_t len) {
62 if (ptr_ + len > end_) 62 if (ptr_ + len > end_)
63 return false; 63 return false;
64 ptr_ += len; 64 ptr_ += len;
65 return true; 65 return true;
66 } 66 }
67 67
68 bool BigEndianWriter::WriteBytes(const void* buf, size_t len) { 68 bool BigEndianWriter::WriteBytes(const void* buf, size_t len) {
69 if (ptr_ + len > end_) 69 if (ptr_ + len > end_)
(...skipping 17 matching lines...) Expand all
87 } 87 }
88 88
89 bool BigEndianWriter::WriteU16(uint16 value) { 89 bool BigEndianWriter::WriteU16(uint16 value) {
90 return Write(value); 90 return Write(value);
91 } 91 }
92 92
93 bool BigEndianWriter::WriteU32(uint32 value) { 93 bool BigEndianWriter::WriteU32(uint32 value) {
94 return Write(value); 94 return Write(value);
95 } 95 }
96 96
97 } // namespace net 97 } // namespace base
98
OLDNEW
« no previous file with comments | « base/big_endian.h ('k') | base/big_endian_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698