Index: ipc/ipc_message_utils.h |
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h |
index b05f76dd17334c7a98385dc1114795e0bf384ec4..e672e07ab26fafa7dfb3a1fa786a4e7886e3d587 100644 |
--- a/ipc/ipc_message_utils.h |
+++ b/ipc/ipc_message_utils.h |
@@ -11,6 +11,7 @@ |
#include <string> |
#include <vector> |
+#include "base/containers/small_map.h" |
#include "base/files/file.h" |
#include "base/format_macros.h" |
#include "base/memory/scoped_vector.h" |
@@ -670,6 +671,41 @@ struct ParamTraits<ScopedVector<P> > { |
} |
}; |
+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; |
+ 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())); |
Tom Sepez
2014/02/14 19:05:37
we ought to be careful here if p.size() > INT_MAX,
Tom Sepez
2014/02/14 19:14:42
Though std::map has this same issue, so this is pr
jdduke (slow)
2014/02/18 01:42:21
Good point. I think some other container types ma
|
+ 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 (!m->ReadLength(iter, &size)) |
+ return false; |
+ for (int i = 0; i < size; ++i) { |
Tom Sepez
2014/02/14 19:05:37
This one is more important: You'll want to return
jdduke (slow)
2014/02/18 01:42:21
Hmm, I was under the impression that |ReadLength()
|
+ K key; |
+ if (!ReadParam(m, iter, &key)) |
+ 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>"); |
+ } |
+}; |
+ |
// IPC types ParamTraits ------------------------------------------------------- |
// A ChannelHandle is basically a platform-inspecific wrapper around the |