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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 164458: Land http://codereview.chromium.org/159067: (Closed)
Patch Set: undo docs Created 11 years, 4 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 | « chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <map> 10 #include <map>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 } 94 }
95 private: 95 private:
96 const Message& msg_; 96 const Message& msg_;
97 mutable void* iter_; 97 mutable void* iter_;
98 }; 98 };
99 99
100 //----------------------------------------------------------------------------- 100 //-----------------------------------------------------------------------------
101 // ParamTraits specializations, etc. 101 // ParamTraits specializations, etc.
102 102
103 template <class P> struct ParamTraits {}; 103 template <class P> struct ParamTraits {
104 };
105
106 template <class P>
107 struct SimilarTypeTraits {
108 typedef P Type;
109 };
104 110
105 template <class P> 111 template <class P>
106 static inline void WriteParam(Message* m, const P& p) { 112 static inline void WriteParam(Message* m, const P& p) {
107 ParamTraits<P>::Write(m, p); 113 typedef typename SimilarTypeTraits<P>::Type Type;
114 ParamTraits<Type>::Write(m, static_cast<const Type& >(p));
108 } 115 }
109 116
110 template <class P> 117 template <class P>
111 static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter, 118 static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter,
112 P* p) { 119 P* p) {
113 return ParamTraits<P>::Read(m, iter, p); 120 typedef typename SimilarTypeTraits<P>::Type Type;
121 return ParamTraits<Type>::Read(m, iter, reinterpret_cast<Type* >(p));
114 } 122 }
115 123
116 template <class P> 124 template <class P>
117 static inline void LogParam(const P& p, std::wstring* l) { 125 static inline void LogParam(const P& p, std::wstring* l) {
118 ParamTraits<P>::Log(p, l); 126 typedef typename SimilarTypeTraits<P>::Type Type;
127 ParamTraits<Type>::Log(static_cast<const Type& >(p), l);
119 } 128 }
120 129
121 template <> 130 template <>
122 struct ParamTraits<bool> { 131 struct ParamTraits<bool> {
123 typedef bool param_type; 132 typedef bool param_type;
124 static void Write(Message* m, const param_type& p) { 133 static void Write(Message* m, const param_type& p) {
125 m->WriteBool(p); 134 m->WriteBool(p);
126 } 135 }
127 static bool Read(const Message* m, void** iter, param_type* r) { 136 static bool Read(const Message* m, void** iter, param_type* r) {
128 return m->ReadBool(iter, r); 137 return m->ReadBool(iter, r);
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 ReadParam(m, iter, &r->dispatch) && 790 ReadParam(m, iter, &r->dispatch) &&
782 ReadParam(m, iter, &r->params); 791 ReadParam(m, iter, &r->params);
783 r->type = static_cast<uint16>(type); 792 r->type = static_cast<uint16>(type);
784 return result; 793 return result;
785 } 794 }
786 static void Log(const param_type& p, std::wstring* l) { 795 static void Log(const param_type& p, std::wstring* l) {
787 // Doesn't make sense to implement this! 796 // Doesn't make sense to implement this!
788 } 797 }
789 }; 798 };
790 799
791
792 template <> 800 template <>
793 struct ParamTraits<Message> { 801 struct ParamTraits<Message> {
794 static void Write(Message* m, const Message& p) { 802 static void Write(Message* m, const Message& p) {
795 m->WriteInt(p.size()); 803 m->WriteInt(p.size());
796 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size()); 804 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size());
797 } 805 }
798 static bool Read(const Message* m, void** iter, Message* r) { 806 static bool Read(const Message* m, void** iter, Message* r) {
799 int size; 807 int size;
800 if (!m->ReadInt(iter, &size)) 808 if (!m->ReadInt(iter, &size))
801 return false; 809 return false;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 ReplyParam p(a, b, c, d, e); 1233 ReplyParam p(a, b, c, d, e);
1226 WriteParam(reply, p); 1234 WriteParam(reply, p);
1227 } 1235 }
1228 }; 1236 };
1229 1237
1230 //----------------------------------------------------------------------------- 1238 //-----------------------------------------------------------------------------
1231 1239
1232 } // namespace IPC 1240 } // namespace IPC
1233 1241
1234 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1242 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698