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

Side by Side Diff: base/pickle.h

Issue 9641005: Remove Pickle::WriteSize() now that it has no remaining callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « no previous file | base/pickle.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 #ifndef BASE_PICKLE_H__ 5 #ifndef BASE_PICKLE_H__
6 #define BASE_PICKLE_H__ 6 #define BASE_PICKLE_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 13 matching lines...) Expand all
24 PickleIterator() : read_ptr_(NULL), read_end_ptr_(NULL) {} 24 PickleIterator() : read_ptr_(NULL), read_end_ptr_(NULL) {}
25 explicit PickleIterator(const Pickle& pickle); 25 explicit PickleIterator(const Pickle& pickle);
26 26
27 // Methods for reading the payload of the Pickle. To read from the start of 27 // Methods for reading the payload of the Pickle. To read from the start of
28 // the Pickle, create a PickleIterator from a Pickle. If successful, these 28 // the Pickle, create a PickleIterator from a Pickle. If successful, these
29 // methods return true. Otherwise, false is returned to indicate that the 29 // methods return true. Otherwise, false is returned to indicate that the
30 // result could not be extracted. 30 // result could not be extracted.
31 bool ReadBool(bool* result) WARN_UNUSED_RESULT; 31 bool ReadBool(bool* result) WARN_UNUSED_RESULT;
32 bool ReadInt(int* result) WARN_UNUSED_RESULT; 32 bool ReadInt(int* result) WARN_UNUSED_RESULT;
33 bool ReadLong(long* result) WARN_UNUSED_RESULT; 33 bool ReadLong(long* result) WARN_UNUSED_RESULT;
34 bool ReadSize(size_t* result) WARN_UNUSED_RESULT;
35 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; 34 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT;
36 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; 35 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT;
37 bool ReadInt64(int64* result) WARN_UNUSED_RESULT; 36 bool ReadInt64(int64* result) WARN_UNUSED_RESULT;
38 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT; 37 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT;
39 bool ReadString(std::string* result) WARN_UNUSED_RESULT; 38 bool ReadString(std::string* result) WARN_UNUSED_RESULT;
40 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; 39 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT;
41 bool ReadString16(string16* result) WARN_UNUSED_RESULT; 40 bool ReadString16(string16* result) WARN_UNUSED_RESULT;
42 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; 41 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT;
43 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; 42 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT;
44 43
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // TODO(jbates) Remove these methods. 140 // TODO(jbates) Remove these methods.
142 bool ReadBool(PickleIterator* iter, bool* result) const { 141 bool ReadBool(PickleIterator* iter, bool* result) const {
143 return iter->ReadBool(result); 142 return iter->ReadBool(result);
144 } 143 }
145 bool ReadInt(PickleIterator* iter, int* result) const { 144 bool ReadInt(PickleIterator* iter, int* result) const {
146 return iter->ReadInt(result); 145 return iter->ReadInt(result);
147 } 146 }
148 bool ReadLong(PickleIterator* iter, long* result) const { 147 bool ReadLong(PickleIterator* iter, long* result) const {
149 return iter->ReadLong(result); 148 return iter->ReadLong(result);
150 } 149 }
151 bool ReadSize(PickleIterator* iter, size_t* result) const {
152 return iter->ReadSize(result);
153 }
154 bool ReadUInt16(PickleIterator* iter, uint16* result) const { 150 bool ReadUInt16(PickleIterator* iter, uint16* result) const {
155 return iter->ReadUInt16(result); 151 return iter->ReadUInt16(result);
156 } 152 }
157 bool ReadUInt32(PickleIterator* iter, uint32* result) const { 153 bool ReadUInt32(PickleIterator* iter, uint32* result) const {
158 return iter->ReadUInt32(result); 154 return iter->ReadUInt32(result);
159 } 155 }
160 bool ReadInt64(PickleIterator* iter, int64* result) const { 156 bool ReadInt64(PickleIterator* iter, int64* result) const {
161 return iter->ReadInt64(result); 157 return iter->ReadInt64(result);
162 } 158 }
163 bool ReadUInt64(PickleIterator* iter, uint64* result) const { 159 bool ReadUInt64(PickleIterator* iter, uint64* result) const {
(...skipping 24 matching lines...) Expand all
188 // Methods for adding to the payload of the Pickle. These values are 184 // Methods for adding to the payload of the Pickle. These values are
189 // appended to the end of the Pickle's payload. When reading values from a 185 // appended to the end of the Pickle's payload. When reading values from a
190 // Pickle, it is important to read them in the order in which they were added 186 // Pickle, it is important to read them in the order in which they were added
191 // to the Pickle. 187 // to the Pickle.
192 bool WriteBool(bool value) { 188 bool WriteBool(bool value) {
193 return WriteInt(value ? 1 : 0); 189 return WriteInt(value ? 1 : 0);
194 } 190 }
195 bool WriteInt(int value) { 191 bool WriteInt(int value) {
196 return WriteBytes(&value, sizeof(value)); 192 return WriteBytes(&value, sizeof(value));
197 } 193 }
194 // WARNING: DO NOT USE WriteLong() IF PICKLES ARE PERSISTED IN ANY WAY.
195 // WriteLong() writes whatever a "long" is on this architecture. On 32-bit
196 // platforms, it is 32 bits. On 64-bit platforms, it is 64 bits. If persisted
197 // pickles are still around after upgrading to 64-bit, or if they are copied
198 // between dissimilar systems, YOUR PICKLES WILL HAVE GONE BAD.
jar (doing other things) 2012/03/22 21:08:57 How about changing the name to something that clar
Mike Mammarella 2012/03/22 21:30:52 I took a look and it turns out that WriteLong() is
198 bool WriteLong(long value) { 199 bool WriteLong(long value) {
199 return WriteBytes(&value, sizeof(value)); 200 return WriteBytes(&value, sizeof(value));
200 } 201 }
201 bool WriteSize(size_t value) {
202 return WriteBytes(&value, sizeof(value));
203 }
204 bool WriteUInt16(uint16 value) { 202 bool WriteUInt16(uint16 value) {
205 return WriteBytes(&value, sizeof(value)); 203 return WriteBytes(&value, sizeof(value));
206 } 204 }
207 bool WriteUInt32(uint32 value) { 205 bool WriteUInt32(uint32 value) {
208 return WriteBytes(&value, sizeof(value)); 206 return WriteBytes(&value, sizeof(value));
209 } 207 }
210 bool WriteInt64(int64 value) { 208 bool WriteInt64(int64 value) {
211 return WriteBytes(&value, sizeof(value)); 209 return WriteBytes(&value, sizeof(value));
212 } 210 }
213 bool WriteUInt64(uint64 value) { 211 bool WriteUInt64(uint64 value) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // Allocation size of payload (or -1 if allocation is const). 321 // Allocation size of payload (or -1 if allocation is const).
324 size_t capacity_; 322 size_t capacity_;
325 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 323 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
326 324
327 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 325 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
328 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 326 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
329 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); 327 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
330 }; 328 };
331 329
332 #endif // BASE_PICKLE_H__ 330 #endif // BASE_PICKLE_H__
OLDNEW
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698