Source code

Revision control

Other Tools

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
template <>
27
struct ParamTraits<mozilla::dom::indexedDB::Key> {
28
typedef mozilla::dom::indexedDB::Key paramType;
29
30
static void Write(Message* aMsg, const paramType& aParam) {
31
WriteParam(aMsg, aParam.mBuffer);
32
}
33
34
static bool Read(const Message* aMsg, PickleIterator* aIter,
35
paramType* aResult) {
36
return ReadParam(aMsg, aIter, &aResult->mBuffer);
37
}
38
39
static void Log(const paramType& aParam, std::wstring* aLog) {
40
LogParam(aParam.mBuffer, aLog);
41
}
42
};
43
44
template <>
45
struct ParamTraits<mozilla::dom::indexedDB::KeyPath::KeyPathType>
46
: public ContiguousEnumSerializer<
47
mozilla::dom::indexedDB::KeyPath::KeyPathType,
48
mozilla::dom::indexedDB::KeyPath::NONEXISTENT,
49
mozilla::dom::indexedDB::KeyPath::ENDGUARD> {};
50
51
template <>
52
struct ParamTraits<mozilla::dom::indexedDB::KeyPath> {
53
typedef mozilla::dom::indexedDB::KeyPath paramType;
54
55
static void Write(Message* aMsg, const paramType& aParam) {
56
WriteParam(aMsg, aParam.mType);
57
WriteParam(aMsg, aParam.mStrings);
58
}
59
60
static bool Read(const Message* aMsg, PickleIterator* aIter,
61
paramType* aResult) {
62
return ReadParam(aMsg, aIter, &aResult->mType) &&
63
ReadParam(aMsg, aIter, &aResult->mStrings);
64
}
65
66
static void Log(const paramType& aParam, std::wstring* aLog) {
67
LogParam(aParam.mStrings, aLog);
68
}
69
};
70
71
template <>
72
struct ParamTraits<mozilla::dom::IDBCursor::Direction>
73
: public ContiguousEnumSerializer<
74
mozilla::dom::IDBCursor::Direction, mozilla::dom::IDBCursor::NEXT,
75
mozilla::dom::IDBCursor::DIRECTION_INVALID> {};
76
77
template <>
78
struct ParamTraits<mozilla::dom::IDBTransaction::Mode>
79
: public ContiguousEnumSerializer<
80
mozilla::dom::IDBTransaction::Mode,
81
mozilla::dom::IDBTransaction::Mode::ReadOnly,
82
mozilla::dom::IDBTransaction::Mode::Invalid> {};
83
84
} // namespace IPC
85
86
#endif // mozilla_dom_indexeddb_serializationhelpers_h__