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_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 "nsWeakPtr.h"
14 :
15 : #define FILEIMPLSNAPSHOT_IID \
16 : {0x0dfc11b1, 0x75d3, 0x473b, {0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73}}
17 :
18 0 : class PIBlobImplSnapshot : public nsISupports
19 : {
20 : public:
21 : NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPLSNAPSHOT_IID)
22 :
23 : virtual mozilla::dom::BlobImpl*
24 : GetBlobImpl() const = 0;
25 : };
26 :
27 : NS_DEFINE_STATIC_IID_ACCESSOR(PIBlobImplSnapshot, FILEIMPLSNAPSHOT_IID)
28 :
29 : namespace mozilla {
30 : namespace dom {
31 :
32 : class IDBFileHandle;
33 :
34 : namespace indexedDB {
35 :
36 : class BlobImplSnapshot final
37 : : public BlobImpl
38 : , public PIBlobImplSnapshot
39 : {
40 : RefPtr<BlobImpl> mBlobImpl;
41 : nsWeakPtr mFileHandle;
42 :
43 : public:
44 : BlobImplSnapshot(BlobImpl* aImpl,
45 : IDBFileHandle* aFileHandle);
46 :
47 : NS_DECL_ISUPPORTS_INHERITED
48 :
49 : private:
50 : BlobImplSnapshot(BlobImpl* aImpl,
51 : nsIWeakReference* aFileHandle);
52 :
53 : ~BlobImplSnapshot();
54 :
55 : // BlobImpl
56 : virtual void
57 0 : GetName(nsAString& aName) const override
58 : {
59 0 : mBlobImpl->GetName(aName);
60 0 : }
61 :
62 : virtual void
63 0 : GetDOMPath(nsAString& aPath) const override
64 : {
65 0 : mBlobImpl->GetDOMPath(aPath);
66 0 : }
67 :
68 : virtual void
69 0 : SetDOMPath(const nsAString& aPath) override
70 : {
71 0 : mBlobImpl->SetDOMPath(aPath);
72 0 : }
73 :
74 : virtual int64_t
75 0 : GetLastModified(ErrorResult& aRv) override
76 : {
77 0 : return mBlobImpl->GetLastModified(aRv);
78 : }
79 :
80 : virtual void
81 0 : SetLastModified(int64_t aLastModified) override
82 : {
83 0 : mBlobImpl->SetLastModified(aLastModified);
84 0 : }
85 :
86 : virtual void
87 0 : GetMozFullPath(nsAString& aName, SystemCallerGuarantee aGuarantee,
88 : ErrorResult& aRv) const override
89 : {
90 0 : mBlobImpl->GetMozFullPath(aName, aGuarantee, aRv);
91 0 : }
92 :
93 : virtual void
94 0 : GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) const override
95 : {
96 0 : mBlobImpl->GetMozFullPathInternal(aFileName, aRv);
97 0 : }
98 :
99 : virtual uint64_t
100 0 : GetSize(ErrorResult& aRv) override
101 : {
102 0 : return mBlobImpl->GetSize(aRv);
103 : }
104 :
105 : virtual void
106 0 : GetType(nsAString& aType) override
107 : {
108 0 : mBlobImpl->GetType(aType);
109 0 : }
110 :
111 : virtual uint64_t
112 0 : GetSerialNumber() const override
113 : {
114 0 : return mBlobImpl->GetSerialNumber();
115 : }
116 :
117 : virtual already_AddRefed<BlobImpl>
118 : CreateSlice(uint64_t aStart,
119 : uint64_t aLength,
120 : const nsAString& aContentType,
121 : ErrorResult& aRv) override;
122 :
123 : virtual const nsTArray<RefPtr<BlobImpl>>*
124 0 : GetSubBlobImpls() const override
125 : {
126 0 : return mBlobImpl->GetSubBlobImpls();
127 : }
128 :
129 : virtual void
130 : GetInternalStream(nsIInputStream** aStream,
131 : ErrorResult& aRv) override;
132 :
133 : virtual int64_t
134 0 : GetFileId() override
135 : {
136 0 : return mBlobImpl->GetFileId();
137 : }
138 :
139 : virtual nsresult
140 0 : GetSendInfo(nsIInputStream** aBody,
141 : uint64_t* aContentLength,
142 : nsACString& aContentType,
143 : nsACString& aCharset) override
144 : {
145 0 : return mBlobImpl->GetSendInfo(aBody,
146 : aContentLength,
147 : aContentType,
148 0 : aCharset);
149 : }
150 :
151 : virtual nsresult
152 0 : GetMutable(bool* aMutable) const override
153 : {
154 0 : return mBlobImpl->GetMutable(aMutable);
155 : }
156 :
157 : virtual nsresult
158 0 : SetMutable(bool aMutable) override
159 : {
160 0 : return mBlobImpl->SetMutable(aMutable);
161 : }
162 :
163 : virtual void
164 0 : SetLazyData(const nsAString& aName,
165 : const nsAString& aContentType,
166 : uint64_t aLength,
167 : int64_t aLastModifiedDate) override
168 : {
169 0 : MOZ_CRASH("This should never be called!");
170 : }
171 :
172 : virtual bool
173 0 : IsMemoryFile() const override
174 : {
175 0 : return mBlobImpl->IsMemoryFile();
176 : }
177 :
178 : virtual bool
179 0 : IsSizeUnknown() const override
180 : {
181 0 : return mBlobImpl->IsSizeUnknown();
182 : }
183 :
184 : virtual bool
185 0 : IsDateUnknown() const override
186 : {
187 0 : return mBlobImpl->IsDateUnknown();
188 : }
189 :
190 : virtual bool
191 0 : IsFile() const override
192 : {
193 0 : return mBlobImpl->IsFile();
194 : }
195 :
196 : virtual bool
197 0 : MayBeClonedToOtherThreads() const override
198 : {
199 0 : return false;
200 : }
201 :
202 : // PIBlobImplSnapshot
203 : virtual BlobImpl*
204 : GetBlobImpl() const override;
205 : };
206 :
207 : } // namespace indexedDB
208 : } // namespace dom
209 : } // namespace mozilla
210 :
211 : #endif // mozilla_dom_indexeddb_filesnapshot_h__
|