1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_SessionStoreMessageUtils_h
6 #define mozilla_dom_SessionStoreMessageUtils_h
8 #include "ipc/IPCMessageUtils.h"
9 #include "mozilla/ipc/IPDLParamTraits.h"
10 #include "mozilla/ipc/URIUtils.h"
11 #include "SessionStoreData.h"
12 #include "SessionStoreUtils.h"
13 #include "SessionStoreRestoreData.h"
18 struct ParamTraits
<mozilla::dom::CollectedNonMultipleSelectValue
> {
19 typedef mozilla::dom::CollectedNonMultipleSelectValue paramType
;
21 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
22 WriteParam(aWriter
, aParam
.mSelectedIndex
);
23 WriteParam(aWriter
, aParam
.mValue
);
26 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
27 return ReadParam(aReader
, &aResult
->mSelectedIndex
) &&
28 ReadParam(aReader
, &aResult
->mValue
);
33 struct ParamTraits
<CollectedInputDataValue
> {
34 typedef CollectedInputDataValue paramType
;
36 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
37 WriteParam(aWriter
, aParam
.id
);
38 WriteParam(aWriter
, aParam
.type
);
39 WriteParam(aWriter
, aParam
.value
);
42 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
43 return ReadParam(aReader
, &aResult
->id
) &&
44 ReadParam(aReader
, &aResult
->type
) &&
45 ReadParam(aReader
, &aResult
->value
);
50 struct ParamTraits
<InputFormData
> {
51 typedef InputFormData paramType
;
53 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
54 WriteParam(aWriter
, aParam
.descendants
);
55 WriteParam(aWriter
, aParam
.innerHTML
);
56 WriteParam(aWriter
, aParam
.url
);
57 WriteParam(aWriter
, aParam
.numId
);
58 WriteParam(aWriter
, aParam
.numXPath
);
61 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
62 return ReadParam(aReader
, &aResult
->descendants
) &&
63 ReadParam(aReader
, &aResult
->innerHTML
) &&
64 ReadParam(aReader
, &aResult
->url
) &&
65 ReadParam(aReader
, &aResult
->numId
) &&
66 ReadParam(aReader
, &aResult
->numXPath
);
76 struct IPDLParamTraits
<mozilla::dom::SessionStoreRestoreData
*> {
77 // Note that we intentionally don't de/serialize mChildren here. The receiver
78 // won't be doing anything with the children lists, and it avoids sending form
79 // data for subframes to the content processes of their embedders.
81 static void Write(IPC::MessageWriter
* aWriter
, IProtocol
* aActor
,
82 mozilla::dom::SessionStoreRestoreData
* aParam
) {
83 bool isNull
= !aParam
;
84 WriteIPDLParam(aWriter
, aActor
, isNull
);
88 WriteIPDLParam(aWriter
, aActor
, aParam
->mURI
);
89 WriteIPDLParam(aWriter
, aActor
, aParam
->mInnerHTML
);
90 WriteIPDLParam(aWriter
, aActor
, aParam
->mScroll
);
91 WriteIPDLParam(aWriter
, aActor
, aParam
->mEntries
);
94 static bool Read(IPC::MessageReader
* aReader
, IProtocol
* aActor
,
95 RefPtr
<mozilla::dom::SessionStoreRestoreData
>* aResult
) {
98 if (!ReadIPDLParam(aReader
, aActor
, &isNull
)) {
104 auto data
= MakeRefPtr
<mozilla::dom::SessionStoreRestoreData
>();
105 if (!ReadIPDLParam(aReader
, aActor
, &data
->mURI
) ||
106 !ReadIPDLParam(aReader
, aActor
, &data
->mInnerHTML
) ||
107 !ReadIPDLParam(aReader
, aActor
, &data
->mScroll
) ||
108 !ReadIPDLParam(aReader
, aActor
, &data
->mEntries
)) {
111 *aResult
= std::move(data
);
117 struct IPDLParamTraits
<mozilla::dom::SessionStoreRestoreData::Entry
> {
118 static void Write(IPC::MessageWriter
* aWriter
, IProtocol
* aActor
,
119 mozilla::dom::SessionStoreRestoreData::Entry aParam
) {
120 WriteIPDLParam(aWriter
, aActor
, aParam
.mData
);
121 WriteIPDLParam(aWriter
, aActor
, aParam
.mIsXPath
);
124 static bool Read(IPC::MessageReader
* aReader
, IProtocol
* aActor
,
125 mozilla::dom::SessionStoreRestoreData::Entry
* aResult
) {
126 return ReadIPDLParam(aReader
, aActor
, &aResult
->mData
) &&
127 ReadIPDLParam(aReader
, aActor
, &aResult
->mIsXPath
);
132 } // namespace mozilla
134 #endif // mozilla_dom_SessionStoreMessageUtils_h