2012-06-03 16:33:52 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 19:32:37 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-06-03 16:33:52 +00: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 16:40:54 +00:00
|
|
|
#ifndef mozilla_dom_indexeddb_filesnapshot_h__
|
|
|
|
#define mozilla_dom_indexeddb_filesnapshot_h__
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-10-08 16:15:23 +00:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-10-21 00:49:00 +00:00
|
|
|
#include "nsISupports.h"
|
2015-01-11 21:35:24 +00:00
|
|
|
#include "nsWeakPtr.h"
|
2014-10-21 00:49:00 +00:00
|
|
|
|
|
|
|
#define FILEIMPLSNAPSHOT_IID \
|
|
|
|
{0x0dfc11b1, 0x75d3, 0x473b, {0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73}}
|
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
class PIBlobImplSnapshot : public nsISupports
|
2014-10-21 00:49:00 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPLSNAPSHOT_IID)
|
2015-09-09 11:15:05 +00:00
|
|
|
|
|
|
|
virtual mozilla::dom::BlobImpl*
|
|
|
|
GetBlobImpl() const = 0;
|
2014-10-21 00:49:00 +00:00
|
|
|
};
|
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(PIBlobImplSnapshot, FILEIMPLSNAPSHOT_IID)
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
class IDBFileHandle;
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2016-02-16 21:46:08 +00:00
|
|
|
namespace indexedDB {
|
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
class BlobImplSnapshot final
|
2015-09-09 11:15:05 +00:00
|
|
|
: public BlobImpl
|
2015-05-12 12:11:03 +00:00
|
|
|
, public PIBlobImplSnapshot
|
2012-06-03 16:33:52 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<BlobImpl> mBlobImpl;
|
2015-01-11 21:35:24 +00:00
|
|
|
nsWeakPtr mFileHandle;
|
2014-09-13 16:12:19 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
public:
|
2015-09-09 11:15:05 +00:00
|
|
|
BlobImplSnapshot(BlobImpl* aImpl,
|
|
|
|
IDBFileHandle* aFileHandle);
|
2014-09-13 16:12:19 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
private:
|
2015-09-09 11:15:05 +00:00
|
|
|
BlobImplSnapshot(BlobImpl* aImpl,
|
|
|
|
nsIWeakReference* aFileHandle);
|
2014-09-26 23:21:57 +00:00
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
~BlobImplSnapshot();
|
2014-09-26 23:21:57 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
// BlobImpl
|
|
|
|
virtual void
|
2016-04-01 10:50:16 +00:00
|
|
|
GetName(nsAString& aName) const override
|
2015-09-09 11:15:05 +00:00
|
|
|
{
|
|
|
|
mBlobImpl->GetName(aName);
|
|
|
|
}
|
2014-09-26 23:21:57 +00:00
|
|
|
|
2014-10-08 16:15:22 +00:00
|
|
|
virtual void
|
2017-02-06 10:07:54 +00:00
|
|
|
GetDOMPath(nsAString& aPath) const override
|
2015-09-09 11:15:05 +00:00
|
|
|
{
|
2017-02-06 10:07:54 +00:00
|
|
|
mBlobImpl->GetDOMPath(aPath);
|
2016-05-13 11:11:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2017-02-06 10:07:54 +00:00
|
|
|
SetDOMPath(const nsAString& aPath) override
|
2016-05-13 11:11:38 +00:00
|
|
|
{
|
2017-02-06 10:07:54 +00:00
|
|
|
mBlobImpl->SetDOMPath(aPath);
|
2015-09-09 11:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int64_t
|
|
|
|
GetLastModified(ErrorResult& aRv) override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetLastModified(aRv);
|
|
|
|
}
|
2014-07-17 16:40:54 +00:00
|
|
|
|
2015-05-19 14:36:37 +00:00
|
|
|
virtual void
|
2015-09-09 11:15:05 +00:00
|
|
|
SetLastModified(int64_t aLastModified) override
|
|
|
|
{
|
|
|
|
mBlobImpl->SetLastModified(aLastModified);
|
|
|
|
}
|
2014-06-26 16:47:44 +00:00
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
virtual void
|
2017-02-01 20:43:37 +00:00
|
|
|
GetMozFullPath(nsAString& aName, SystemCallerGuarantee aGuarantee,
|
|
|
|
ErrorResult& aRv) const override
|
2015-01-11 21:35:24 +00:00
|
|
|
{
|
2017-02-01 20:43:37 +00:00
|
|
|
mBlobImpl->GetMozFullPath(aName, aGuarantee, aRv);
|
2015-09-09 11:15:05 +00: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);
|
|
|
|
}
|
|
|
|
|
2017-09-12 09:46:51 +00:00
|
|
|
size_t
|
|
|
|
GetAllocationSize() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetAllocationSize();
|
|
|
|
}
|
|
|
|
|
2015-09-09 11:15:05 +00:00
|
|
|
virtual uint64_t
|
|
|
|
GetSerialNumber() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetSerialNumber();
|
2015-01-11 21:35:24 +00:00
|
|
|
}
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
virtual already_AddRefed<BlobImpl>
|
2014-09-26 23:21:57 +00:00
|
|
|
CreateSlice(uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
2014-10-08 16:15:22 +00:00
|
|
|
const nsAString& aContentType,
|
2015-03-21 16:28:04 +00:00
|
|
|
ErrorResult& aRv) override;
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
virtual const nsTArray<RefPtr<BlobImpl>>*
|
2015-09-09 11:15:05 +00:00
|
|
|
GetSubBlobImpls() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->GetSubBlobImpls();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2017-10-02 11:53:12 +00:00
|
|
|
CreateInputStream(nsIInputStream** aStream,
|
2015-09-09 11:15:05 +00: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-07 22:00:51 +00:00
|
|
|
int64_t aLastModifiedDate) override
|
2015-09-09 11:15:05 +00: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 16:33:52 +00:00
|
|
|
virtual bool
|
2015-09-09 11:15:05 +00:00
|
|
|
IsDateUnknown() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->IsDateUnknown();
|
|
|
|
}
|
2012-06-03 16:33:52 +00:00
|
|
|
|
|
|
|
virtual bool
|
2015-09-09 11:15:05 +00:00
|
|
|
IsFile() const override
|
|
|
|
{
|
|
|
|
return mBlobImpl->IsFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
MayBeClonedToOtherThreads() const override
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// PIBlobImplSnapshot
|
|
|
|
virtual BlobImpl*
|
|
|
|
GetBlobImpl() const override;
|
2012-06-03 16:33:52 +00:00
|
|
|
};
|
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
} // namespace indexedDB
|
2014-05-07 14:32:12 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 16:33:52 +00:00
|
|
|
|
2014-07-17 16:40:54 +00:00
|
|
|
#endif // mozilla_dom_indexeddb_filesnapshot_h__
|