2012-06-03 20:33:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-06-03 20:33:52 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
#ifndef mozilla_dom_indexeddb_filesnapshot_h__
|
|
|
|
#define mozilla_dom_indexeddb_filesnapshot_h__
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2013-06-05 20:15:48 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-10-21 04:49:00 +04:00
|
|
|
#include "nsISupports.h"
|
2018-10-31 23:39:03 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2014-10-21 04:49:00 +04:00
|
|
|
|
|
|
|
#define FILEIMPLSNAPSHOT_IID \
|
|
|
|
{ \
|
|
|
|
0x0dfc11b1, 0x75d3, 0x473b, { \
|
|
|
|
0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73 \
|
|
|
|
} \
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-10-21 04:49:00 +04:00
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
class PIBlobImplSnapshot : public nsISupports {
|
2014-10-21 04:49:00 +04:00
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPLSNAPSHOT_IID)
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
virtual mozilla::dom::BlobImpl* GetBlobImpl() const = 0;
|
2014-10-21 04:49:00 +04:00
|
|
|
};
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(PIBlobImplSnapshot, FILEIMPLSNAPSHOT_IID)
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-05-07 18:32:12 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
class IDBFileHandle;
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
namespace indexedDB {
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
class BlobImplSnapshot final : public BlobImpl, public PIBlobImplSnapshot {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<BlobImpl> mBlobImpl;
|
2015-01-12 00:35:24 +03:00
|
|
|
nsWeakPtr mFileHandle;
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
public:
|
2015-09-09 14:15:05 +03:00
|
|
|
BlobImplSnapshot(BlobImpl* aImpl, IDBFileHandle* aFileHandle);
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
private:
|
2015-09-09 14:15:05 +03:00
|
|
|
BlobImplSnapshot(BlobImpl* aImpl, nsIWeakReference* aFileHandle);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
~BlobImplSnapshot();
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
// BlobImpl
|
2016-04-01 13:50:16 +03:00
|
|
|
virtual void GetName(nsAString& aName) const override {
|
2015-09-09 14:15:05 +03:00
|
|
|
mBlobImpl->GetName(aName);
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2017-02-06 13:07:54 +03:00
|
|
|
virtual void GetDOMPath(nsAString& aPath) const override {
|
|
|
|
mBlobImpl->GetDOMPath(aPath);
|
2016-05-13 14:11:38 +03:00
|
|
|
}
|
|
|
|
|
2017-02-06 13:07:54 +03:00
|
|
|
virtual void SetDOMPath(const nsAString& aPath) override {
|
|
|
|
mBlobImpl->SetDOMPath(aPath);
|
2015-09-09 14:15:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int64_t GetLastModified(ErrorResult& aRv) override {
|
|
|
|
return mBlobImpl->GetLastModified(aRv);
|
|
|
|
}
|
2014-07-17 20:40:54 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
virtual void SetLastModified(int64_t aLastModified) override {
|
|
|
|
mBlobImpl->SetLastModified(aLastModified);
|
|
|
|
}
|
2014-06-26 20:47:44 +04:00
|
|
|
|
2017-02-01 23:43:37 +03:00
|
|
|
virtual void GetMozFullPath(nsAString& aName,
|
|
|
|
SystemCallerGuarantee aGuarantee,
|
2019-04-26 20:53:07 +03:00
|
|
|
ErrorResult& aRv) override {
|
2017-02-01 23:43:37 +03:00
|
|
|
mBlobImpl->GetMozFullPath(aName, aGuarantee, aRv);
|
2015-09-09 14:15:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetMozFullPathInternal(nsAString& aFileName,
|
2019-04-26 20:53:07 +03:00
|
|
|
ErrorResult& aRv) override {
|
2015-09-09 14:15:05 +03:00
|
|
|
mBlobImpl->GetMozFullPathInternal(aFileName, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual uint64_t GetSize(ErrorResult& aRv) override {
|
|
|
|
return mBlobImpl->GetSize(aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetType(nsAString& aType) override { mBlobImpl->GetType(aType); }
|
|
|
|
|
2018-12-15 23:40:05 +03:00
|
|
|
virtual void GetBlobImplType(nsAString& aBlobImplType) const override;
|
|
|
|
|
2017-09-12 12:46:51 +03:00
|
|
|
size_t GetAllocationSize() const override {
|
|
|
|
return mBlobImpl->GetAllocationSize();
|
|
|
|
}
|
|
|
|
|
2018-06-18 18:35:46 +03:00
|
|
|
size_t GetAllocationSize(
|
|
|
|
FallibleTArray<BlobImpl*>& aVisitedBlobs) const override {
|
|
|
|
return mBlobImpl->GetAllocationSize(aVisitedBlobs);
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
virtual uint64_t GetSerialNumber() const override {
|
|
|
|
return mBlobImpl->GetSerialNumber();
|
2015-01-12 00:35:24 +03:00
|
|
|
}
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart,
|
2014-09-27 03:21:57 +04:00
|
|
|
uint64_t aLength,
|
2014-10-08 20:15:22 +04:00
|
|
|
const nsAString& aContentType,
|
2015-03-21 19:28:04 +03:00
|
|
|
ErrorResult& aRv) override;
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
virtual const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const override {
|
2015-09-09 14:15:05 +03:00
|
|
|
return mBlobImpl->GetSubBlobImpls();
|
|
|
|
}
|
|
|
|
|
2017-10-02 14:53:12 +03:00
|
|
|
virtual void CreateInputStream(nsIInputStream** aStream,
|
2015-09-09 14:15:05 +03:00
|
|
|
ErrorResult& aRv) override;
|
|
|
|
|
|
|
|
virtual int64_t GetFileId() override { return mBlobImpl->GetFileId(); }
|
|
|
|
|
|
|
|
virtual nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
|
|
|
nsACString& aContentType,
|
|
|
|
nsACString& aCharset) override {
|
|
|
|
return mBlobImpl->GetSendInfo(aBody, aContentLength, aContentType,
|
|
|
|
aCharset);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult GetMutable(bool* aMutable) const override {
|
|
|
|
return mBlobImpl->GetMutable(aMutable);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult SetMutable(bool aMutable) override {
|
|
|
|
return mBlobImpl->SetMutable(aMutable);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetLazyData(const nsAString& aName,
|
|
|
|
const nsAString& aContentType, uint64_t aLength,
|
2015-12-08 01:00:51 +03:00
|
|
|
int64_t aLastModifiedDate) override {
|
2015-09-09 14:15:05 +03:00
|
|
|
MOZ_CRASH("This should never be called!");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsMemoryFile() const override {
|
|
|
|
return mBlobImpl->IsMemoryFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsSizeUnknown() const override {
|
|
|
|
return mBlobImpl->IsSizeUnknown();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsDateUnknown() const override {
|
|
|
|
return mBlobImpl->IsDateUnknown();
|
|
|
|
}
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
virtual bool IsFile() const override { return mBlobImpl->IsFile(); }
|
|
|
|
|
|
|
|
virtual bool MayBeClonedToOtherThreads() const override { return false; }
|
|
|
|
|
|
|
|
// PIBlobImplSnapshot
|
|
|
|
virtual BlobImpl* GetBlobImpl() const override;
|
2012-06-03 20:33:52 +04:00
|
|
|
};
|
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
} // namespace indexedDB
|
2014-05-07 18:32:12 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
#endif // mozilla_dom_indexeddb_filesnapshot_h__
|