Index: content/public/common/common_param_traits.cc |
diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc |
index f953fa33f83e4fc2e41141de8119093cc93bb7de..4e993adad3d1254411ae1ff82a69fac41d7f28b9 100644 |
--- a/content/public/common/common_param_traits.cc |
+++ b/content/public/common/common_param_traits.cc |
@@ -7,6 +7,7 @@ |
#include <string> |
#include "content/public/common/content_constants.h" |
+#include "content/public/common/input/web_input_event_traits.h" |
#include "content/public/common/page_state.h" |
#include "content/public/common/referrer.h" |
#include "net/base/host_port_pair.h" |
@@ -185,6 +186,76 @@ void ParamTraits<content::PageState>::Log( |
l->append(")"); |
} |
+void ParamTraits<WebInputEventPointer>::Write(Message* m, const param_type& p) { |
+ m->WriteData(reinterpret_cast<const char*>(p), p->size); |
+} |
+ |
+bool ParamTraits<WebInputEventPointer>::Read(const Message* m, |
+ base::PickleIterator* iter, |
+ param_type* r) { |
+ const char* data; |
+ int data_length; |
+ if (!iter->ReadData(&data, &data_length)) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ if (data_length < static_cast<int>(sizeof(blink::WebInputEvent))) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ param_type event = reinterpret_cast<param_type>(data); |
+ // Check that the data size matches that of the event. |
+ if (data_length != static_cast<int>(event->size)) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ const size_t expected_size_for_type = |
+ content::WebInputEventTraits::GetSize(event->type); |
+ if (data_length != static_cast<int>(expected_size_for_type)) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ *r = event; |
+ return true; |
+} |
+ |
+void ParamTraits<WebInputEventPointer>::Log(const param_type& p, |
+ std::string* l) { |
+ l->append("("); |
+ LogParam(p->size, l); |
+ l->append(", "); |
+ LogParam(p->type, l); |
+ l->append(", "); |
+ LogParam(p->timeStampSeconds, l); |
+ l->append(")"); |
+} |
+ |
+void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, |
+ const param_type& p) { |
+ bool valid_web_event = !!p; |
+ WriteParam(m, valid_web_event); |
+ if (valid_web_event) |
+ WriteParam(m, static_cast<WebInputEventPointer>(p.get())); |
+} |
+ |
+bool ParamTraits<content::ScopedWebInputEvent>::Read(const Message* m, |
+ base::PickleIterator* iter, |
+ param_type* p) { |
+ bool valid_web_event = false; |
+ WebInputEventPointer web_event_pointer = NULL; |
+ if (!ReadParam(m, iter, &valid_web_event) || !valid_web_event || |
+ !ReadParam(m, iter, &web_event_pointer) || !web_event_pointer) |
+ return false; |
+ |
+ (*p) = content::WebInputEventTraits::Clone(*web_event_pointer); |
+ return true; |
+} |
+ |
+void ParamTraits<content::ScopedWebInputEvent>::Log(const param_type& p, |
+ std::string* l) { |
+ LogParam(static_cast<WebInputEventPointer>(p.get()), l); |
+} |
+ |
} // namespace IPC |
// Generate param traits write methods. |