OLD | NEW |
---|---|
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 #include "ui/base/models/menu_model.h" | 5 #include "ui/base/models/menu_model.h" |
6 | 6 |
7 // Get basic type definitions. | 7 // Get basic type definitions. |
8 #define IPC_MESSAGE_IMPL | 8 #define IPC_MESSAGE_IMPL |
9 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 break; | 214 break; |
215 } | 215 } |
216 } | 216 } |
217 return true; | 217 return true; |
218 } | 218 } |
219 static void Log(const param_type& p, std::string* l) { | 219 static void Log(const param_type& p, std::string* l) { |
220 l->append("<net::UploadElement>"); | 220 l->append("<net::UploadElement>"); |
221 } | 221 } |
222 }; | 222 }; |
223 | 223 |
224 template<> | |
225 struct ParamTraits<ScopedVector<net::UploadElement> > { | |
jam
2012/11/09 17:38:48
can you add a param traits for ScopedVector that's
hashimoto
2012/11/10 09:34:52
Moved this to ipc_messge_utils.h.
I've switched f
jam
2012/11/12 20:58:54
I'm not sure what you mean. you mean when it comes
hashimoto
2012/11/13 05:03:51
I thought this size check was to avoid copying hea
| |
226 typedef ScopedVector<net::UploadElement> param_type; | |
227 static void Write(Message* m, const param_type& p) { | |
228 WriteParam(m, static_cast<int>(p.size())); | |
229 for (size_t i = 0; i < p.size(); i++) | |
230 WriteParam(m, *p[i]); | |
231 } | |
232 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { | |
233 int size = 0; | |
234 // ReadLength() checks for < 0 itself. | |
235 if (!m->ReadLength(iter, &size)) | |
236 return false; | |
237 r->resize(size); | |
238 for (int i = 0; i < size; i++) { | |
239 (*r)[i] = new net::UploadElement(); | |
240 if (!ReadParam(m, iter, (*r)[i])) | |
241 return false; | |
242 } | |
243 return true; | |
244 } | |
245 static void Log(const param_type& p, std::string* l) { | |
246 for (size_t i = 0; i < p.size(); ++i) { | |
247 if (i != 0) | |
248 l->append(" "); | |
249 LogParam(*p[i], l); | |
250 } | |
251 } | |
252 }; | |
253 | |
224 void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, | 254 void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, |
225 const param_type& p) { | 255 const param_type& p) { |
226 WriteParam(m, p.get() != NULL); | 256 WriteParam(m, p.get() != NULL); |
227 if (p) { | 257 if (p) { |
228 WriteParam(m, *p->elements()); | 258 WriteParam(m, p->elements()); |
229 WriteParam(m, p->identifier()); | 259 WriteParam(m, p->identifier()); |
230 WriteParam(m, p->is_chunked()); | 260 WriteParam(m, p->is_chunked()); |
231 WriteParam(m, p->last_chunk_appended()); | 261 WriteParam(m, p->last_chunk_appended()); |
232 } | 262 } |
233 } | 263 } |
234 | 264 |
235 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, | 265 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, |
236 PickleIterator* iter, | 266 PickleIterator* iter, |
237 param_type* r) { | 267 param_type* r) { |
238 bool has_object; | 268 bool has_object; |
239 if (!ReadParam(m, iter, &has_object)) | 269 if (!ReadParam(m, iter, &has_object)) |
240 return false; | 270 return false; |
241 if (!has_object) | 271 if (!has_object) |
242 return true; | 272 return true; |
243 std::vector<net::UploadElement> elements; | 273 ScopedVector<net::UploadElement> elements; |
244 if (!ReadParam(m, iter, &elements)) | 274 if (!ReadParam(m, iter, &elements)) |
245 return false; | 275 return false; |
246 int64 identifier; | 276 int64 identifier; |
247 if (!ReadParam(m, iter, &identifier)) | 277 if (!ReadParam(m, iter, &identifier)) |
248 return false; | 278 return false; |
249 bool is_chunked = false; | 279 bool is_chunked = false; |
250 if (!ReadParam(m, iter, &is_chunked)) | 280 if (!ReadParam(m, iter, &is_chunked)) |
251 return false; | 281 return false; |
252 bool last_chunk_appended = false; | 282 bool last_chunk_appended = false; |
253 if (!ReadParam(m, iter, &last_chunk_appended)) | 283 if (!ReadParam(m, iter, &last_chunk_appended)) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 LogParam(status, l); | 338 LogParam(status, l); |
309 | 339 |
310 if (p.status() == net::URLRequestStatus::FAILED) { | 340 if (p.status() == net::URLRequestStatus::FAILED) { |
311 l->append(", "); | 341 l->append(", "); |
312 LogParam(p.error(), l); | 342 LogParam(p.error(), l); |
313 l->append(")"); | 343 l->append(")"); |
314 } | 344 } |
315 } | 345 } |
316 | 346 |
317 } // namespace IPC | 347 } // namespace IPC |
OLD | NEW |