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> |
| 8 |
7 #include "content/common/content_param_traits.h" | 9 #include "content/common/content_param_traits.h" |
8 #include "content/common/input/synthetic_pinch_gesture_params.h" | 10 #include "content/common/input/synthetic_pinch_gesture_params.h" |
9 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" | 11 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
11 #include "content/common/input/web_input_event_traits.h" | 13 #include "content/common/input/web_input_event_traits.h" |
12 #include "content/common/input_messages.h" | 14 #include "content/common/input_messages.h" |
13 | 15 |
14 namespace IPC { | 16 namespace IPC { |
15 namespace { | 17 namespace { |
16 template <typename GestureType> | 18 template <typename GestureType> |
17 scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( | 19 scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( |
18 const Message* m, | 20 const Message* m, |
19 base::PickleIterator* iter) { | 21 base::PickleIterator* iter) { |
20 scoped_ptr<GestureType> gesture_params(new GestureType); | 22 scoped_ptr<GestureType> gesture_params(new GestureType); |
21 if (!ReadParam(m, iter, gesture_params.get())) | 23 if (!ReadParam(m, iter, gesture_params.get())) |
22 return scoped_ptr<content::SyntheticGestureParams>(); | 24 return scoped_ptr<content::SyntheticGestureParams>(); |
23 | 25 |
24 return gesture_params.Pass(); | 26 return std::move(gesture_params); |
25 } | 27 } |
26 } // namespace | 28 } // namespace |
27 | 29 |
28 void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, | 30 void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m, |
29 const param_type& p) { | 31 const param_type& p) { |
30 bool valid_web_event = !!p; | 32 bool valid_web_event = !!p; |
31 WriteParam(m, valid_web_event); | 33 WriteParam(m, valid_web_event); |
32 if (valid_web_event) | 34 if (valid_web_event) |
33 WriteParam(m, static_cast<WebInputEventPointer>(p.get())); | 35 WriteParam(m, static_cast<WebInputEventPointer>(p.get())); |
34 } | 36 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ReadGestureParams<content::SyntheticPinchGestureParams>(m, iter); | 102 ReadGestureParams<content::SyntheticPinchGestureParams>(m, iter); |
101 break; | 103 break; |
102 case content::SyntheticGestureParams::TAP_GESTURE: | 104 case content::SyntheticGestureParams::TAP_GESTURE: |
103 gesture_params = | 105 gesture_params = |
104 ReadGestureParams<content::SyntheticTapGestureParams>(m, iter); | 106 ReadGestureParams<content::SyntheticTapGestureParams>(m, iter); |
105 break; | 107 break; |
106 default: | 108 default: |
107 return false; | 109 return false; |
108 } | 110 } |
109 | 111 |
110 p->set_gesture_params(gesture_params.Pass()); | 112 p->set_gesture_params(std::move(gesture_params)); |
111 return p->gesture_params() != NULL; | 113 return p->gesture_params() != NULL; |
112 } | 114 } |
113 | 115 |
114 void ParamTraits<content::SyntheticGesturePacket>::Log(const param_type& p, | 116 void ParamTraits<content::SyntheticGesturePacket>::Log(const param_type& p, |
115 std::string* l) { | 117 std::string* l) { |
116 DCHECK(p.gesture_params()); | 118 DCHECK(p.gesture_params()); |
117 switch (p.gesture_params()->GetGestureType()) { | 119 switch (p.gesture_params()->GetGestureType()) { |
118 case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: | 120 case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: |
119 LogParam( | 121 LogParam( |
120 *content::SyntheticSmoothScrollGestureParams::Cast( | 122 *content::SyntheticSmoothScrollGestureParams::Cast( |
(...skipping 12 matching lines...) Expand all Loading... |
133 break; | 135 break; |
134 case content::SyntheticGestureParams::TAP_GESTURE: | 136 case content::SyntheticGestureParams::TAP_GESTURE: |
135 LogParam( | 137 LogParam( |
136 *content::SyntheticTapGestureParams::Cast(p.gesture_params()), | 138 *content::SyntheticTapGestureParams::Cast(p.gesture_params()), |
137 l); | 139 l); |
138 break; | 140 break; |
139 } | 141 } |
140 } | 142 } |
141 | 143 |
142 } // namespace IPC | 144 } // namespace IPC |
OLD | NEW |