OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/chromoting_param_traits.h" | 5 #include "remoting/host/chromoting_param_traits.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "ipc/ipc_message_utils.h" | |
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
11 | 12 |
12 namespace IPC { | 13 namespace IPC { |
13 | 14 |
14 // static | 15 // static |
15 void ParamTraits<webrtc::DesktopVector>::Write(base::Pickle* m, | 16 void ParamTraits<webrtc::DesktopVector>::Write(base::Pickle* m, |
16 const webrtc::DesktopVector& p) { | 17 const webrtc::DesktopVector& p) { |
17 m->WriteInt(p.x()); | 18 m->WriteInt(p.x()); |
18 m->WriteInt(p.y()); | 19 m->WriteInt(p.y()); |
19 } | 20 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 | 182 |
182 // static | 183 // static |
183 void ParamTraits<remoting::ScreenResolution>::Log( | 184 void ParamTraits<remoting::ScreenResolution>::Log( |
184 const remoting::ScreenResolution& p, | 185 const remoting::ScreenResolution& p, |
185 std::string* l) { | 186 std::string* l) { |
186 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)", | 187 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)", |
187 p.dimensions().width(), p.dimensions().height(), | 188 p.dimensions().width(), p.dimensions().height(), |
188 p.dpi().x(), p.dpi().y())); | 189 p.dpi().x(), p.dpi().y())); |
189 } | 190 } |
190 | 191 |
192 // static | |
193 void ParamTraits<net::IPAddress>::Write(base::Pickle* m, const param_type& p) { | |
194 WriteParam(m, p.bytes()); | |
195 } | |
196 | |
197 // static | |
198 bool ParamTraits<net::IPAddress>::Read(const base::Pickle* m, | |
199 base::PickleIterator* iter, | |
200 param_type* p) { | |
201 std::vector<uint8_t> bytes; | |
202 if (!ReadParam(m, iter, &bytes)) | |
203 return false; | |
204 if (bytes.size() && bytes.size() != net::IPAddress::kIPv4AddressSize && | |
205 bytes.size() != net::IPAddress::kIPv6AddressSize) { | |
Wez
2016/04/05 17:08:01
This would be more readable as:
if (bytes.empty()
martijnc
2016/04/05 20:08:48
Done.
| |
206 return false; | |
207 } | |
208 *p = net::IPAddress(bytes); | |
209 return true; | |
210 } | |
211 | |
212 // static | |
213 void ParamTraits<net::IPAddress>::Log(const param_type& p, std::string* l) { | |
214 l->append("IPAddress:" + (p.empty() ? "(empty)" : p.ToString())); | |
215 } | |
216 | |
217 // static | |
218 void ParamTraits<net::IPEndPoint>::Write(base::Pickle* m, const param_type& p) { | |
219 WriteParam(m, p.address()); | |
220 WriteParam(m, p.port()); | |
221 } | |
222 | |
223 // static | |
224 bool ParamTraits<net::IPEndPoint>::Read(const base::Pickle* m, | |
225 base::PickleIterator* iter, | |
226 param_type* p) { | |
227 net::IPAddress address; | |
228 uint16_t port; | |
229 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) | |
230 return false; | |
231 if (!address.empty() && !address.IsValid()) | |
Wez
2016/04/05 17:08:01
Similarly, this is painful to parse; better to hav
martijnc
2016/04/05 20:08:48
Done.
(the IPAddress should always be valid (or e
Wez
2016/04/05 20:12:27
The IPAddress ParamTraits doesn't seem to do an Is
martijnc
2016/04/05 21:16:29
Done.
| |
232 return false; | |
233 | |
234 *p = net::IPEndPoint(address, port); | |
235 return true; | |
236 } | |
237 | |
238 // static | |
239 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { | |
240 l->append("IPEndPoint: " + p.ToString()); | |
241 } | |
242 | |
191 } // namespace IPC | 243 } // namespace IPC |
192 | 244 |
OLD | NEW |