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
3 // found in the LICENSE file.
5 #include "content/common/content_param_traits.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "content/common/input/web_input_event_traits.h"
9 #include "net/base/ip_endpoint.h"
10 #include "ui/gfx/range/range.h"
14 void ParamTraits
<gfx::Range
>::Write(Message
* m
, const gfx::Range
& r
) {
15 m
->WriteSizeT(r
.start());
16 m
->WriteSizeT(r
.end());
19 bool ParamTraits
<gfx::Range
>::Read(const Message
* m
,
23 if (!m
->ReadSizeT(iter
, &start
) || !m
->ReadSizeT(iter
, &end
))
30 void ParamTraits
<gfx::Range
>::Log(const gfx::Range
& r
, std::string
* l
) {
31 l
->append(base::StringPrintf("(%" PRIuS
", %" PRIuS
")", r
.start(), r
.end()));
34 void ParamTraits
<WebInputEventPointer
>::Write(Message
* m
, const param_type
& p
) {
35 m
->WriteData(reinterpret_cast<const char*>(p
), p
->size
);
38 bool ParamTraits
<WebInputEventPointer
>::Read(const Message
* m
,
43 if (!m
->ReadData(iter
, &data
, &data_length
)) {
47 if (data_length
< static_cast<int>(sizeof(blink::WebInputEvent
))) {
51 param_type event
= reinterpret_cast<param_type
>(data
);
52 // Check that the data size matches that of the event.
53 if (data_length
!= static_cast<int>(event
->size
)) {
57 const size_t expected_size_for_type
=
58 content::WebInputEventTraits::GetSize(event
->type
);
59 if (data_length
!= static_cast<int>(expected_size_for_type
)) {
67 void ParamTraits
<WebInputEventPointer
>::Log(const param_type
& p
,
74 LogParam(p
->timeStampSeconds
, l
);
80 // Generate param traits write methods.
81 #include "ipc/param_traits_write_macros.h"
83 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
84 #include "content/common/content_param_traits_macros.h"
87 // Generate param traits read methods.
88 #include "ipc/param_traits_read_macros.h"
90 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
91 #include "content/common/content_param_traits_macros.h"
94 // Generate param traits log methods.
95 #include "ipc/param_traits_log_macros.h"
97 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
98 #include "content/common/content_param_traits_macros.h"