Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: ipc/ipc_message_utils.h

Issue 157003005: Replace std::map with base::SmallMap in ui::LatencyInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/renderer/render_widget.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698