Chromium Code Reviews| Index: ipc/ipc_message_utils.h |
| diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h |
| index 58d6aa26da34fb125d45bd9f2ddd3f767a2f7313..e60c4edfb23b746158d6720379eaa39a63cfd903 100644 |
| --- a/ipc/ipc_message_utils.h |
| +++ b/ipc/ipc_message_utils.h |
| @@ -307,6 +307,44 @@ struct IPC_EXPORT ParamTraits<double> { |
| static void Log(const param_type& p, std::string* l); |
| }; |
| +template <class P, size_t Size> |
| +struct ParamTraits<P[Size]> { |
| + using param_type = P[Size]; |
| + static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
| + GetParamSize(sizer, static_cast<int>(Size)); |
|
dcheng
2017/02/08 00:13:37
Let's use strict_cast instead of static_cast throu
ericrk
2017/02/08 18:57:49
So, strict_cast seems to only consider the types b
|
| + for (size_t i = 0; i < Size; i++) |
| + GetParamSize(sizer, p[i]); |
| + } |
| + static void Write(base::Pickle* m, const param_type& p) { |
| + WriteParam(m, static_cast<int>(Size)); |
| + for (size_t i = 0; i < Size; i++) |
| + WriteParam(m, p[i]); |
| + } |
| + static bool Read(const base::Pickle* m, |
| + base::PickleIterator* iter, |
| + param_type* r) { |
| + int size; |
| + // ReadLength() checks for < 0 itself. |
| + if (!iter->ReadLength(&size)) |
| + return false; |
| + // For a fixed size array, a size mismatch should be impossible. |
|
dcheng
2017/02/08 00:13:37
It's not impossible if the renderer sends us bad d
ericrk
2017/02/08 18:57:49
heh, true enough, updated the comment
|
| + if (size != Size) |
| + return false; |
| + for (size_t i = 0; i < Size; i++) { |
| + if (!ReadParam(m, iter, &(*r)[i])) |
| + return false; |
| + } |
| + return true; |
| + } |
| + static void Log(const param_type& p, std::string* l) { |
| + for (size_t i = 0; i < Size; ++i) { |
| + if (i != 0) |
| + l->append(" "); |
| + LogParam((p[i]), l); |
| + } |
| + } |
| +}; |
| + |
| // STL ParamTraits ------------------------------------------------------------- |
| template <> |