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 base::StringPiece data(base::RefCountedMemory::AsString(p.get())); |
| 18 m->WriteData(data.data(), data.size()); |
| 19 } |
| 20 |
| 21 bool ParamTraits<scoped_refptr<base::RefCountedMemory> >::Read( |
| 22 const Message* m, |
| 23 PickleIterator* iter, |
| 24 param_type* p) { |
| 25 const char* data; |
| 26 int len; |
| 27 if (!m->ReadData(iter, &data, &len)) |
| 28 return false; |
| 29 if (len > 0) { |
| 30 scoped_refptr<base::RefCountedString> res = new base::RefCountedString; |
| 31 res->data().assign(data, len); |
| 32 *p = res; |
| 33 } else { |
| 34 *p = NULL; |
| 35 } |
| 36 return true; |
| 37 } |
| 38 |
| 39 void ParamTraits<scoped_refptr<base::RefCountedMemory> >::Log( |
| 40 const param_type& p, std::string* l) { |
| 41 l->append("(RefCountedMemory: "); |
| 42 base::RefCountedMemory::AsString(p.get()).AppendToString(l); |
| 43 l->append(")"); |
| 44 } |
| 45 |
14 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { | 46 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { |
15 WriteParam(m, p.address()); | 47 WriteParam(m, p.address()); |
16 WriteParam(m, p.port()); | 48 WriteParam(m, p.port()); |
17 } | 49 } |
18 | 50 |
19 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, | 51 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, |
20 param_type* p) { | 52 param_type* p) { |
21 net::IPAddressNumber address; | 53 net::IPAddressNumber address; |
22 int port; | 54 int port; |
23 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) | 55 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_ | 141 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
110 #include "content/common/content_param_traits_macros.h" | 142 #include "content/common/content_param_traits_macros.h" |
111 } // namespace IPC | 143 } // namespace IPC |
112 | 144 |
113 // Generate param traits log methods. | 145 // Generate param traits log methods. |
114 #include "ipc/param_traits_log_macros.h" | 146 #include "ipc/param_traits_log_macros.h" |
115 namespace IPC { | 147 namespace IPC { |
116 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 148 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
117 #include "content/common/content_param_traits_macros.h" | 149 #include "content/common/content_param_traits_macros.h" |
118 } // namespace IPC | 150 } // namespace IPC |
OLD | NEW |