diff options
-rw-r--r-- | ipc/ipc_message_utils.cc | 51 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 24 |
2 files changed, 50 insertions, 25 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index 8bf7609..2acddce 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -253,6 +253,40 @@ void ParamTraits<bool>::Log(const param_type& p, std::string* l) { l->append(p ? "true" : "false"); } +void ParamTraits<unsigned char>::Write(Message* m, const param_type& p) { + m->WriteBytes(&p, sizeof(param_type)); +} + +bool ParamTraits<unsigned char>::Read(const Message* m, PickleIterator* iter, + param_type* r) { + const char* data; + if (!m->ReadBytes(iter, &data, sizeof(param_type))) + return false; + memcpy(r, data, sizeof(param_type)); + return true; +} + +void ParamTraits<unsigned char>::Log(const param_type& p, std::string* l) { + l->append(base::UintToString(p)); +} + +void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) { + m->WriteBytes(&p, sizeof(param_type)); +} + +bool ParamTraits<unsigned short>::Read(const Message* m, PickleIterator* iter, + param_type* r) { + const char* data; + if (!m->ReadBytes(iter, &data, sizeof(param_type))) + return false; + memcpy(r, data, sizeof(param_type)); + return true; +} + +void ParamTraits<unsigned short>::Log(const param_type& p, std::string* l) { + l->append(base::UintToString(p)); +} + void ParamTraits<int>::Log(const param_type& p, std::string* l) { l->append(base::IntToString(p)); } @@ -277,23 +311,6 @@ void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) { l->append(base::Uint64ToString(p)); } -void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) { - m->WriteBytes(&p, sizeof(param_type)); -} - -bool ParamTraits<unsigned short>::Read(const Message* m, PickleIterator* iter, - param_type* r) { - const char* data; - if (!m->ReadBytes(iter, &data, sizeof(param_type))) - return false; - memcpy(r, data, sizeof(param_type)); - return true; -} - -void ParamTraits<unsigned short>::Log(const param_type& p, std::string* l) { - l->append(base::UintToString(p)); -} - void ParamTraits<float>::Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 7fda943..4db8b12 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -121,6 +121,22 @@ struct ParamTraits<bool> { }; template <> +struct IPC_EXPORT ParamTraits<unsigned char> { + typedef unsigned short param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct IPC_EXPORT ParamTraits<unsigned short> { + typedef unsigned short param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> struct ParamTraits<int> { typedef int param_type; static void Write(Message* m, const param_type& p) { @@ -194,14 +210,6 @@ struct ParamTraits<unsigned long long> { IPC_EXPORT static void Log(const param_type& p, std::string* l); }; -template <> -struct IPC_EXPORT ParamTraits<unsigned short> { - typedef unsigned short param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients // should be sure to check the sanity of these values after receiving them over // IPC. |