diff options
author | klink@google.com <klink@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 23:24:54 +0000 |
---|---|---|
committer | klink@google.com <klink@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 23:24:54 +0000 |
commit | 43beaef40b42c3afb4870043ab5720286e786ae4 (patch) | |
tree | 3abd0dd136552ad3055abfa2ca9a476463d8711c | |
parent | 77c40528d35beef9559b2e3412f04b472b995c4e (diff) | |
download | chromium_src-43beaef40b42c3afb4870043ab5720286e786ae4.zip chromium_src-43beaef40b42c3afb4870043ab5720286e786ae4.tar.gz chromium_src-43beaef40b42c3afb4870043ab5720286e786ae4.tar.bz2 |
Adds capabilities for IPC messages of type long, for the primary purpose of accessibility related communication.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1263 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/pickle.cc | 16 | ||||
-rw-r--r-- | base/pickle.h | 4 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.h | 14 |
3 files changed, 34 insertions, 0 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 73a764a..83efaf1 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -130,6 +130,22 @@ bool Pickle::ReadInt(void** iter, int* result) const { return true; } +bool Pickle::ReadLong(void** iter, long* result) const { + DCHECK(iter); + if (!*iter) + *iter = const_cast<char*>(payload()); + + if (!IteratorHasRoomFor(*iter, sizeof(*result))) + return false; + + // TODO(jar) bug 1129285: Pickle should be cleaned up, and not dependent on + // alignment. + memcpy(result, *iter, sizeof(*result)); + + UpdateIter(iter, sizeof(*result)); + return true; +} + bool Pickle::ReadLength(void** iter, int* result) const { if (!ReadInt(iter, result)) return false; diff --git a/base/pickle.h b/base/pickle.h index 422a1a30..3538e12 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -90,6 +90,7 @@ class Pickle { // be extracted. bool ReadBool(void** iter, bool* result) const; bool ReadInt(void** iter, int* result) const; + bool ReadLong(void** iter, long* result) const; bool ReadSize(void** iter, size_t* result) const; bool ReadInt64(void** iter, int64* result) const; bool ReadIntPtr(void** iter, intptr_t* result) const; @@ -112,6 +113,9 @@ class Pickle { bool WriteInt(int value) { return WriteBytes(&value, sizeof(value)); } + bool WriteLong(long value) { + return WriteBytes(&value, sizeof(value)); + } bool WriteSize(size_t value) { return WriteBytes(&value, sizeof(value)); } diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 7939147..add9d19 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -158,6 +158,20 @@ struct ParamTraits<int> { }; template <> +struct ParamTraits<long> { + typedef long param_type; + static void Write(Message* m, const param_type& p) { + m->WriteLong(p); + } + static bool Read(const Message* m, void** iter, param_type* r) { + return m->ReadLong(iter, r); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"%l", p)); + } +}; + +template <> struct ParamTraits<size_t> { typedef size_t param_type; static void Write(Message* m, const param_type& p) { |