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"
|
2015-01-12 00:35:24 +03:00
|
|
|
#include "nsWeakPtr.h"
|
2014-10-21 04:49:00 +04:00
|
|
|
|
|
|
|
#define FILEIMPLSNAPSHOT_IID \
|
|
|
|
{0x0dfc11b1, 0x75d3, 0x473b, {0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73}}
|
|
|
|
|
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
|
2015-09-09 14:15:05 +03:00
|
|
|
: public BlobImpl
|
2015-05-12 15:11:03 +03:00
|
|
|
, public PIBlobImplSnapshot
|
2012-06-03 20:33:52 +04:00
|
|
|
{
|
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
|
|
|
|
virtual void
|
2016-04-01 13:50:16 +03:00
|
|
|
GetName(nsAString& aName) const override
|
2015-09-09 14:15:05 +03:00
|
|
|
{
|
|
|
|
mBlobImpl->GetName(aName);
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2014-10-08 20:15:22 +04:00
|
|
|
virtual void
|
2017-02-06 13:07:54 +03:00
|
|
|
GetDOMPath(nsAString& aPath) const override
|
2015-09-09 14:15:05 +03:00
|
|
|
{
|
2017-02-06 13:07:54 +03:00
|
|
|
mBlobImpl->GetDOMPath(aPath);
|
2016-05-13 14:11:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2017-02-06 13:07:54 +03:00
|
|
|
SetDOMPath(const nsAString& aPath) override
|
2016-05-13 14:11:38 +03:00
|
|
|
{
|
2017-02-06 13:07:54 +03:00
|
|
|
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-05-19 17:36:37 +03:00
|
|
|
virtual void
|
2015-09-09 14:15:05 +03:00
|
|
|
SetLastModified(int64_t aLastModified) override
|
|
|
|
{
|
|
|
|
mBlobImpl->SetLastModified(aLastModified);
|
|
|
|
}
|
2014-06-26 20:47:44 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
virtual void
|
2017-02-01 23:43:37 +03:00
|
|
|
GetMozFullPath(nsAString& aName, SystemCallerGuarantee aGuarantee,
|
|
|
|
ErrorResult& aRv) const override
|
2015-01-12 00:35:24 +03:00
|
|
|
{
|
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, ErrorResult& aRv) const override
|
|
|
|
{
|
|
|
|
mBlobImpl->GetMozFullPathInternal(aFileName, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual uint64_t
|
|
|
|
GetSize(ErrorResult& aRv) override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetSize(aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
GetType(nsAString& aType) override
|
|
|
|
{
|
|
|
|
mBlobImpl->GetType(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
2014-09-27 03:21:57 +04:00
|
|
|
CreateSlice(uint64_t aStart,
|
|
|
|
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>>*
|
2015-09-09 14:15:05 +03:00
|
|
|
GetSubBlobImpls() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetSubBlobImpls();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
GetInternalStream(nsIInputStream** aStream,
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:33:52 +04:00
|
|
|
virtual bool
|
2015-09-09 14:15:05 +03:00
|
|
|
IsDateUnknown() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->IsDateUnknown();
|
|
|
|
}
|
2012-06-03 20:33:52 +04:00
|
|
|
|
|
|
|
virtual bool
|
2015-09-09 14:15:05 +03:00
|
|
|
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__
|