| OLD | NEW |
| 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 "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| 11 #include "ui/events/blink/web_input_event_traits.h" | 11 #include "ui/events/blink/web_input_event_traits.h" |
| 12 | 12 |
| 13 namespace IPC { | 13 namespace IPC { |
| 14 | 14 |
| 15 void ParamTraits<WebInputEventPointer>::GetSize(base::PickleSizer* s, | 15 void ParamTraits<WebInputEventPointer>::GetSize(base::PickleSizer* s, |
| 16 const param_type& p) { | 16 const param_type& p) { |
| 17 s->AddData(p->size); | 17 s->AddData(p->size()); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void ParamTraits<WebInputEventPointer>::Write(base::Pickle* m, | 20 void ParamTraits<WebInputEventPointer>::Write(base::Pickle* m, |
| 21 const param_type& p) { | 21 const param_type& p) { |
| 22 m->WriteData(reinterpret_cast<const char*>(p), p->size); | 22 m->WriteData(reinterpret_cast<const char*>(p), p->size()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool ParamTraits<WebInputEventPointer>::Read(const base::Pickle* m, | 25 bool ParamTraits<WebInputEventPointer>::Read(const base::Pickle* m, |
| 26 base::PickleIterator* iter, | 26 base::PickleIterator* iter, |
| 27 param_type* r) { | 27 param_type* r) { |
| 28 const char* data; | 28 const char* data; |
| 29 int data_length; | 29 int data_length; |
| 30 if (!iter->ReadData(&data, &data_length)) { | 30 if (!iter->ReadData(&data, &data_length)) { |
| 31 NOTREACHED(); | 31 NOTREACHED(); |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 if (data_length < static_cast<int>(sizeof(blink::WebInputEvent))) { | 34 if (data_length < static_cast<int>(sizeof(blink::WebInputEvent))) { |
| 35 NOTREACHED(); | 35 NOTREACHED(); |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 param_type event = reinterpret_cast<param_type>(data); | 38 param_type event = reinterpret_cast<param_type>(data); |
| 39 // Check that the data size matches that of the event. | 39 // Check that the data size matches that of the event. |
| 40 if (data_length != static_cast<int>(event->size)) { | 40 if (data_length != static_cast<int>(event->size())) { |
| 41 NOTREACHED(); | 41 NOTREACHED(); |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 const size_t expected_size_for_type = | 44 const size_t expected_size_for_type = |
| 45 ui::WebInputEventTraits::GetSize(event->type); | 45 ui::WebInputEventTraits::GetSize(event->type()); |
| 46 if (data_length != static_cast<int>(expected_size_for_type)) { | 46 if (data_length != static_cast<int>(expected_size_for_type)) { |
| 47 NOTREACHED(); | 47 NOTREACHED(); |
| 48 return false; | 48 return false; |
| 49 } | 49 } |
| 50 *r = event; | 50 *r = event; |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ParamTraits<WebInputEventPointer>::Log(const param_type& p, | 54 void ParamTraits<WebInputEventPointer>::Log(const param_type& p, |
| 55 std::string* l) { | 55 std::string* l) { |
| 56 l->append("("); | 56 l->append("("); |
| 57 LogParam(p->size, l); | 57 LogParam(p->size(), l); |
| 58 l->append(", "); | 58 l->append(", "); |
| 59 LogParam(p->type, l); | 59 LogParam(p->type(), l); |
| 60 l->append(", "); | 60 l->append(", "); |
| 61 LogParam(p->timeStampSeconds, l); | 61 LogParam(p->timeStampSeconds(), l); |
| 62 l->append(")"); | 62 l->append(")"); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace IPC | 65 } // namespace IPC |
| 66 | 66 |
| 67 // Generate param traits size methods. | 67 // Generate param traits size methods. |
| 68 #include "ipc/param_traits_size_macros.h" | 68 #include "ipc/param_traits_size_macros.h" |
| 69 namespace IPC { | 69 namespace IPC { |
| 70 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 70 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
| 71 #include "content/common/content_param_traits_macros.h" | 71 #include "content/common/content_param_traits_macros.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 84 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
| 85 #include "content/common/content_param_traits_macros.h" | 85 #include "content/common/content_param_traits_macros.h" |
| 86 } // namespace IPC | 86 } // namespace IPC |
| 87 | 87 |
| 88 // Generate param traits log methods. | 88 // Generate param traits log methods. |
| 89 #include "ipc/param_traits_log_macros.h" | 89 #include "ipc/param_traits_log_macros.h" |
| 90 namespace IPC { | 90 namespace IPC { |
| 91 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ | 91 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ |
| 92 #include "content/common/content_param_traits_macros.h" | 92 #include "content/common/content_param_traits_macros.h" |
| 93 } // namespace IPC | 93 } // namespace IPC |
| OLD | NEW |