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

Side by Side Diff: content/public/common/common_param_traits.cc

Issue 1560553002: Framelet Prototype 2016 Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + Applied Brett's Windows + Fixed security issue Created 4 years, 11 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
OLDNEW
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/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/common/input/web_input_event_traits.h"
10 #include "content/public/common/page_state.h" 11 #include "content/public/common/page_state.h"
11 #include "content/public/common/referrer.h" 12 #include "content/public/common/referrer.h"
12 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
13 #include "net/base/ip_address.h" 14 #include "net/base/ip_address.h"
14 #include "net/base/ip_endpoint.h" 15 #include "net/base/ip_endpoint.h"
15 16
16 namespace IPC { 17 namespace IPC {
17 18
18 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { 19 void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
19 if (p.possibly_invalid_spec().length() > content::kMaxURLChars) { 20 if (p.possibly_invalid_spec().length() > content::kMaxURLChars) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return true; 179 return true;
179 } 180 }
180 181
181 void ParamTraits<content::PageState>::Log( 182 void ParamTraits<content::PageState>::Log(
182 const param_type& p, std::string* l) { 183 const param_type& p, std::string* l) {
183 l->append("("); 184 l->append("(");
184 LogParam(p.ToEncodedData(), l); 185 LogParam(p.ToEncodedData(), l);
185 l->append(")"); 186 l->append(")");
186 } 187 }
187 188
189 void ParamTraits<WebInputEventPointer>::Write(Message* m, const param_type& p) {
190 m->WriteData(reinterpret_cast<const char*>(p), p->size);
191 }
192
193 bool ParamTraits<WebInputEventPointer>::Read(const Message* m,
194 base::PickleIterator* iter,
195 param_type* r) {
196 const char* data;
197 int data_length;
198 if (!iter->ReadData(&data, &data_length)) {
199 NOTREACHED();
200 return false;
201 }
202 if (data_length < static_cast<int>(sizeof(blink::WebInputEvent))) {
203 NOTREACHED();
204 return false;
205 }
206 param_type event = reinterpret_cast<param_type>(data);
207 // Check that the data size matches that of the event.
208 if (data_length != static_cast<int>(event->size)) {
209 NOTREACHED();
210 return false;
211 }
212 const size_t expected_size_for_type =
213 content::WebInputEventTraits::GetSize(event->type);
214 if (data_length != static_cast<int>(expected_size_for_type)) {
215 NOTREACHED();
216 return false;
217 }
218 *r = event;
219 return true;
220 }
221
222 void ParamTraits<WebInputEventPointer>::Log(const param_type& p,
223 std::string* l) {
224 l->append("(");
225 LogParam(p->size, l);
226 l->append(", ");
227 LogParam(p->type, l);
228 l->append(", ");
229 LogParam(p->timeStampSeconds, l);
230 l->append(")");
231 }
232
233 void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m,
234 const param_type& p) {
235 bool valid_web_event = !!p;
236 WriteParam(m, valid_web_event);
237 if (valid_web_event)
238 WriteParam(m, static_cast<WebInputEventPointer>(p.get()));
239 }
240
241 bool ParamTraits<content::ScopedWebInputEvent>::Read(const Message* m,
242 base::PickleIterator* iter,
243 param_type* p) {
244 bool valid_web_event = false;
245 WebInputEventPointer web_event_pointer = NULL;
246 if (!ReadParam(m, iter, &valid_web_event) || !valid_web_event ||
247 !ReadParam(m, iter, &web_event_pointer) || !web_event_pointer)
248 return false;
249
250 (*p) = content::WebInputEventTraits::Clone(*web_event_pointer);
251 return true;
252 }
253
254 void ParamTraits<content::ScopedWebInputEvent>::Log(const param_type& p,
255 std::string* l) {
256 LogParam(static_cast<WebInputEventPointer>(p.get()), l);
257 }
258
188 } // namespace IPC 259 } // namespace IPC
189 260
190 // Generate param traits write methods. 261 // Generate param traits write methods.
191 #include "ipc/param_traits_write_macros.h" 262 #include "ipc/param_traits_write_macros.h"
192 namespace IPC { 263 namespace IPC {
193 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 264 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
194 #include "content/public/common/common_param_traits_macros.h" 265 #include "content/public/common/common_param_traits_macros.h"
195 } // namespace IPC 266 } // namespace IPC
196 267
197 // Generate param traits read methods. 268 // Generate param traits read methods.
198 #include "ipc/param_traits_read_macros.h" 269 #include "ipc/param_traits_read_macros.h"
199 namespace IPC { 270 namespace IPC {
200 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 271 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
201 #include "content/public/common/common_param_traits_macros.h" 272 #include "content/public/common/common_param_traits_macros.h"
202 } // namespace IPC 273 } // namespace IPC
203 274
204 // Generate param traits log methods. 275 // Generate param traits log methods.
205 #include "ipc/param_traits_log_macros.h" 276 #include "ipc/param_traits_log_macros.h"
206 namespace IPC { 277 namespace IPC {
207 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 278 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
208 #include "content/public/common/common_param_traits_macros.h" 279 #include "content/public/common/common_param_traits_macros.h"
209 } // namespace IPC 280 } // namespace IPC
OLDNEW
« no previous file with comments | « content/public/common/common_param_traits.h ('k') | content/public/common/common_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698