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_filesnapshot_h__
8
#define mozilla_dom_indexeddb_filesnapshot_h__
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/dom/File.h"
12
#include "nsISupports.h"
13
#include "nsIWeakReferenceUtils.h"
14
15
#define FILEIMPLSNAPSHOT_IID \
16
{ \
17
0x0dfc11b1, 0x75d3, 0x473b, { \
18
0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73 \
19
} \
20
}
21
22
class PIBlobImplSnapshot : public nsISupports {
23
public:
24
NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPLSNAPSHOT_IID)
25
26
virtual mozilla::dom::BlobImpl* GetBlobImpl() const = 0;
27
};
28
29
NS_DEFINE_STATIC_IID_ACCESSOR(PIBlobImplSnapshot, FILEIMPLSNAPSHOT_IID)
30
31
namespace mozilla {
32
namespace dom {
33
34
class IDBFileHandle;
35
36
namespace indexedDB {
37
38
class BlobImplSnapshot final : public BlobImpl, public PIBlobImplSnapshot {
39
RefPtr<BlobImpl> mBlobImpl;
40
nsWeakPtr mFileHandle;
41
42
public:
43
BlobImplSnapshot(BlobImpl* aFileImpl, IDBFileHandle* aFileHandle);
44
45
NS_DECL_ISUPPORTS_INHERITED
46
47
private:
48
BlobImplSnapshot(BlobImpl* aFileImpl, nsIWeakReference* aFileHandle);
49
50
~BlobImplSnapshot() = default;
51
52
// BlobImpl
53
virtual void GetName(nsAString& aName) const override {
54
mBlobImpl->GetName(aName);
55
}
56
57
virtual void GetDOMPath(nsAString& aPath) const override {
58
mBlobImpl->GetDOMPath(aPath);
59
}
60
61
virtual void SetDOMPath(const nsAString& aPath) override {
62
mBlobImpl->SetDOMPath(aPath);
63
}
64
65
virtual int64_t GetLastModified(ErrorResult& aRv) override {
66
return mBlobImpl->GetLastModified(aRv);
67
}
68
69
virtual void SetLastModified(int64_t aLastModified) override {
70
mBlobImpl->SetLastModified(aLastModified);
71
}
72
73
virtual void GetMozFullPath(nsAString& aName,
74
SystemCallerGuarantee aGuarantee,
75
ErrorResult& aRv) override {
76
mBlobImpl->GetMozFullPath(aName, aGuarantee, aRv);
77
}
78
79
virtual void GetMozFullPathInternal(nsAString& aFileName,
80
ErrorResult& aRv) override {
81
mBlobImpl->GetMozFullPathInternal(aFileName, aRv);
82
}
83
84
virtual uint64_t GetSize(ErrorResult& aRv) override {
85
return mBlobImpl->GetSize(aRv);
86
}
87
88
virtual void GetType(nsAString& aType) override { mBlobImpl->GetType(aType); }
89
90
virtual void GetBlobImplType(nsAString& aBlobImplType) const override;
91
92
size_t GetAllocationSize() const override {
93
return mBlobImpl->GetAllocationSize();
94
}
95
96
size_t GetAllocationSize(
97
FallibleTArray<BlobImpl*>& aVisitedBlobs) const override {
98
return mBlobImpl->GetAllocationSize(aVisitedBlobs);
99
}
100
101
virtual uint64_t GetSerialNumber() const override {
102
return mBlobImpl->GetSerialNumber();
103
}
104
105
virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart,
106
uint64_t aLength,
107
const nsAString& aContentType,
108
ErrorResult& aRv) override;
109
110
virtual const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const override {
111
return mBlobImpl->GetSubBlobImpls();
112
}
113
114
virtual void CreateInputStream(nsIInputStream** aStream,
115
ErrorResult& aRv) override;
116
117
virtual int64_t GetFileId() override { return mBlobImpl->GetFileId(); }
118
119
virtual nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
120
nsACString& aContentType,
121
nsACString& aCharset) override {
122
return mBlobImpl->GetSendInfo(aBody, aContentLength, aContentType,
123
aCharset);
124
}
125
126
virtual nsresult GetMutable(bool* aMutable) const override {
127
return mBlobImpl->GetMutable(aMutable);
128
}
129
130
virtual nsresult SetMutable(bool aMutable) override {
131
return mBlobImpl->SetMutable(aMutable);
132
}
133
134
virtual void SetLazyData(const nsAString& aName,
135
const nsAString& aContentType, uint64_t aLength,
136
int64_t aLastModifiedDate) override {
137
MOZ_CRASH("This should never be called!");
138
}
139
140
virtual bool IsMemoryFile() const override {
141
return mBlobImpl->IsMemoryFile();
142
}
143
144
virtual bool IsSizeUnknown() const override {
145
return mBlobImpl->IsSizeUnknown();
146
}
147
148
virtual bool IsDateUnknown() const override {
149
return mBlobImpl->IsDateUnknown();
150
}
151
152
virtual bool IsFile() const override { return mBlobImpl->IsFile(); }
153
154
virtual bool MayBeClonedToOtherThreads() const override { return false; }
155
156
// PIBlobImplSnapshot
157
virtual BlobImpl* GetBlobImpl() const override;
158
};
159
160
} // namespace indexedDB
161
} // namespace dom
162
} // namespace mozilla
163
164
#endif // mozilla_dom_indexeddb_filesnapshot_h__