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 |
| 205 net::IPAddress address(bytes); |
| 206 if (address.empty() || address.IsValid()) { |
| 207 *p = address; |
| 208 return true; |
| 209 } |
| 210 return false; |
| 211 } |
| 212 |
| 213 // static |
| 214 void ParamTraits<net::IPAddress>::Log(const param_type& p, std::string* l) { |
| 215 l->append("IPAddress:" + (p.empty() ? "(empty)" : p.ToString())); |
| 216 } |
| 217 |
| 218 // static |
| 219 void ParamTraits<net::IPEndPoint>::Write(base::Pickle* m, const param_type& p) { |
| 220 WriteParam(m, p.address()); |
| 221 WriteParam(m, p.port()); |
| 222 } |
| 223 |
| 224 // static |
| 225 bool ParamTraits<net::IPEndPoint>::Read(const base::Pickle* m, |
| 226 base::PickleIterator* iter, |
| 227 param_type* p) { |
| 228 net::IPAddress address; |
| 229 uint16_t port; |
| 230 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) |
| 231 return false; |
| 232 |
| 233 *p = net::IPEndPoint(address, port); |
| 234 return true; |
| 235 } |
| 236 |
| 237 // static |
| 238 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { |
| 239 l->append("IPEndPoint: " + p.ToString()); |
| 240 } |
| 241 |
191 } // namespace IPC | 242 } // namespace IPC |
192 | 243 |
OLD | NEW |