Add Pickle::Read/WriteUint64.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/297011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30320 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/pickle.cc b/base/pickle.cc
index 0be89c2..be76cf5a 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -6,8 +6,8 @@
#include <stdlib.h>
+#include <algorithm> // for max()
#include <limits>
-#include <string>
//------------------------------------------------------------------------------
@@ -181,6 +181,20 @@
return true;
}
+bool Pickle::ReadUInt64(void** iter, uint64* result) const {
+ DCHECK(iter);
+ if (!*iter)
+ *iter = const_cast<char*>(payload());
+
+ if (!IteratorHasRoomFor(*iter, sizeof(*result)))
+ return false;
+
+ memcpy(result, *iter, sizeof(*result));
+
+ UpdateIter(iter, sizeof(*result));
+ return true;
+}
+
bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const {
DCHECK(iter);
if (!*iter)
@@ -355,7 +369,7 @@
}
void Pickle::TrimWriteData(int new_length) {
- DCHECK(variable_buffer_offset_ != 0);
+ DCHECK_NE(variable_buffer_offset_, 0);
// Fetch the the variable buffer size
int* cur_length = reinterpret_cast<int*>(