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

Side by Side Diff: chrome/common/common_param_traits.cc

Issue 3119035: FBTF: Move individual XXXMsg_Params structs to a new file. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix comment Created 10 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/common/common_param_traits.h ('k') | chrome/common/common_param_traits_unittest.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/common_param_traits.h" 5 #include "chrome/common/common_param_traits.h"
6 6
7 #include "chrome/common/chrome_constants.h" 7 #include "chrome/common/chrome_constants.h"
8 #include "chrome/common/content_settings.h" 8 #include "chrome/common/content_settings.h"
9 #include "chrome/common/geoposition.h"
9 #include "chrome/common/thumbnail_score.h" 10 #include "chrome/common/thumbnail_score.h"
10 #include "gfx/rect.h" 11 #include "gfx/rect.h"
11 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "net/base/upload_data.h"
12 #include "printing/native_metafile.h" 14 #include "printing/native_metafile.h"
13 #include "printing/page_range.h" 15 #include "printing/page_range.h"
14 16
15 #ifndef EXCLUDE_SKIA_DEPENDENCIES 17 #ifndef EXCLUDE_SKIA_DEPENDENCIES
16 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
17 #endif 19 #endif
18 #include "webkit/glue/dom_operations.h" 20 #include "webkit/glue/dom_operations.h"
19 #include "webkit/glue/password_form.h" 21 #include "webkit/glue/password_form.h"
20 22
21 namespace IPC { 23 namespace IPC {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 310
309 LogParam(status, l); 311 LogParam(status, l);
310 312
311 if (p.status() == URLRequestStatus::FAILED) { 313 if (p.status() == URLRequestStatus::FAILED) {
312 l->append(", "); 314 l->append(", ");
313 LogParam(p.os_error(), l); 315 LogParam(p.os_error(), l);
314 l->append(")"); 316 l->append(")");
315 } 317 }
316 } 318 }
317 319
320 // Only the net::UploadData ParamTraits<> definition needs this definition, so
321 // keep this in the implementation file so we can forward declare UploadData in
322 // the header.
323 template <>
324 struct ParamTraits<net::UploadData::Element> {
325 typedef net::UploadData::Element param_type;
326 static void Write(Message* m, const param_type& p) {
327 WriteParam(m, static_cast<int>(p.type()));
328 if (p.type() == net::UploadData::TYPE_BYTES) {
329 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size()));
330 } else {
331 WriteParam(m, p.file_path());
332 WriteParam(m, p.file_range_offset());
333 WriteParam(m, p.file_range_length());
334 WriteParam(m, p.expected_file_modification_time());
335 }
336 }
337 static bool Read(const Message* m, void** iter, param_type* r) {
338 int type;
339 if (!ReadParam(m, iter, &type))
340 return false;
341 if (type == net::UploadData::TYPE_BYTES) {
342 const char* data;
343 int len;
344 if (!m->ReadData(iter, &data, &len))
345 return false;
346 r->SetToBytes(data, len);
347 } else {
348 DCHECK(type == net::UploadData::TYPE_FILE);
349 FilePath file_path;
350 uint64 offset, length;
351 base::Time expected_modification_time;
352 if (!ReadParam(m, iter, &file_path))
353 return false;
354 if (!ReadParam(m, iter, &offset))
355 return false;
356 if (!ReadParam(m, iter, &length))
357 return false;
358 if (!ReadParam(m, iter, &expected_modification_time))
359 return false;
360 r->SetToFilePathRange(file_path, offset, length,
361 expected_modification_time);
362 }
363 return true;
364 }
365 static void Log(const param_type& p, std::string* l) {
366 l->append("<net::UploadData::Element>");
367 }
368 };
369
370 void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m,
371 const param_type& p) {
372 WriteParam(m, p.get() != NULL);
373 if (p) {
374 WriteParam(m, *p->elements());
375 WriteParam(m, p->identifier());
376 }
377 }
378
379 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m,
380 void** iter,
381 param_type* r) {
382 bool has_object;
383 if (!ReadParam(m, iter, &has_object))
384 return false;
385 if (!has_object)
386 return true;
387 std::vector<net::UploadData::Element> elements;
388 if (!ReadParam(m, iter, &elements))
389 return false;
390 int64 identifier;
391 if (!ReadParam(m, iter, &identifier))
392 return false;
393 *r = new net::UploadData;
394 (*r)->swap_elements(&elements);
395 (*r)->set_identifier(identifier);
396 return true;
397 }
398
399 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p,
400 std::string* l) {
401 l->append("<net::UploadData>");
402 }
403
318 void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) { 404 void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) {
319 IPC::ParamTraits<double>::Write(m, p.boring_score); 405 IPC::ParamTraits<double>::Write(m, p.boring_score);
320 IPC::ParamTraits<bool>::Write(m, p.good_clipping); 406 IPC::ParamTraits<bool>::Write(m, p.good_clipping);
321 IPC::ParamTraits<bool>::Write(m, p.at_top); 407 IPC::ParamTraits<bool>::Write(m, p.at_top);
322 IPC::ParamTraits<base::Time>::Write(m, p.time_at_snapshot); 408 IPC::ParamTraits<base::Time>::Write(m, p.time_at_snapshot);
323 } 409 }
324 410
325 bool ParamTraits<ThumbnailScore>::Read(const Message* m, void** iter, 411 bool ParamTraits<ThumbnailScore>::Read(const Message* m, void** iter,
326 param_type* r) { 412 param_type* r) {
327 double boring_score; 413 double boring_score;
(...skipping 10 matching lines...) Expand all
338 r->at_top = at_top; 424 r->at_top = at_top;
339 r->time_at_snapshot = time_at_snapshot; 425 r->time_at_snapshot = time_at_snapshot;
340 return true; 426 return true;
341 } 427 }
342 428
343 void ParamTraits<ThumbnailScore>::Log(const param_type& p, std::string* l) { 429 void ParamTraits<ThumbnailScore>::Log(const param_type& p, std::string* l) {
344 l->append(StringPrintf("(%f, %d, %d)", 430 l->append(StringPrintf("(%f, %d, %d)",
345 p.boring_score, p.good_clipping, p.at_top)); 431 p.boring_score, p.good_clipping, p.at_top));
346 } 432 }
347 433
348 void ParamTraits<Geoposition::ErrorCode>::Write( 434 template <>
349 Message* m, const Geoposition::ErrorCode& p) { 435 struct ParamTraits<Geoposition::ErrorCode> {
350 int error_code = p; 436 typedef Geoposition::ErrorCode param_type;
351 WriteParam(m, error_code); 437 static void Write(Message* m, const param_type& p) {
352 } 438 int error_code = p;
353 439 WriteParam(m, error_code);
354 bool ParamTraits<Geoposition::ErrorCode>::Read( 440 }
355 const Message* m, void** iter, Geoposition::ErrorCode* p) { 441 static bool Read(const Message* m, void** iter, param_type* p) {
356 int error_code_param = 0; 442 int error_code_param = 0;
357 bool ret = ReadParam(m, iter, &error_code_param); 443 bool ret = ReadParam(m, iter, &error_code_param);
358 *p = static_cast<Geoposition::ErrorCode>(error_code_param); 444 *p = static_cast<Geoposition::ErrorCode>(error_code_param);
359 return ret; 445 return ret;
360 } 446 }
361 447 static void Log(const param_type& p, std::string* l) {
362 void ParamTraits<Geoposition::ErrorCode>::Log( 448 int error_code = p;
363 const Geoposition::ErrorCode& p, std::string* l) { 449 l->append(StringPrintf("<Geoposition::ErrorCode>%d", error_code));
364 int error_code = p; 450 }
365 l->append(StringPrintf("<Geoposition::ErrorCode>%d", error_code)); 451 };
366 }
367 452
368 void ParamTraits<Geoposition>::Write(Message* m, const Geoposition& p) { 453 void ParamTraits<Geoposition>::Write(Message* m, const Geoposition& p) {
369 WriteParam(m, p.latitude); 454 WriteParam(m, p.latitude);
370 WriteParam(m, p.longitude); 455 WriteParam(m, p.longitude);
371 WriteParam(m, p.accuracy); 456 WriteParam(m, p.accuracy);
372 WriteParam(m, p.altitude); 457 WriteParam(m, p.altitude);
373 WriteParam(m, p.altitude_accuracy); 458 WriteParam(m, p.altitude_accuracy);
374 WriteParam(m, p.speed); 459 WriteParam(m, p.speed);
375 WriteParam(m, p.heading); 460 WriteParam(m, p.heading);
376 WriteParam(m, p.timestamp); 461 WriteParam(m, p.timestamp);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 p->Init(&buffer.front(), static_cast<uint32>(buffer.size())); 573 p->Init(&buffer.front(), static_cast<uint32>(buffer.size()));
489 #endif // defined(OS_WIN) 574 #endif // defined(OS_WIN)
490 } 575 }
491 576
492 void ParamTraits<printing::NativeMetafile>::Log( 577 void ParamTraits<printing::NativeMetafile>::Log(
493 const param_type& p, std::string* l) { 578 const param_type& p, std::string* l) {
494 l->append("<printing::NativeMetafile>"); 579 l->append("<printing::NativeMetafile>");
495 } 580 }
496 581
497 } // namespace IPC 582 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/common_param_traits.h ('k') | chrome/common/common_param_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698