| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/webkit_param_traits.h" | 8 #include "content/common/webkit_param_traits.h" |
| 9 | 9 |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const param_type& p, std::string* l) { | 143 const param_type& p, std::string* l) { |
| 144 l->append("("); | 144 l->append("("); |
| 145 if (p) { | 145 if (p) { |
| 146 LogParam(p->request_headers, l); | 146 LogParam(p->request_headers, l); |
| 147 l->append(", "); | 147 l->append(", "); |
| 148 LogParam(p->response_headers, l); | 148 LogParam(p->response_headers, l); |
| 149 } | 149 } |
| 150 l->append(")"); | 150 l->append(")"); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Only the webkit_blob::BlobData ParamTraits<> definition needs this | |
| 154 // definition, so keep this in the implementation file so we can forward declare | |
| 155 // BlobData in the header. | |
| 156 template <> | |
| 157 struct ParamTraits<webkit_blob::BlobData::Item> { | |
| 158 typedef webkit_blob::BlobData::Item param_type; | |
| 159 static void Write(Message* m, const param_type& p) { | |
| 160 WriteParam(m, static_cast<int>(p.type())); | |
| 161 if (p.type() == webkit_blob::BlobData::TYPE_DATA) { | |
| 162 WriteParam(m, p.data()); | |
| 163 } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) { | |
| 164 WriteParam(m, p.file_path()); | |
| 165 WriteParam(m, p.offset()); | |
| 166 WriteParam(m, p.length()); | |
| 167 WriteParam(m, p.expected_modification_time()); | |
| 168 } else { | |
| 169 WriteParam(m, p.blob_url()); | |
| 170 WriteParam(m, p.offset()); | |
| 171 WriteParam(m, p.length()); | |
| 172 } | |
| 173 } | |
| 174 static bool Read(const Message* m, void** iter, param_type* r) { | |
| 175 int type; | |
| 176 if (!ReadParam(m, iter, &type)) | |
| 177 return false; | |
| 178 if (type == webkit_blob::BlobData::TYPE_DATA) { | |
| 179 std::string data; | |
| 180 if (!ReadParam(m, iter, &data)) | |
| 181 return false; | |
| 182 r->SetToData(data); | |
| 183 } else if (type == webkit_blob::BlobData::TYPE_FILE) { | |
| 184 FilePath file_path; | |
| 185 uint64 offset, length; | |
| 186 base::Time expected_modification_time; | |
| 187 if (!ReadParam(m, iter, &file_path)) | |
| 188 return false; | |
| 189 if (!ReadParam(m, iter, &offset)) | |
| 190 return false; | |
| 191 if (!ReadParam(m, iter, &length)) | |
| 192 return false; | |
| 193 if (!ReadParam(m, iter, &expected_modification_time)) | |
| 194 return false; | |
| 195 r->SetToFile(file_path, offset, length, expected_modification_time); | |
| 196 } else { | |
| 197 DCHECK(type == webkit_blob::BlobData::TYPE_BLOB); | |
| 198 GURL blob_url; | |
| 199 uint64 offset, length; | |
| 200 if (!ReadParam(m, iter, &blob_url)) | |
| 201 return false; | |
| 202 if (!ReadParam(m, iter, &offset)) | |
| 203 return false; | |
| 204 if (!ReadParam(m, iter, &length)) | |
| 205 return false; | |
| 206 r->SetToBlob(blob_url, offset, length); | |
| 207 } | |
| 208 return true; | |
| 209 } | |
| 210 static void Log(const param_type& p, std::string* l) { | |
| 211 l->append("<BlobData::Item>"); | |
| 212 } | |
| 213 }; | |
| 214 | |
| 215 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write( | |
| 216 Message* m, const param_type& p) { | |
| 217 WriteParam(m, p.get() != NULL); | |
| 218 if (p) { | |
| 219 WriteParam(m, p->items()); | |
| 220 WriteParam(m, p->content_type()); | |
| 221 WriteParam(m, p->content_disposition()); | |
| 222 } | |
| 223 } | |
| 224 | |
| 225 bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read( | |
| 226 const Message* m, void** iter, param_type* r) { | |
| 227 bool has_object; | |
| 228 if (!ReadParam(m, iter, &has_object)) | |
| 229 return false; | |
| 230 if (!has_object) | |
| 231 return true; | |
| 232 std::vector<webkit_blob::BlobData::Item> items; | |
| 233 if (!ReadParam(m, iter, &items)) | |
| 234 return false; | |
| 235 std::string content_type; | |
| 236 if (!ReadParam(m, iter, &content_type)) | |
| 237 return false; | |
| 238 std::string content_disposition; | |
| 239 if (!ReadParam(m, iter, &content_disposition)) | |
| 240 return false; | |
| 241 *r = new webkit_blob::BlobData; | |
| 242 (*r)->swap_items(&items); | |
| 243 (*r)->set_content_type(content_type); | |
| 244 (*r)->set_content_disposition(content_disposition); | |
| 245 return true; | |
| 246 } | |
| 247 | |
| 248 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log( | |
| 249 const param_type& p, std::string* l) { | |
| 250 l->append("<webkit_blob::BlobData>"); | |
| 251 } | |
| 252 | |
| 253 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { | 153 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { |
| 254 WriteParam(m, static_cast<int>(p.type)); | 154 WriteParam(m, static_cast<int>(p.type)); |
| 255 if (p.type == NPVARIANT_PARAM_BOOL) { | 155 if (p.type == NPVARIANT_PARAM_BOOL) { |
| 256 WriteParam(m, p.bool_value); | 156 WriteParam(m, p.bool_value); |
| 257 } else if (p.type == NPVARIANT_PARAM_INT) { | 157 } else if (p.type == NPVARIANT_PARAM_INT) { |
| 258 WriteParam(m, p.int_value); | 158 WriteParam(m, p.int_value); |
| 259 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { | 159 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { |
| 260 WriteParam(m, p.double_value); | 160 WriteParam(m, p.double_value); |
| 261 } else if (p.type == NPVARIANT_PARAM_STRING) { | 161 } else if (p.type == NPVARIANT_PARAM_STRING) { |
| 262 WriteParam(m, p.string_value); | 162 WriteParam(m, p.string_value); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 ReadParam(m, iter, &p->ssl_valid) && | 274 ReadParam(m, iter, &p->ssl_valid) && |
| 375 ReadParam(m, iter, &p->preferred) && | 275 ReadParam(m, iter, &p->preferred) && |
| 376 ReadParam(m, iter, &p->blacklisted_by_user); | 276 ReadParam(m, iter, &p->blacklisted_by_user); |
| 377 } | 277 } |
| 378 void ParamTraits<webkit_glue::PasswordForm>::Log(const param_type& p, | 278 void ParamTraits<webkit_glue::PasswordForm>::Log(const param_type& p, |
| 379 std::string* l) { | 279 std::string* l) { |
| 380 l->append("<PasswordForm>"); | 280 l->append("<PasswordForm>"); |
| 381 } | 281 } |
| 382 | 282 |
| 383 } // namespace IPC | 283 } // namespace IPC |
| OLD | NEW |