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

Side by Side Diff: ui/gfx/ipc/gfx_param_traits.cc

Issue 1966983003: Generate param traits size methods for IPC files in content/ (and traits it depends on). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gfx/ipc/gfx_param_traits.h" 5 #include "ui/gfx/ipc/gfx_param_traits.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "ui/gfx/range/range.h" 12 #include "ui/gfx/range/range.h"
13 13
14 #if defined(OS_MACOSX) 14 #if defined(OS_MACOSX)
15 #include "ipc/mach_port_mac.h" 15 #include "ipc/mach_port_mac.h"
16 #endif 16 #endif
17 17
18 namespace IPC { 18 namespace IPC {
19 19
20 void ParamTraits<gfx::Range>::GetSize(base::PickleSizer* s,
21 const gfx::Range& p) {
22 s->AddUInt32();
dcheng 2016/05/11 17:39:12 Would it make sense to add a ParamTraits::GetSize
jam 2016/05/11 17:57:02 GetParamSize already works. Switched this and othe
23 s->AddUInt32();
24 }
25
20 void ParamTraits<gfx::Range>::Write(base::Pickle* m, const gfx::Range& r) { 26 void ParamTraits<gfx::Range>::Write(base::Pickle* m, const gfx::Range& r) {
21 m->WriteUInt32(r.start()); 27 m->WriteUInt32(r.start());
22 m->WriteUInt32(r.end()); 28 m->WriteUInt32(r.end());
23 } 29 }
24 30
25 bool ParamTraits<gfx::Range>::Read(const base::Pickle* m, 31 bool ParamTraits<gfx::Range>::Read(const base::Pickle* m,
26 base::PickleIterator* iter, 32 base::PickleIterator* iter,
27 gfx::Range* r) { 33 gfx::Range* r) {
28 uint32_t start, end; 34 uint32_t start, end;
29 if (!iter->ReadUInt32(&start) || !iter->ReadUInt32(&end)) 35 if (!iter->ReadUInt32(&start) || !iter->ReadUInt32(&end))
30 return false; 36 return false;
31 r->set_start(start); 37 r->set_start(start);
32 r->set_end(end); 38 r->set_end(end);
33 return true; 39 return true;
34 } 40 }
35 41
36 void ParamTraits<gfx::Range>::Log(const gfx::Range& r, std::string* l) { 42 void ParamTraits<gfx::Range>::Log(const gfx::Range& r, std::string* l) {
37 l->append(base::StringPrintf("(%d, %d)", r.start(), r.end())); 43 l->append(base::StringPrintf("(%d, %d)", r.start(), r.end()));
38 } 44 }
39 45
40 #if defined(OS_MACOSX) && !defined(OS_IOS) 46 #if defined(OS_MACOSX) && !defined(OS_IOS)
47 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::GetSize(
48 base::PickleSizer* s, const param_type& p) {
49 MachPortMac mach_port_mac(p.get());
50 GetParamSize(s, mach_port_mac);
51 }
52
41 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( 53 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write(
42 base::Pickle* m, 54 base::Pickle* m,
43 const param_type p) { 55 const param_type p) {
44 MachPortMac mach_port_mac(p.get()); 56 MachPortMac mach_port_mac(p.get());
45 ParamTraits<MachPortMac>::Write(m, mach_port_mac); 57 ParamTraits<MachPortMac>::Write(m, mach_port_mac);
46 } 58 }
47 59
48 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( 60 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read(
49 const base::Pickle* m, 61 const base::Pickle* m,
50 base::PickleIterator* iter, 62 base::PickleIterator* iter,
51 param_type* r) { 63 param_type* r) {
52 MachPortMac mach_port_mac; 64 MachPortMac mach_port_mac;
53 if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac)) 65 if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac))
54 return false; 66 return false;
55 r->reset(mach_port_mac.get_mach_port()); 67 r->reset(mach_port_mac.get_mach_port());
56 return true; 68 return true;
57 } 69 }
58 70
59 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Log( 71 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Log(
60 const param_type& p, 72 const param_type& p,
61 std::string* l) { 73 std::string* l) {
62 l->append("IOSurface Mach send right: "); 74 l->append("IOSurface Mach send right: ");
63 LogParam(p.get(), l); 75 LogParam(p.get(), l);
64 } 76 }
65 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 77 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
66 78
67 } // namespace IPC 79 } // namespace IPC
68 80
81 // Generate param traits size methods.
82 #include "ipc/param_traits_size_macros.h"
83 namespace IPC {
84 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
85 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
86 }
87
69 // Generate param traits write methods. 88 // Generate param traits write methods.
70 #include "ipc/param_traits_write_macros.h" 89 #include "ipc/param_traits_write_macros.h"
71 namespace IPC { 90 namespace IPC {
72 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 91 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
73 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 92 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
74 } // namespace IPC 93 } // namespace IPC
75 94
76 // Generate param traits read methods. 95 // Generate param traits read methods.
77 #include "ipc/param_traits_read_macros.h" 96 #include "ipc/param_traits_read_macros.h"
78 namespace IPC { 97 namespace IPC {
79 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 98 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
80 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 99 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
81 } // namespace IPC 100 } // namespace IPC
82 101
83 // Generate param traits log methods. 102 // Generate param traits log methods.
84 #include "ipc/param_traits_log_macros.h" 103 #include "ipc/param_traits_log_macros.h"
85 namespace IPC { 104 namespace IPC {
86 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 105 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
87 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 106 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
88 } // namespace IPC 107 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698