Chromium Code Reviews| Index: ipc/ipc_message_utils.h |
| diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h |
| index df2c6c7693ff7df67e3148b5cd8e0d211df54b88..747d2620cfca91aae76e9a03d528f083df85b835 100644 |
| --- a/ipc/ipc_message_utils.h |
| +++ b/ipc/ipc_message_utils.h |
| @@ -226,6 +226,33 @@ struct ParamTraits<unsigned long long> { |
| } |
| }; |
| +// 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. |
| +template <> |
| +struct ParamTraits<float> { |
| + typedef float param_type; |
| + static void Write(Message* m, const param_type& p) { |
| + m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); |
| + } |
| + static bool Read(const Message* m, void** iter, param_type* r) { |
| + const char *data; |
|
agl
2010/06/15 14:10:15
Seems over complex:
const char* data;
int data_si
jeremy
2010/06/15 14:26:55
Agreed, I wanted to match the definition for doubl
|
| + int data_size = 0; |
| + bool result = m->ReadData(iter, &data, &data_size); |
| + if (result && data_size == sizeof(param_type)) { |
| + memcpy(r, data, sizeof(param_type)); |
| + } else { |
| + result = false; |
| + NOTREACHED(); |
| + } |
| + |
| + return result; |
| + } |
| + static void Log(const param_type& p, std::wstring* l) { |
| + l->append(StringPrintf(L"e", p)); |
| + } |
| +}; |
| + |
| template <> |
| struct ParamTraits<double> { |
| typedef double param_type; |