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

Side by Side Diff: content/public/common/webkit_param_traits.cc

Issue 10948044: Pickling traits for more simple WebKit types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove static_cast and initialize ptr to NULL Created 8 years, 3 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/public/common/webkit_param_traits.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 // NOTE: New trait definitions that will be used by Chrome Frame must be placed 5 // NOTE: New trait definitions that will be used by Chrome Frame must be placed
6 // in common_param_traits2.cc. 6 // in common_param_traits2.cc.
7 7
8 #include "content/public/common/webkit_param_traits.h" 8 #include "content/public/common/webkit_param_traits.h"
9 9
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 17 matching lines...) Expand all
28 int_value(0), 28 int_value(0),
29 double_value(0), 29 double_value(0),
30 npobject_routing_id(-1) { 30 npobject_routing_id(-1) {
31 } 31 }
32 32
33 NPVariant_Param::~NPVariant_Param() { 33 NPVariant_Param::~NPVariant_Param() {
34 } 34 }
35 35
36 namespace IPC { 36 namespace IPC {
37 37
38 void ParamTraits<WebKit::WebData>::Write(Message* m, const param_type& p) {
39 if (p.isEmpty()) {
40 m->WriteData(NULL, 0);
41 } else {
42 m->WriteData(p.data(), p.size());
43 }
44 }
45
46 bool ParamTraits<WebKit::WebData>::Read(
47 const Message* m, PickleIterator* iter, param_type* r) {
48 const char *data = NULL;
49 int data_size = 0;
50 if (!m->ReadData(iter, &data, &data_size) || data_size < 0)
51 return false;
52 if (data_size)
53 r->assign(data, data_size);
54 else
55 r->reset();
56 return true;
57 }
58
59 void ParamTraits<WebKit::WebData>::Log(const param_type& p, std::string* l) {
60 l->append("(WebData of size ");
61 LogParam(p.size(), l);
62 l->append(")");
63 }
64
65 void ParamTraits<WebKit::WebTransformationMatrix>::Write(
66 Message* m, const param_type& p) {
67 WriteParam(m, p.m11());
68 WriteParam(m, p.m12());
69 WriteParam(m, p.m13());
70 WriteParam(m, p.m14());
71 WriteParam(m, p.m21());
72 WriteParam(m, p.m22());
73 WriteParam(m, p.m23());
74 WriteParam(m, p.m24());
75 WriteParam(m, p.m31());
76 WriteParam(m, p.m32());
77 WriteParam(m, p.m33());
78 WriteParam(m, p.m34());
79 WriteParam(m, p.m41());
80 WriteParam(m, p.m42());
81 WriteParam(m, p.m43());
82 WriteParam(m, p.m44());
83 }
84
85 bool ParamTraits<WebKit::WebTransformationMatrix>::Read(
86 const Message* m, PickleIterator* iter, param_type* r) {
87 double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
88 m41, m42, m43, m44;
89 bool success =
90 ReadParam(m, iter, &m11) &&
91 ReadParam(m, iter, &m12) &&
92 ReadParam(m, iter, &m13) &&
93 ReadParam(m, iter, &m14) &&
94 ReadParam(m, iter, &m21) &&
95 ReadParam(m, iter, &m22) &&
96 ReadParam(m, iter, &m23) &&
97 ReadParam(m, iter, &m24) &&
98 ReadParam(m, iter, &m31) &&
99 ReadParam(m, iter, &m32) &&
100 ReadParam(m, iter, &m33) &&
101 ReadParam(m, iter, &m34) &&
102 ReadParam(m, iter, &m41) &&
103 ReadParam(m, iter, &m42) &&
104 ReadParam(m, iter, &m43) &&
105 ReadParam(m, iter, &m44);
106
107 if (success) {
108 r->setM11(m11);
109 r->setM12(m12);
110 r->setM13(m13);
111 r->setM14(m14);
112 r->setM21(m21);
113 r->setM22(m22);
114 r->setM23(m23);
115 r->setM24(m24);
116 r->setM31(m31);
117 r->setM32(m32);
118 r->setM33(m33);
119 r->setM34(m34);
120 r->setM41(m41);
121 r->setM42(m42);
122 r->setM43(m43);
123 r->setM44(m44);
124 }
125
126 return success;
127 }
128
129 void ParamTraits<WebKit::WebTransformationMatrix>::Log(
130 const param_type& p, std::string* l) {
131 l->append("(");
132 LogParam(p.m11(), l);
133 l->append(", ");
134 LogParam(p.m12(), l);
135 l->append(", ");
136 LogParam(p.m13(), l);
137 l->append(", ");
138 LogParam(p.m14(), l);
139 l->append(", ");
140 LogParam(p.m21(), l);
141 l->append(", ");
142 LogParam(p.m22(), l);
143 l->append(", ");
144 LogParam(p.m23(), l);
145 l->append(", ");
146 LogParam(p.m24(), l);
147 l->append(", ");
148 LogParam(p.m31(), l);
149 l->append(", ");
150 LogParam(p.m32(), l);
151 l->append(", ");
152 LogParam(p.m33(), l);
153 l->append(", ");
154 LogParam(p.m34(), l);
155 l->append(", ");
156 LogParam(p.m41(), l);
157 l->append(", ");
158 LogParam(p.m42(), l);
159 l->append(", ");
160 LogParam(p.m43(), l);
161 l->append(", ");
162 LogParam(p.m44(), l);
163 l->append(") ");
164 }
165
38 void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( 166 void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write(
39 Message* m, const param_type& p) { 167 Message* m, const param_type& p) {
40 WriteParam(m, p.base_time.is_null()); 168 WriteParam(m, p.base_time.is_null());
41 if (p.base_time.is_null()) 169 if (p.base_time.is_null())
42 return; 170 return;
43 WriteParam(m, p.base_ticks); 171 WriteParam(m, p.base_ticks);
44 WriteParam(m, p.base_time); 172 WriteParam(m, p.base_time);
45 WriteParam(m, p.proxy_start); 173 WriteParam(m, p.proxy_start);
46 WriteParam(m, p.proxy_end); 174 WriteParam(m, p.proxy_end);
47 WriteParam(m, p.dns_start); 175 WriteParam(m, p.dns_start);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 ReadParam(m, iter, &p->ssl_valid) && 472 ReadParam(m, iter, &p->ssl_valid) &&
345 ReadParam(m, iter, &p->preferred) && 473 ReadParam(m, iter, &p->preferred) &&
346 ReadParam(m, iter, &p->blacklisted_by_user); 474 ReadParam(m, iter, &p->blacklisted_by_user);
347 } 475 }
348 void ParamTraits<webkit::forms::PasswordForm>::Log(const param_type& p, 476 void ParamTraits<webkit::forms::PasswordForm>::Log(const param_type& p,
349 std::string* l) { 477 std::string* l) {
350 l->append("<PasswordForm>"); 478 l->append("<PasswordForm>");
351 } 479 }
352 480
353 } // namespace IPC 481 } // namespace IPC
OLDNEW
« no previous file with comments | « content/public/common/webkit_param_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698