Index: ipc/ipc_message_utils.h |
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h |
index b05f76dd17334c7a98385dc1114795e0bf384ec4..102992d45ec6e003bf1a516bdc9b39e002b494f8 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())); |
+ 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) { |
+ K key; |
+ if (!ReadParam(m, iter, &key)) |
+ return false; |
+ V& value = (*r)[key]; |
+ 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 |