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 "content/common/content_param_traits.h" | 5 #include "content/common/content_param_traits.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "content/common/input/web_input_event_traits.h" | 8 #include "content/common/input/web_input_event_traits.h" |
9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
10 #include "ui/gfx/range/range.h" | 10 #include "ui/gfx/range/range.h" |
11 | 11 |
12 namespace IPC { | 12 namespace IPC { |
13 | 13 |
14 void ParamTraits<scoped_refptr<base::RefCountedMemory> >::Write( | |
15 Message* m, | |
16 const param_type& p) { | |
17 const char* data = NULL; | |
18 size_t size = 0; | |
19 if (p.get()) { | |
20 data = reinterpret_cast<const char*>(p->front()); | |
21 size = p->size(); | |
22 } | |
23 m->WriteData(data, size); | |
24 } | |
25 | |
26 bool ParamTraits<scoped_refptr<base::RefCountedMemory> >::Read( | |
27 const Message* m, | |
28 PickleIterator* iter, | |
29 param_type* p) { | |
30 const char* data; | |
31 int len; | |
32 if (!m->ReadData(iter, &data, &len)) | |
33 return false; | |
34 if (len > 0) { | |
35 scoped_refptr<base::RefCountedString> res = new base::RefCountedString; | |
36 res->data().assign(data, len); | |
jln (very slow on Chromium)
2013/12/02 23:05:25
This clearly needs a reasonable limit on len.
Thi
joth
2013/12/02 23:21:38
Good point.
The required use-case is only for sen
| |
37 *p = res; | |
38 } else { | |
39 *p = NULL; | |
40 } | |
41 return true; | |
42 } | |
43 | |
44 void ParamTraits<scoped_refptr<base::RefCountedMemory> >::Log( | |
45 const param_type& p, std::string* l) { | |
46 l->append("(RefCountedMemory)"); | |
47 } | |
48 | |
14 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { | 49 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { |
15 WriteParam(m, p.address()); | 50 WriteParam(m, p.address()); |
16 WriteParam(m, p.port()); | 51 WriteParam(m, p.port()); |
17 } | 52 } |
18 | 53 |
19 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, | 54 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, |
20 param_type* p) { | 55 param_type* p) { |
21 net::IPAddressNumber address; | 56 net::IPAddressNumber address; |
22 int port; | 57 int port; |
23 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) | 58 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 144 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
110 #include "content/common/content_param_traits_macros.h" | 145 #include "content/common/content_param_traits_macros.h" |
111 } // namespace IPC | 146 } // namespace IPC |
112 | 147 |
113 // Generate param traits log methods. | 148 // Generate param traits log methods. |
114 #include "ipc/param_traits_log_macros.h" | 149 #include "ipc/param_traits_log_macros.h" |
115 namespace IPC { | 150 namespace IPC { |
116 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 151 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
117 #include "content/common/content_param_traits_macros.h" | 152 #include "content/common/content_param_traits_macros.h" |
118 } // namespace IPC | 153 } // namespace IPC |
OLD | NEW |