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

Side by Side Diff: base/pickle.h

Issue 19642005: Make TracedValue lower overhead. Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added pickle unit test, cleaned up traced value's unit tests. Created 7 years, 4 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
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 16 matching lines...) Expand all
27 // the Pickle, create a PickleIterator from a Pickle. If successful, these 27 // the Pickle, create a PickleIterator from a Pickle. If successful, these
28 // methods return true. Otherwise, false is returned to indicate that the 28 // methods return true. Otherwise, false is returned to indicate that the
29 // result could not be extracted. 29 // result could not be extracted.
30 bool ReadBool(bool* result) WARN_UNUSED_RESULT; 30 bool ReadBool(bool* result) WARN_UNUSED_RESULT;
31 bool ReadInt(int* result) WARN_UNUSED_RESULT; 31 bool ReadInt(int* result) WARN_UNUSED_RESULT;
32 bool ReadLong(long* result) WARN_UNUSED_RESULT; 32 bool ReadLong(long* result) WARN_UNUSED_RESULT;
33 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; 33 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT;
34 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; 34 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT;
35 bool ReadInt64(int64* result) WARN_UNUSED_RESULT; 35 bool ReadInt64(int64* result) WARN_UNUSED_RESULT;
36 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT; 36 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT;
37 bool ReadUIntPtr(uintptr_t* result) WARN_UNUSED_RESULT;
37 bool ReadFloat(float* result) WARN_UNUSED_RESULT; 38 bool ReadFloat(float* result) WARN_UNUSED_RESULT;
38 bool ReadString(std::string* result) WARN_UNUSED_RESULT; 39 bool ReadString(std::string* result) WARN_UNUSED_RESULT;
39 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; 40 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT;
40 bool ReadString16(string16* result) WARN_UNUSED_RESULT; 41 bool ReadString16(string16* result) WARN_UNUSED_RESULT;
41 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; 42 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT;
42 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; 43 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT;
43 44
44 // Safer version of ReadInt() checks for the result not being negative. 45 // Safer version of ReadInt() checks for the result not being negative.
45 // Use it for reading the object sizes. 46 // Use it for reading the object sizes.
46 bool ReadLength(int* result) WARN_UNUSED_RESULT { 47 bool ReadLength(int* result) WARN_UNUSED_RESULT {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 153 }
153 bool ReadUInt32(PickleIterator* iter, uint32* result) const { 154 bool ReadUInt32(PickleIterator* iter, uint32* result) const {
154 return iter->ReadUInt32(result); 155 return iter->ReadUInt32(result);
155 } 156 }
156 bool ReadInt64(PickleIterator* iter, int64* result) const { 157 bool ReadInt64(PickleIterator* iter, int64* result) const {
157 return iter->ReadInt64(result); 158 return iter->ReadInt64(result);
158 } 159 }
159 bool ReadUInt64(PickleIterator* iter, uint64* result) const { 160 bool ReadUInt64(PickleIterator* iter, uint64* result) const {
160 return iter->ReadUInt64(result); 161 return iter->ReadUInt64(result);
161 } 162 }
163 bool ReadUIntPtr(PickleIterator* iter, uintptr_t* result) const {
164 return iter->ReadUIntPtr(result);
165 }
162 bool ReadFloat(PickleIterator* iter, float* result) const { 166 bool ReadFloat(PickleIterator* iter, float* result) const {
163 return iter->ReadFloat(result); 167 return iter->ReadFloat(result);
164 } 168 }
165 bool ReadString(PickleIterator* iter, std::string* result) const { 169 bool ReadString(PickleIterator* iter, std::string* result) const {
166 return iter->ReadString(result); 170 return iter->ReadString(result);
167 } 171 }
168 bool ReadWString(PickleIterator* iter, std::wstring* result) const { 172 bool ReadWString(PickleIterator* iter, std::wstring* result) const {
169 return iter->ReadWString(result); 173 return iter->ReadWString(result);
170 } 174 }
171 bool ReadString16(PickleIterator* iter, string16* result) const { 175 bool ReadString16(PickleIterator* iter, string16* result) const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 219 }
216 bool WriteUInt32(uint32 value) { 220 bool WriteUInt32(uint32 value) {
217 return WriteBytes(&value, sizeof(value)); 221 return WriteBytes(&value, sizeof(value));
218 } 222 }
219 bool WriteInt64(int64 value) { 223 bool WriteInt64(int64 value) {
220 return WriteBytes(&value, sizeof(value)); 224 return WriteBytes(&value, sizeof(value));
221 } 225 }
222 bool WriteUInt64(uint64 value) { 226 bool WriteUInt64(uint64 value) {
223 return WriteBytes(&value, sizeof(value)); 227 return WriteBytes(&value, sizeof(value));
224 } 228 }
229 bool WriteUIntPtr(uintptr_t value) {
230 return WriteBytes(&value, sizeof(value));
231 }
225 bool WriteFloat(float value) { 232 bool WriteFloat(float value) {
226 return WriteBytes(&value, sizeof(value)); 233 return WriteBytes(&value, sizeof(value));
227 } 234 }
228 bool WriteString(const std::string& value); 235 bool WriteString(const std::string& value);
229 bool WriteWString(const std::wstring& value); 236 bool WriteWString(const std::wstring& value);
230 bool WriteString16(const string16& value); 237 bool WriteString16(const string16& value);
231 // "Data" is a blob with a length. When you read it out you will be given the 238 // "Data" is a blob with a length. When you read it out you will be given the
232 // length. See also WriteBytes. 239 // length. See also WriteBytes.
233 bool WriteData(const char* data, int length); 240 bool WriteData(const char* data, int length);
234 // "Bytes" is a blob with no length. The caller must specify the lenght both 241 // "Bytes" is a blob with no length. The caller must specify the lenght both
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Allocation size of payload (or -1 if allocation is const). 345 // Allocation size of payload (or -1 if allocation is const).
339 size_t capacity_; 346 size_t capacity_;
340 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 347 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
341 348
342 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 349 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
343 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 350 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
344 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); 351 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
345 }; 352 };
346 353
347 #endif // BASE_PICKLE_H__ 354 #endif // BASE_PICKLE_H__
OLDNEW
« base/debug/traced_object.h ('K') | « base/json/json_writer.cc ('k') | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698