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
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_indexeddatabase_h__
8
#define mozilla_dom_indexeddatabase_h__
9
10
#include "js/StructuredClone.h"
11
#include "nsCOMPtr.h"
12
#include "nsTArray.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
class Blob;
18
class IDBDatabase;
19
class IDBMutableFile;
20
21
namespace indexedDB {
22
23
class FileInfo;
24
class SerializedStructuredCloneReadInfo;
25
26
struct StructuredCloneFile {
27
enum FileType {
28
eBlob,
29
eMutableFile,
30
eStructuredClone,
31
eWasmBytecode,
32
eWasmCompiled,
33
eEndGuard
34
};
35
36
RefPtr<Blob> mBlob;
37
RefPtr<IDBMutableFile> mMutableFile;
38
RefPtr<FileInfo> mFileInfo;
39
FileType mType;
40
41
// In IndexedDatabaseInlines.h
42
inline explicit StructuredCloneFile(FileType aType, RefPtr<Blob> aBlob = {});
43
44
// In IndexedDatabaseInlines.h
45
inline explicit StructuredCloneFile(RefPtr<IDBMutableFile> aMutableFile);
46
47
// In IndexedDatabaseInlines.h
48
inline ~StructuredCloneFile();
49
50
// In IndexedDatabaseInlines.h
51
inline bool operator==(const StructuredCloneFile& aOther) const;
52
};
53
54
struct StructuredCloneReadInfo {
55
JSStructuredCloneData mData;
56
nsTArray<StructuredCloneFile> mFiles;
57
IDBDatabase* mDatabase;
58
bool mHasPreprocessInfo;
59
60
// In IndexedDatabaseInlines.h
61
inline explicit StructuredCloneReadInfo(JS::StructuredCloneScope aScope);
62
63
// In IndexedDatabaseInlines.h
64
inline StructuredCloneReadInfo();
65
66
// In IndexedDatabaseInlines.h
67
inline StructuredCloneReadInfo(JSStructuredCloneData&& aData,
68
nsTArray<StructuredCloneFile> aFiles,
69
IDBDatabase* aDatabase,
70
bool aHasPreprocessInfo);
71
72
#ifdef NS_BUILD_REFCNT_LOGGING
73
// In IndexedDatabaseInlines.h
74
inline ~StructuredCloneReadInfo();
75
76
// In IndexedDatabaseInlines.h
77
//
78
// This custom implementation of the move ctor is only necessary because of
79
// MOZ_COUNT_CTOR. It is less efficient as the compiler-generated move ctor,
80
// since it unnecessarily clears elements on the source.
81
inline StructuredCloneReadInfo(StructuredCloneReadInfo&& aOther) noexcept;
82
83
// In IndexedDatabaseInlines.h
84
//
85
// This custom implementation of the move assignment operator is only there
86
// for symmetry with the move ctor. It is less efficient as the
87
// compiler-generated move assignment operator, since it unnecessarily clears
88
// elements on the source.
89
inline StructuredCloneReadInfo& operator=(
90
StructuredCloneReadInfo&& aOther) noexcept;
91
#else
92
StructuredCloneReadInfo(StructuredCloneReadInfo&& aOther) = default;
93
StructuredCloneReadInfo& operator=(StructuredCloneReadInfo&& aOther) =
94
default;
95
#endif
96
97
StructuredCloneReadInfo(const StructuredCloneReadInfo& aOther) = delete;
98
StructuredCloneReadInfo& operator=(const StructuredCloneReadInfo& aOther) =
99
delete;
100
101
// In IndexedDatabaseInlines.h
102
inline size_t Size() const;
103
};
104
105
} // namespace indexedDB
106
} // namespace dom
107
} // namespace mozilla
108
109
#endif // mozilla_dom_indexeddatabase_h__