diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 00:03:10 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 00:03:10 +0000 |
commit | c272d08ceb9a6b960ace9be9c22600034f7e240e (patch) | |
tree | 0c7ee36cb0f3d6ac381aa1be66ccd309659c2c6d | |
parent | 4a7e43e76fb9ff1ae2c78ed62ee802e5c855aa56 (diff) | |
download | chromium_src-c272d08ceb9a6b960ace9be9c22600034f7e240e.zip chromium_src-c272d08ceb9a6b960ace9be9c22600034f7e240e.tar.gz chromium_src-c272d08ceb9a6b960ace9be9c22600034f7e240e.tar.bz2 |
Remove Pickle::WriteSize() now that it has no remaining callers. Also rename
Pickle::WriteLong() to WriteLongUsingDangerousNonPortableLessPersistableForm()
and add a strongly-worded comment against its use; it is used only for IPC
which is safe. (These methods write variable amounts of data to pickles,
depending on architecture, and aren't safe if pickles are persisted.)
Review URL: http://codereview.chromium.org/9641005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128347 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/pickle.cc | 4 | ||||
-rw-r--r-- | base/pickle.h | 14 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 4 |
3 files changed, 8 insertions, 14 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 3b8e0ce..0e44131 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -74,10 +74,6 @@ bool PickleIterator::ReadLong(long* result) { return ReadBuiltinType(result); } -bool PickleIterator::ReadSize(size_t* result) { - return ReadBuiltinType(result); -} - bool PickleIterator::ReadUInt16(uint16* result) { return ReadBuiltinType(result); } diff --git a/base/pickle.h b/base/pickle.h index 47e3bf6..baa20f6 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -31,7 +31,6 @@ class BASE_EXPORT PickleIterator { bool ReadBool(bool* result) WARN_UNUSED_RESULT; bool ReadInt(int* result) WARN_UNUSED_RESULT; bool ReadLong(long* result) WARN_UNUSED_RESULT; - bool ReadSize(size_t* result) WARN_UNUSED_RESULT; bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; bool ReadInt64(int64* result) WARN_UNUSED_RESULT; @@ -148,9 +147,6 @@ class BASE_EXPORT Pickle { bool ReadLong(PickleIterator* iter, long* result) const { return iter->ReadLong(result); } - bool ReadSize(PickleIterator* iter, size_t* result) const { - return iter->ReadSize(result); - } bool ReadUInt16(PickleIterator* iter, uint16* result) const { return iter->ReadUInt16(result); } @@ -195,10 +191,12 @@ class BASE_EXPORT Pickle { bool WriteInt(int value) { return WriteBytes(&value, sizeof(value)); } - bool WriteLong(long value) { - return WriteBytes(&value, sizeof(value)); - } - bool WriteSize(size_t value) { + // WARNING: DO NOT USE THIS METHOD IF PICKLES ARE PERSISTED IN ANY WAY. + // It will write whatever a "long" is on this architecture. On 32-bit + // platforms, it is 32 bits. On 64-bit platforms, it is 64 bits. If persisted + // pickles are still around after upgrading to 64-bit, or if they are copied + // between dissimilar systems, YOUR PICKLES WILL HAVE GONE BAD. + bool WriteLongUsingDangerousNonPortableLessPersistableForm(long value) { return WriteBytes(&value, sizeof(value)); } bool WriteUInt16(uint16 value) { diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index bac0a82..dc4a4be 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -228,7 +228,7 @@ template <> struct ParamTraits<long> { typedef long param_type; static void Write(Message* m, const param_type& p) { - m->WriteLong(p); + m->WriteLongUsingDangerousNonPortableLessPersistableForm(p); } static bool Read(const Message* m, PickleIterator* iter, param_type* r) { @@ -241,7 +241,7 @@ template <> struct ParamTraits<unsigned long> { typedef unsigned long param_type; static void Write(Message* m, const param_type& p) { - m->WriteLong(p); + m->WriteLongUsingDangerousNonPortableLessPersistableForm(p); } static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |