| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/input_param_traits.h" | 5 #include "content/common/input/input_param_traits.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/common/content_param_traits.h" | 9 #include "content/common/content_param_traits.h" |
| 10 #include "content/common/input/synthetic_pinch_gesture_params.h" | 10 #include "content/common/input/synthetic_pinch_gesture_params.h" |
| 11 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" | 11 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
| 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 13 #include "content/common/input/web_input_event_traits.h" | |
| 14 #include "content/common/input_messages.h" | 13 #include "content/common/input_messages.h" |
| 15 | 14 |
| 16 namespace IPC { | 15 namespace IPC { |
| 17 namespace { | 16 namespace { |
| 18 template <typename GestureType> | 17 template <typename GestureType> |
| 19 scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( | 18 scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( |
| 20 const Message* m, | 19 const Message* m, |
| 21 base::PickleIterator* iter) { | 20 base::PickleIterator* iter) { |
| 22 scoped_ptr<GestureType> gesture_params(new GestureType); | 21 scoped_ptr<GestureType> gesture_params(new GestureType); |
| 23 if (!ReadParam(m, iter, gesture_params.get())) | 22 if (!ReadParam(m, iter, gesture_params.get())) |
| 24 return scoped_ptr<content::SyntheticGestureParams>(); | 23 return scoped_ptr<content::SyntheticGestureParams>(); |
| 25 | 24 |
| 26 return std::move(gesture_params); | 25 return std::move(gesture_params); |
| 27 } | 26 } |
| 28 } // namespace | 27 } // namespace |
| 29 | 28 |
| 30 void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, | |
| 31 const param_type& p) { | |
| 32 bool valid_web_event = !!p; | |
| 33 WriteParam(m, valid_web_event); | |
| 34 if (valid_web_event) | |
| 35 WriteParam(m, static_cast<WebInputEventPointer>(p.get())); | |
| 36 } | |
| 37 | |
| 38 bool ParamTraits<content::ScopedWebInputEvent>::Read(const Message* m, | |
| 39 base::PickleIterator* iter, | |
| 40 param_type* p) { | |
| 41 bool valid_web_event = false; | |
| 42 WebInputEventPointer web_event_pointer = NULL; | |
| 43 if (!ReadParam(m, iter, &valid_web_event) || | |
| 44 !valid_web_event || | |
| 45 !ReadParam(m, iter, &web_event_pointer) || | |
| 46 !web_event_pointer) | |
| 47 return false; | |
| 48 | |
| 49 (*p) = content::WebInputEventTraits::Clone(*web_event_pointer); | |
| 50 return true; | |
| 51 } | |
| 52 | |
| 53 void ParamTraits<content::ScopedWebInputEvent>::Log(const param_type& p, | |
| 54 std::string* l) { | |
| 55 LogParam(static_cast<WebInputEventPointer>(p.get()), l); | |
| 56 } | |
| 57 | |
| 58 void ParamTraits<content::SyntheticGesturePacket>::Write(Message* m, | 29 void ParamTraits<content::SyntheticGesturePacket>::Write(Message* m, |
| 59 const param_type& p) { | 30 const param_type& p) { |
| 60 DCHECK(p.gesture_params()); | 31 DCHECK(p.gesture_params()); |
| 61 WriteParam(m, p.gesture_params()->GetGestureType()); | 32 WriteParam(m, p.gesture_params()->GetGestureType()); |
| 62 switch (p.gesture_params()->GetGestureType()) { | 33 switch (p.gesture_params()->GetGestureType()) { |
| 63 case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: | 34 case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: |
| 64 WriteParam(m, *content::SyntheticSmoothScrollGestureParams::Cast( | 35 WriteParam(m, *content::SyntheticSmoothScrollGestureParams::Cast( |
| 65 p.gesture_params())); | 36 p.gesture_params())); |
| 66 break; | 37 break; |
| 67 case content::SyntheticGestureParams::SMOOTH_DRAG_GESTURE: | 38 case content::SyntheticGestureParams::SMOOTH_DRAG_GESTURE: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 break; | 106 break; |
| 136 case content::SyntheticGestureParams::TAP_GESTURE: | 107 case content::SyntheticGestureParams::TAP_GESTURE: |
| 137 LogParam( | 108 LogParam( |
| 138 *content::SyntheticTapGestureParams::Cast(p.gesture_params()), | 109 *content::SyntheticTapGestureParams::Cast(p.gesture_params()), |
| 139 l); | 110 l); |
| 140 break; | 111 break; |
| 141 } | 112 } |
| 142 } | 113 } |
| 143 | 114 |
| 144 } // namespace IPC | 115 } // namespace IPC |
| OLD | NEW |