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

Side by Side Diff: remoting/host/chromoting_param_traits.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « ppapi/proxy/url_loader_resource.cc ('k') | sandbox/linux/syscall_broker/broker_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
9 9
10 namespace IPC { 10 namespace IPC {
11 11
12 // static 12 // static
13 void ParamTraits<webrtc::DesktopVector>::Write(Message* m, 13 void ParamTraits<webrtc::DesktopVector>::Write(Message* m,
14 const webrtc::DesktopVector& p) { 14 const webrtc::DesktopVector& p) {
15 m->WriteInt(p.x()); 15 m->WriteInt(p.x());
16 m->WriteInt(p.y()); 16 m->WriteInt(p.y());
17 } 17 }
18 18
19 // static 19 // static
20 bool ParamTraits<webrtc::DesktopVector>::Read(const Message* m, 20 bool ParamTraits<webrtc::DesktopVector>::Read(const Message* m,
21 PickleIterator* iter, 21 base::PickleIterator* iter,
22 webrtc::DesktopVector* r) { 22 webrtc::DesktopVector* r) {
23 int x, y; 23 int x, y;
24 if (!iter->ReadInt(&x) || !iter->ReadInt(&y)) 24 if (!iter->ReadInt(&x) || !iter->ReadInt(&y))
25 return false; 25 return false;
26 *r = webrtc::DesktopVector(x, y); 26 *r = webrtc::DesktopVector(x, y);
27 return true; 27 return true;
28 } 28 }
29 29
30 // static 30 // static
31 void ParamTraits<webrtc::DesktopVector>::Log(const webrtc::DesktopVector& p, 31 void ParamTraits<webrtc::DesktopVector>::Log(const webrtc::DesktopVector& p,
32 std::string* l) { 32 std::string* l) {
33 l->append(base::StringPrintf("webrtc::DesktopVector(%d, %d)", 33 l->append(base::StringPrintf("webrtc::DesktopVector(%d, %d)",
34 p.x(), p.y())); 34 p.x(), p.y()));
35 } 35 }
36 36
37 // static 37 // static
38 void ParamTraits<webrtc::DesktopSize>::Write(Message* m, 38 void ParamTraits<webrtc::DesktopSize>::Write(Message* m,
39 const webrtc::DesktopSize& p) { 39 const webrtc::DesktopSize& p) {
40 m->WriteInt(p.width()); 40 m->WriteInt(p.width());
41 m->WriteInt(p.height()); 41 m->WriteInt(p.height());
42 } 42 }
43 43
44 // static 44 // static
45 bool ParamTraits<webrtc::DesktopSize>::Read(const Message* m, 45 bool ParamTraits<webrtc::DesktopSize>::Read(const Message* m,
46 PickleIterator* iter, 46 base::PickleIterator* iter,
47 webrtc::DesktopSize* r) { 47 webrtc::DesktopSize* r) {
48 int width, height; 48 int width, height;
49 if (!iter->ReadInt(&width) || !iter->ReadInt(&height)) 49 if (!iter->ReadInt(&width) || !iter->ReadInt(&height))
50 return false; 50 return false;
51 *r = webrtc::DesktopSize(width, height); 51 *r = webrtc::DesktopSize(width, height);
52 return true; 52 return true;
53 } 53 }
54 54
55 // static 55 // static
56 void ParamTraits<webrtc::DesktopSize>::Log(const webrtc::DesktopSize& p, 56 void ParamTraits<webrtc::DesktopSize>::Log(const webrtc::DesktopSize& p,
57 std::string* l) { 57 std::string* l) {
58 l->append(base::StringPrintf("webrtc::DesktopSize(%d, %d)", 58 l->append(base::StringPrintf("webrtc::DesktopSize(%d, %d)",
59 p.width(), p.height())); 59 p.width(), p.height()));
60 } 60 }
61 61
62 // static 62 // static
63 void ParamTraits<webrtc::DesktopRect>::Write(Message* m, 63 void ParamTraits<webrtc::DesktopRect>::Write(Message* m,
64 const webrtc::DesktopRect& p) { 64 const webrtc::DesktopRect& p) {
65 m->WriteInt(p.left()); 65 m->WriteInt(p.left());
66 m->WriteInt(p.top()); 66 m->WriteInt(p.top());
67 m->WriteInt(p.right()); 67 m->WriteInt(p.right());
68 m->WriteInt(p.bottom()); 68 m->WriteInt(p.bottom());
69 } 69 }
70 70
71 // static 71 // static
72 bool ParamTraits<webrtc::DesktopRect>::Read(const Message* m, 72 bool ParamTraits<webrtc::DesktopRect>::Read(const Message* m,
73 PickleIterator* iter, 73 base::PickleIterator* iter,
74 webrtc::DesktopRect* r) { 74 webrtc::DesktopRect* r) {
75 int left, right, top, bottom; 75 int left, right, top, bottom;
76 if (!iter->ReadInt(&left) || !iter->ReadInt(&top) || 76 if (!iter->ReadInt(&left) || !iter->ReadInt(&top) ||
77 !iter->ReadInt(&right) || !iter->ReadInt(&bottom)) { 77 !iter->ReadInt(&right) || !iter->ReadInt(&bottom)) {
78 return false; 78 return false;
79 } 79 }
80 *r = webrtc::DesktopRect::MakeLTRB(left, top, right, bottom); 80 *r = webrtc::DesktopRect::MakeLTRB(left, top, right, bottom);
81 return true; 81 return true;
82 } 82 }
83 83
(...skipping 19 matching lines...) Expand all
103 current_row + p.image()->size().width() * 103 current_row + p.image()->size().width() *
104 webrtc::DesktopFrame::kBytesPerPixel); 104 webrtc::DesktopFrame::kBytesPerPixel);
105 current_row += p.image()->stride(); 105 current_row += p.image()->stride();
106 } 106 }
107 m->WriteData(reinterpret_cast<const char*>(p.image()->data()), data.size()); 107 m->WriteData(reinterpret_cast<const char*>(p.image()->data()), data.size());
108 108
109 ParamTraits<webrtc::DesktopVector>::Write(m, p.hotspot()); 109 ParamTraits<webrtc::DesktopVector>::Write(m, p.hotspot());
110 } 110 }
111 111
112 // static 112 // static
113 bool ParamTraits<webrtc::MouseCursor>::Read( 113 bool ParamTraits<webrtc::MouseCursor>::Read(const Message* m,
114 const Message* m, 114 base::PickleIterator* iter,
115 PickleIterator* iter, 115 webrtc::MouseCursor* r) {
116 webrtc::MouseCursor* r) {
117 webrtc::DesktopSize size; 116 webrtc::DesktopSize size;
118 if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) || 117 if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) ||
119 size.width() <= 0 || size.width() > (SHRT_MAX / 2) || 118 size.width() <= 0 || size.width() > (SHRT_MAX / 2) ||
120 size.height() <= 0 || size.height() > (SHRT_MAX / 2)) { 119 size.height() <= 0 || size.height() > (SHRT_MAX / 2)) {
121 return false; 120 return false;
122 } 121 }
123 122
124 const int expected_length = 123 const int expected_length =
125 size.width() * size.height() * webrtc::DesktopFrame::kBytesPerPixel; 124 size.width() * size.height() * webrtc::DesktopFrame::kBytesPerPixel;
126 125
(...skipping 29 matching lines...) Expand all
156 void ParamTraits<remoting::ScreenResolution>::Write( 155 void ParamTraits<remoting::ScreenResolution>::Write(
157 Message* m, 156 Message* m,
158 const remoting::ScreenResolution& p) { 157 const remoting::ScreenResolution& p) {
159 ParamTraits<webrtc::DesktopSize>::Write(m, p.dimensions()); 158 ParamTraits<webrtc::DesktopSize>::Write(m, p.dimensions());
160 ParamTraits<webrtc::DesktopVector>::Write(m, p.dpi()); 159 ParamTraits<webrtc::DesktopVector>::Write(m, p.dpi());
161 } 160 }
162 161
163 // static 162 // static
164 bool ParamTraits<remoting::ScreenResolution>::Read( 163 bool ParamTraits<remoting::ScreenResolution>::Read(
165 const Message* m, 164 const Message* m,
166 PickleIterator* iter, 165 base::PickleIterator* iter,
167 remoting::ScreenResolution* r) { 166 remoting::ScreenResolution* r) {
168 webrtc::DesktopSize size; 167 webrtc::DesktopSize size;
169 webrtc::DesktopVector dpi; 168 webrtc::DesktopVector dpi;
170 if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) || 169 if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) ||
171 !ParamTraits<webrtc::DesktopVector>::Read(m, iter, &dpi)) { 170 !ParamTraits<webrtc::DesktopVector>::Read(m, iter, &dpi)) {
172 return false; 171 return false;
173 } 172 }
174 if (size.width() < 0 || size.height() < 0 || 173 if (size.width() < 0 || size.height() < 0 ||
175 dpi.x() < 0 || dpi.y() < 0) { 174 dpi.x() < 0 || dpi.y() < 0) {
176 return false; 175 return false;
177 } 176 }
178 *r = remoting::ScreenResolution(size, dpi); 177 *r = remoting::ScreenResolution(size, dpi);
179 return true; 178 return true;
180 } 179 }
181 180
182 // static 181 // static
183 void ParamTraits<remoting::ScreenResolution>::Log( 182 void ParamTraits<remoting::ScreenResolution>::Log(
184 const remoting::ScreenResolution& p, 183 const remoting::ScreenResolution& p,
185 std::string* l) { 184 std::string* l) {
186 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)", 185 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)",
187 p.dimensions().width(), p.dimensions().height(), 186 p.dimensions().width(), p.dimensions().height(),
188 p.dpi().x(), p.dpi().y())); 187 p.dpi().x(), p.dpi().y()));
189 } 188 }
190 189
191 } // namespace IPC 190 } // namespace IPC
192 191
OLDNEW
« no previous file with comments | « ppapi/proxy/url_loader_resource.cc ('k') | sandbox/linux/syscall_broker/broker_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698