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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 2825853002: Improvements to uses of base::SmallMap (Closed)
Patch Set: Code review Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_
6 #define IPC_IPC_MESSAGE_UTILS_H_ 6 #define IPC_IPC_MESSAGE_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 l->append(" "); 892 l->append(" ");
893 LogParam((p[i]), l); 893 LogParam((p[i]), l);
894 } 894 }
895 } 895 }
896 }; 896 };
897 897
898 template <typename NormalMap, 898 template <typename NormalMap,
899 int kArraySize, 899 int kArraySize,
900 typename EqualKey, 900 typename EqualKey,
901 typename MapInit> 901 typename MapInit>
902 struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { 902 struct ParamTraits<base::small_map<NormalMap, kArraySize, EqualKey, MapInit>> {
903 typedef base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> param_type; 903 using param + _type =
904 typedef typename param_type::key_type K; 904 base::small_map<NormalMap, kArraySize, EqualKey, MapInit> param_type;
905 typedef typename param_type::data_type V; 905 using K = typename param_type::key_type;
906 using V = typename param_type::data_type;
906 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 907 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
907 GetParamSize(sizer, static_cast<int>(p.size())); 908 GetParamSize(sizer, static_cast<int>(p.size()));
908 typename param_type::const_iterator iter; 909 typename param_type::const_iterator iter;
909 for (iter = p.begin(); iter != p.end(); ++iter) { 910 for (iter = p.begin(); iter != p.end(); ++iter) {
910 GetParamSize(sizer, iter->first); 911 GetParamSize(sizer, iter->first);
911 GetParamSize(sizer, iter->second); 912 GetParamSize(sizer, iter->second);
912 } 913 }
913 } 914 }
914 static void Write(base::Pickle* m, const param_type& p) { 915 static void Write(base::Pickle* m, const param_type& p) {
915 WriteParam(m, static_cast<int>(p.size())); 916 WriteParam(m, static_cast<int>(p.size()));
(...skipping 13 matching lines...) Expand all
929 K key; 930 K key;
930 if (!ReadParam(m, iter, &key)) 931 if (!ReadParam(m, iter, &key))
931 return false; 932 return false;
932 V& value = (*r)[key]; 933 V& value = (*r)[key];
933 if (!ReadParam(m, iter, &value)) 934 if (!ReadParam(m, iter, &value))
934 return false; 935 return false;
935 } 936 }
936 return true; 937 return true;
937 } 938 }
938 static void Log(const param_type& p, std::string* l) { 939 static void Log(const param_type& p, std::string* l) {
939 l->append("<base::SmallMap>"); 940 l->append("<base::small_map>");
940 } 941 }
941 }; 942 };
942 943
943 template <class P> 944 template <class P>
944 struct ParamTraits<std::unique_ptr<P>> { 945 struct ParamTraits<std::unique_ptr<P>> {
945 typedef std::unique_ptr<P> param_type; 946 typedef std::unique_ptr<P> param_type;
946 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 947 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
947 bool valid = !!p; 948 bool valid = !!p;
948 GetParamSize(sizer, valid); 949 GetParamSize(sizer, valid);
949 if (valid) 950 if (valid)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 template <class ReplyParamType> 1137 template <class ReplyParamType>
1137 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, 1138 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params,
1138 const Message* msg) {} 1139 const Message* msg) {}
1139 1140
1140 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} 1141 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {}
1141 #endif 1142 #endif
1142 1143
1143 } // namespace IPC 1144 } // namespace IPC
1144 1145
1145 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1146 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698