Chromium Code Reviews| Index: content/common/content_param_traits.h |
| diff --git a/content/common/content_param_traits.h b/content/common/content_param_traits.h |
| index d4bc359863e4102b62bfb9174aa79e82f8c36038..4bc13cc96218c6fe98ccc4d17594ff3ea4335d40 100644 |
| --- a/content/common/content_param_traits.h |
| +++ b/content/common/content_param_traits.h |
| @@ -68,6 +68,41 @@ struct ParamTraits<WebInputEventPointer> { |
| static void Log(const param_type& p, std::string* l); |
| }; |
| +template <typename NormalMap, |
| + int kArraySize, |
| + typename EqualKey, |
| + typename MapInit> |
| +struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { |
| + typedef base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> param_type; |
|
jdduke (slow)
2014/02/13 20:48:43
Hmm, this should probably live in common_param_tra
|
| + typedef typename param_type::key_type K; |
| + typedef typename param_type::data_type V; |
| + static void Write(Message* m, const param_type& p) { |
| + WriteParam(m, static_cast<int>(p.size())); |
| + typename param_type::const_iterator iter; |
| + for (iter = p.begin(); iter != p.end(); ++iter) { |
| + WriteParam(m, iter->first); |
| + WriteParam(m, iter->second); |
| + } |
| + } |
| + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
| + int size; |
| + if (!ReadParam(m, iter, &size) || size < 0) |
| + return false; |
| + for (int i = 0; i < size; ++i) { |
| + K k; |
| + if (!ReadParam(m, iter, &k)) |
| + return false; |
| + V& value = (*r)[k]; |
| + if (!ReadParam(m, iter, &value)) |
| + return false; |
| + } |
| + return true; |
| + } |
| + static void Log(const param_type& p, std::string* l) { |
| + l->append("<base::SmallMap>"); |
| + } |
| +}; |
| + |
| } // namespace IPC |
| #endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ |