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

Side by Side Diff: content/common/cc_messages.cc

Issue 10980010: Cleanup the IPC param traits structure (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix android Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/cc_messages.h"
6
7 #include "content/public/common/common_param_traits.h"
8
9 namespace IPC {
10
11 void ParamTraits<WebKit::WebData>::Write(Message* m, const param_type& p) {
12 if (p.isEmpty()) {
13 m->WriteData(NULL, 0);
14 } else {
15 m->WriteData(p.data(), p.size());
16 }
17 }
18
19 bool ParamTraits<WebKit::WebData>::Read(
20 const Message* m, PickleIterator* iter, param_type* r) {
21 const char *data = NULL;
22 int data_size = 0;
23 if (!m->ReadData(iter, &data, &data_size) || data_size < 0)
24 return false;
25 if (data_size)
26 r->assign(data, data_size);
27 else
28 r->reset();
29 return true;
30 }
31
32 void ParamTraits<WebKit::WebData>::Log(const param_type& p, std::string* l) {
33 l->append("(WebData of size ");
34 LogParam(p.size(), l);
35 l->append(")");
36 }
37
38 void ParamTraits<WebKit::WebTransformationMatrix>::Write(
39 Message* m, const param_type& p) {
40 WriteParam(m, p.m11());
41 WriteParam(m, p.m12());
42 WriteParam(m, p.m13());
43 WriteParam(m, p.m14());
44 WriteParam(m, p.m21());
45 WriteParam(m, p.m22());
46 WriteParam(m, p.m23());
47 WriteParam(m, p.m24());
48 WriteParam(m, p.m31());
49 WriteParam(m, p.m32());
50 WriteParam(m, p.m33());
51 WriteParam(m, p.m34());
52 WriteParam(m, p.m41());
53 WriteParam(m, p.m42());
54 WriteParam(m, p.m43());
55 WriteParam(m, p.m44());
56 }
57
58 bool ParamTraits<WebKit::WebTransformationMatrix>::Read(
59 const Message* m, PickleIterator* iter, param_type* r) {
60 double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
61 m41, m42, m43, m44;
62 bool success =
63 ReadParam(m, iter, &m11) &&
64 ReadParam(m, iter, &m12) &&
65 ReadParam(m, iter, &m13) &&
66 ReadParam(m, iter, &m14) &&
67 ReadParam(m, iter, &m21) &&
68 ReadParam(m, iter, &m22) &&
69 ReadParam(m, iter, &m23) &&
70 ReadParam(m, iter, &m24) &&
71 ReadParam(m, iter, &m31) &&
72 ReadParam(m, iter, &m32) &&
73 ReadParam(m, iter, &m33) &&
74 ReadParam(m, iter, &m34) &&
75 ReadParam(m, iter, &m41) &&
76 ReadParam(m, iter, &m42) &&
77 ReadParam(m, iter, &m43) &&
78 ReadParam(m, iter, &m44);
79
80 if (success) {
81 r->setM11(m11);
82 r->setM12(m12);
83 r->setM13(m13);
84 r->setM14(m14);
85 r->setM21(m21);
86 r->setM22(m22);
87 r->setM23(m23);
88 r->setM24(m24);
89 r->setM31(m31);
90 r->setM32(m32);
91 r->setM33(m33);
92 r->setM34(m34);
93 r->setM41(m41);
94 r->setM42(m42);
95 r->setM43(m43);
96 r->setM44(m44);
97 }
98
99 return success;
100 }
101
102 void ParamTraits<WebKit::WebTransformationMatrix>::Log(
103 const param_type& p, std::string* l) {
104 l->append("(");
105 LogParam(p.m11(), l);
106 l->append(", ");
107 LogParam(p.m12(), l);
108 l->append(", ");
109 LogParam(p.m13(), l);
110 l->append(", ");
111 LogParam(p.m14(), l);
112 l->append(", ");
113 LogParam(p.m21(), l);
114 l->append(", ");
115 LogParam(p.m22(), l);
116 l->append(", ");
117 LogParam(p.m23(), l);
118 l->append(", ");
119 LogParam(p.m24(), l);
120 l->append(", ");
121 LogParam(p.m31(), l);
122 l->append(", ");
123 LogParam(p.m32(), l);
124 l->append(", ");
125 LogParam(p.m33(), l);
126 l->append(", ");
127 LogParam(p.m34(), l);
128 l->append(", ");
129 LogParam(p.m41(), l);
130 l->append(", ");
131 LogParam(p.m42(), l);
132 l->append(", ");
133 LogParam(p.m43(), l);
134 l->append(", ");
135 LogParam(p.m44(), l);
136 l->append(") ");
137 }
138
139 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698