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

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

Issue 10818011: Allow floating point rectangles to be sent via IPC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/common_param_traits.h ('k') | ui/ui.gyp » ('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) 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 "content/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include "content/public/common/content_constants.h" 7 #include "content/public/common/content_constants.h"
8 #include "content/public/common/referrer.h" 8 #include "content/public/common/referrer.h"
9 #include "net/base/host_port_pair.h" 9 #include "net/base/host_port_pair.h"
10 #include "net/base/upload_data.h" 10 #include "net/base/upload_data.h"
11 #include "net/http/http_response_headers.h" 11 #include "net/http/http_response_headers.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/base/range/range.h" 13 #include "ui/base/range/range.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/rect_f.h"
15 16
16 namespace { 17 namespace {
17 18
18 struct SkBitmap_Data { 19 struct SkBitmap_Data {
19 // The configuration for the bitmap (bits per pixel, etc). 20 // The configuration for the bitmap (bits per pixel, etc).
20 SkBitmap::Config fConfig; 21 SkBitmap::Config fConfig;
21 22
22 // The width of the bitmap in pixels. 23 // The width of the bitmap in pixels.
23 uint32 fWidth; 24 uint32 fWidth;
24 25
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 r->set_width(w); 416 r->set_width(w);
416 r->set_height(h); 417 r->set_height(h);
417 return true; 418 return true;
418 } 419 }
419 420
420 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { 421 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
421 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), 422 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(),
422 p.width(), p.height())); 423 p.width(), p.height()));
423 } 424 }
424 425
426 void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) {
427 m->WriteFloat(p.x());
brettw 2012/07/23 19:06:21 I'd avoid adding anything to pickle and instead us
Leandro GraciĆ” Gil 2012/07/23 20:45:35 SGTM. Fixed. On 2012/07/23 19:06:21, brettw wrote
428 m->WriteFloat(p.y());
429 m->WriteFloat(p.width());
430 m->WriteFloat(p.height());
431 }
432
433 bool ParamTraits<gfx::RectF>::Read(const Message* m,
434 PickleIterator* iter,
435 gfx::RectF* r) {
436 float x, y, w, h;
437 if (!m->ReadFloat(iter, &x) ||
438 !m->ReadFloat(iter, &y) ||
439 !m->ReadFloat(iter, &w) ||
440 !m->ReadFloat(iter, &h))
441 return false;
442 r->set_x(x);
443 r->set_y(y);
444 r->set_width(w);
445 r->set_height(h);
446 return true;
447 }
448
449 void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) {
450 l->append(base::StringPrintf("(%f, %f, %f, %f)", p.x(), p.y(),
451 p.width(), p.height()));
452 }
453
425 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { 454 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) {
426 m->WriteUInt64(r.start()); 455 m->WriteUInt64(r.start());
427 m->WriteUInt64(r.end()); 456 m->WriteUInt64(r.end());
428 } 457 }
429 458
430 bool ParamTraits<ui::Range>::Read(const Message* m, 459 bool ParamTraits<ui::Range>::Read(const Message* m,
431 PickleIterator* iter, 460 PickleIterator* iter,
432 ui::Range* r) { 461 ui::Range* r) {
433 uint64 start, end; 462 uint64 start, end;
434 if (!m->ReadUInt64(iter, &start) || !m->ReadUInt64(iter, &end)) 463 if (!m->ReadUInt64(iter, &start) || !m->ReadUInt64(iter, &end))
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 527 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
499 #include "content/public/common/common_param_traits_macros.h" 528 #include "content/public/common/common_param_traits_macros.h"
500 } // namespace IPC 529 } // namespace IPC
501 530
502 // Generate param traits log methods. 531 // Generate param traits log methods.
503 #include "ipc/param_traits_log_macros.h" 532 #include "ipc/param_traits_log_macros.h"
504 namespace IPC { 533 namespace IPC {
505 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 534 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
506 #include "content/public/common/common_param_traits_macros.h" 535 #include "content/public/common/common_param_traits_macros.h"
507 } // namespace IPC 536 } // namespace IPC
OLDNEW
« no previous file with comments | « content/public/common/common_param_traits.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698