[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 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. |
| 4 | |
| 5 | // This file is used to define IPC::ParamTraits<> specializations for a number |
| 6 | // of types so that they can be serialized over IPC. IPC::ParamTraits<> |
| 7 | // specializations for basic types (like int and std::string) and types in the |
| 8 | // 'base' project can be found in ipc/ipc_message_utils.h. This file contains |
| 9 | // specializations for types that are used by the content code, and which need |
| 10 | // manual serialization code. This is usually because they're not structs with |
| 11 | // public members, or because the same type is being used in multiple |
| 12 | // *_messages.h headers. |
| 13 | |
| 14 | #ifndef CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ |
| 15 | #define CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ |
| 16 | |
| 17 | #include "content/common/content_param_traits_macros.h" |
[email protected] | c2809346d | 2014-03-20 00:11:03 | [diff] [blame] | 18 | #include "content/common/cursors/webcursor.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 19 | #include "third_party/WebKit/public/web/WebInputEvent.h" |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 20 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 21 | namespace net { |
| 22 | class IPEndPoint; |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 23 | } |
| 24 | |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 25 | namespace IPC { |
| 26 | |
| 27 | template <> |
[email protected] | c2809346d | 2014-03-20 00:11:03 | [diff] [blame] | 28 | struct ParamTraits<content::WebCursor> { |
| 29 | typedef content::WebCursor param_type; |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame^] | 30 | static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } |
| 31 | static bool Read(const base::Pickle* m, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 32 | base::PickleIterator* iter, |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame^] | 33 | param_type* r) { |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 34 | return r->Deserialize(iter); |
| 35 | } |
| 36 | static void Log(const param_type& p, std::string* l) { |
| 37 | l->append("<WebCursor>"); |
| 38 | } |
| 39 | }; |
| 40 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 41 | typedef const blink::WebInputEvent* WebInputEventPointer; |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 42 | template <> |
| 43 | struct ParamTraits<WebInputEventPointer> { |
| 44 | typedef WebInputEventPointer param_type; |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame^] | 45 | static void Write(base::Pickle* m, const param_type& p); |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 46 | // Note: upon read, the event has the lifetime of the message. |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame^] | 47 | static bool Read(const base::Pickle* m, |
| 48 | base::PickleIterator* iter, |
| 49 | param_type* r); |
[email protected] | 0dea165 | 2012-12-14 00:09:09 | [diff] [blame] | 50 | static void Log(const param_type& p, std::string* l); |
[email protected] | 9d8ea30 | 2012-09-25 15:04:22 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace IPC |
| 54 | |
| 55 | #endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ |