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

Side by Side Diff: content/common/content_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
« no previous file with comments | « content/common/content_param_traits.h ('k') | content/common/content_param_traits_macros.h » ('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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "content/common/input/web_input_event_traits.h"
11 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
12 11
13 namespace IPC {
14
15 void ParamTraits<WebInputEventPointer>::Write(Message* m, const param_type& p) {
16 m->WriteData(reinterpret_cast<const char*>(p), p->size);
17 }
18
19 bool ParamTraits<WebInputEventPointer>::Read(const Message* m,
20 base::PickleIterator* iter,
21 param_type* r) {
22 const char* data;
23 int data_length;
24 if (!iter->ReadData(&data, &data_length)) {
25 NOTREACHED();
26 return false;
27 }
28 if (data_length < static_cast<int>(sizeof(blink::WebInputEvent))) {
29 NOTREACHED();
30 return false;
31 }
32 param_type event = reinterpret_cast<param_type>(data);
33 // Check that the data size matches that of the event.
34 if (data_length != static_cast<int>(event->size)) {
35 NOTREACHED();
36 return false;
37 }
38 const size_t expected_size_for_type =
39 content::WebInputEventTraits::GetSize(event->type);
40 if (data_length != static_cast<int>(expected_size_for_type)) {
41 NOTREACHED();
42 return false;
43 }
44 *r = event;
45 return true;
46 }
47
48 void ParamTraits<WebInputEventPointer>::Log(const param_type& p,
49 std::string* l) {
50 l->append("(");
51 LogParam(p->size, l);
52 l->append(", ");
53 LogParam(p->type, l);
54 l->append(", ");
55 LogParam(p->timeStampSeconds, l);
56 l->append(")");
57 }
58
59 } // namespace IPC
60
61 // Generate param traits write methods. 12 // Generate param traits write methods.
62 #include "ipc/param_traits_write_macros.h" 13 #include "ipc/param_traits_write_macros.h"
63 namespace IPC { 14 namespace IPC {
64 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ 15 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
65 #include "content/common/content_param_traits_macros.h" 16 #include "content/common/content_param_traits_macros.h"
66 } // namespace IPC 17 } // namespace IPC
67 18
68 // Generate param traits read methods. 19 // Generate param traits read methods.
69 #include "ipc/param_traits_read_macros.h" 20 #include "ipc/param_traits_read_macros.h"
70 namespace IPC { 21 namespace IPC {
71 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ 22 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
72 #include "content/common/content_param_traits_macros.h" 23 #include "content/common/content_param_traits_macros.h"
73 } // namespace IPC 24 } // namespace IPC
74 25
75 // Generate param traits log methods. 26 // Generate param traits log methods.
76 #include "ipc/param_traits_log_macros.h" 27 #include "ipc/param_traits_log_macros.h"
77 namespace IPC { 28 namespace IPC {
78 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ 29 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
79 #include "content/common/content_param_traits_macros.h" 30 #include "content/common/content_param_traits_macros.h"
80 } // namespace IPC 31 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/content_param_traits.h ('k') | content/common/content_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698