Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_indexeddb_serializationhelpers_h__
8 : #define mozilla_dom_indexeddb_serializationhelpers_h__
9 :
10 : #include "ipc/IPCMessageUtils.h"
11 :
12 : #include "mozilla/dom/indexedDB/Key.h"
13 : #include "mozilla/dom/indexedDB/KeyPath.h"
14 : #include "mozilla/dom/IDBCursor.h"
15 : #include "mozilla/dom/IDBTransaction.h"
16 :
17 : namespace IPC {
18 :
19 : template <>
20 : struct ParamTraits<mozilla::dom::indexedDB::StructuredCloneFile::FileType> :
21 : public ContiguousEnumSerializer<
22 : mozilla::dom::indexedDB::StructuredCloneFile::FileType,
23 : mozilla::dom::indexedDB::StructuredCloneFile::eBlob,
24 : mozilla::dom::indexedDB::StructuredCloneFile::eEndGuard>
25 : { };
26 :
27 : template <>
28 : struct ParamTraits<mozilla::dom::indexedDB::Key>
29 : {
30 : typedef mozilla::dom::indexedDB::Key paramType;
31 :
32 0 : static void Write(Message* aMsg, const paramType& aParam)
33 : {
34 0 : WriteParam(aMsg, aParam.mBuffer);
35 0 : }
36 :
37 0 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
38 : {
39 0 : return ReadParam(aMsg, aIter, &aResult->mBuffer);
40 : }
41 :
42 : static void Log(const paramType& aParam, std::wstring* aLog)
43 : {
44 : LogParam(aParam.mBuffer, aLog);
45 : }
46 : };
47 :
48 : template <>
49 : struct ParamTraits<mozilla::dom::indexedDB::KeyPath::KeyPathType> :
50 : public ContiguousEnumSerializer<mozilla::dom::indexedDB::KeyPath::KeyPathType,
51 : mozilla::dom::indexedDB::KeyPath::NONEXISTENT,
52 : mozilla::dom::indexedDB::KeyPath::ENDGUARD>
53 : { };
54 :
55 : template <>
56 : struct ParamTraits<mozilla::dom::indexedDB::KeyPath>
57 : {
58 : typedef mozilla::dom::indexedDB::KeyPath paramType;
59 :
60 0 : static void Write(Message* aMsg, const paramType& aParam)
61 : {
62 0 : WriteParam(aMsg, aParam.mType);
63 0 : WriteParam(aMsg, aParam.mStrings);
64 0 : }
65 :
66 0 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
67 : {
68 0 : return ReadParam(aMsg, aIter, &aResult->mType) &&
69 0 : ReadParam(aMsg, aIter, &aResult->mStrings);
70 : }
71 :
72 : static void Log(const paramType& aParam, std::wstring* aLog)
73 : {
74 : LogParam(aParam.mStrings, aLog);
75 : }
76 : };
77 :
78 : template <>
79 : struct ParamTraits<mozilla::dom::IDBCursor::Direction> :
80 : public ContiguousEnumSerializer<
81 : mozilla::dom::IDBCursor::Direction,
82 : mozilla::dom::IDBCursor::NEXT,
83 : mozilla::dom::IDBCursor::DIRECTION_INVALID>
84 : { };
85 :
86 : template <>
87 : struct ParamTraits<mozilla::dom::IDBTransaction::Mode> :
88 : public ContiguousEnumSerializer<
89 : mozilla::dom::IDBTransaction::Mode,
90 : mozilla::dom::IDBTransaction::READ_ONLY,
91 : mozilla::dom::IDBTransaction::MODE_INVALID>
92 : { };
93 :
94 : } // namespace IPC
95 :
96 : #endif // mozilla_dom_indexeddb_serializationhelpers_h__
|