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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 2748133007: Remove ScopedVector from ipc/. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_reader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <map> 13 #include <map>
14 #include <memory> 14 #include <memory>
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <tuple> 17 #include <tuple>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/containers/small_map.h" 20 #include "base/containers/small_map.h"
21 #include "base/containers/stack_container.h" 21 #include "base/containers/stack_container.h"
22 #include "base/files/file.h" 22 #include "base/files/file.h"
23 #include "base/format_macros.h" 23 #include "base/format_macros.h"
24 #include "base/memory/scoped_vector.h"
25 #include "base/optional.h" 24 #include "base/optional.h"
26 #include "base/strings/string16.h" 25 #include "base/strings/string16.h"
27 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
28 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
29 #include "build/build_config.h" 28 #include "build/build_config.h"
30 #include "ipc/ipc_message_start.h" 29 #include "ipc/ipc_message_start.h"
31 #include "ipc/ipc_param_traits.h" 30 #include "ipc/ipc_param_traits.h"
32 #include "ipc/ipc_sync_message.h" 31 #include "ipc/ipc_sync_message.h"
33 32
34 namespace base { 33 namespace base {
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 LogParam(std::get<1>(p), l); 848 LogParam(std::get<1>(p), l);
850 l->append(", "); 849 l->append(", ");
851 LogParam(std::get<2>(p), l); 850 LogParam(std::get<2>(p), l);
852 l->append(", "); 851 l->append(", ");
853 LogParam(std::get<3>(p), l); 852 LogParam(std::get<3>(p), l);
854 l->append(", "); 853 l->append(", ");
855 LogParam(std::get<4>(p), l); 854 LogParam(std::get<4>(p), l);
856 } 855 }
857 }; 856 };
858 857
859 template<class P>
860 struct ParamTraits<ScopedVector<P> > {
861 typedef ScopedVector<P> param_type;
862 static void Write(base::Pickle* m, const param_type& p) {
863 WriteParam(m, static_cast<int>(p.size()));
864 for (size_t i = 0; i < p.size(); i++)
865 WriteParam(m, *p[i]);
866 }
867 static bool Read(const base::Pickle* m,
868 base::PickleIterator* iter,
869 param_type* r) {
870 int size = 0;
871 if (!iter->ReadLength(&size))
872 return false;
873 if (INT_MAX/sizeof(P) <= static_cast<size_t>(size))
874 return false;
875 r->resize(size);
876 for (int i = 0; i < size; i++) {
877 (*r)[i] = new P();
878 if (!ReadParam(m, iter, (*r)[i]))
879 return false;
880 }
881 return true;
882 }
883 static void Log(const param_type& p, std::string* l) {
884 for (size_t i = 0; i < p.size(); ++i) {
885 if (i != 0)
886 l->append(" ");
887 LogParam(*p[i], l);
888 }
889 }
890 };
891
892 template <class P, size_t stack_capacity> 858 template <class P, size_t stack_capacity>
893 struct ParamTraits<base::StackVector<P, stack_capacity> > { 859 struct ParamTraits<base::StackVector<P, stack_capacity> > {
894 typedef base::StackVector<P, stack_capacity> param_type; 860 typedef base::StackVector<P, stack_capacity> param_type;
895 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 861 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
896 GetParamSize(sizer, static_cast<int>(p->size())); 862 GetParamSize(sizer, static_cast<int>(p->size()));
897 for (size_t i = 0; i < p->size(); i++) 863 for (size_t i = 0; i < p->size(); i++)
898 GetParamSize(sizer, p[i]); 864 GetParamSize(sizer, p[i]);
899 } 865 }
900 static void Write(base::Pickle* m, const param_type& p) { 866 static void Write(base::Pickle* m, const param_type& p) {
901 WriteParam(m, static_cast<int>(p->size())); 867 WriteParam(m, static_cast<int>(p->size()));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 template <class ReplyParamType> 1136 template <class ReplyParamType>
1171 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, 1137 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params,
1172 const Message* msg) {} 1138 const Message* msg) {}
1173 1139
1174 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} 1140 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {}
1175 #endif 1141 #endif
1176 1142
1177 } // namespace IPC 1143 } // namespace IPC
1178 1144
1179 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1145 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_reader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698