2014-07-17 20:40:54 +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: */
|
2014-07-17 20:40:54 +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/. */
|
|
|
|
|
|
|
|
#include "FileSnapshot.h"
|
|
|
|
|
2017-06-07 13:36:20 +03:00
|
|
|
#include "IDBDatabase.h"
|
2014-07-17 20:40:54 +04:00
|
|
|
#include "IDBFileHandle.h"
|
2017-06-07 13:36:20 +03:00
|
|
|
#include "IDBMutableFile.h"
|
2014-07-17 20:40:54 +04:00
|
|
|
#include "mozilla/Assertions.h"
|
2018-04-10 18:33:09 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
2017-05-09 23:35:42 +03:00
|
|
|
#include "nsIAsyncInputStream.h"
|
|
|
|
#include "nsICloneableInputStream.h"
|
2015-09-09 14:15:05 +03:00
|
|
|
#include "nsIIPCSerializableInputStream.h"
|
2014-07-17 20:40:54 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class StreamWrapper final
|
2017-05-09 23:35:42 +03:00
|
|
|
: public nsIAsyncInputStream
|
|
|
|
, public nsIInputStreamCallback
|
|
|
|
, public nsICloneableInputStream
|
2015-09-09 14:15:05 +03:00
|
|
|
, public nsIIPCSerializableInputStream
|
|
|
|
{
|
|
|
|
class CloseRunnable;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventTarget> mOwningThread;
|
|
|
|
nsCOMPtr<nsIInputStream> mInputStream;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBFileHandle> mFileHandle;
|
2015-09-09 14:15:05 +03:00
|
|
|
bool mFinished;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2017-05-09 23:35:42 +03:00
|
|
|
// This is needed to call OnInputStreamReady() with the correct inputStream.
|
2018-04-10 18:33:09 +03:00
|
|
|
// It is protected by mutex.
|
2017-05-09 23:35:42 +03:00
|
|
|
nsCOMPtr<nsIInputStreamCallback> mAsyncWaitCallback;
|
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
Mutex mMutex;
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
public:
|
|
|
|
StreamWrapper(nsIInputStream* aInputStream,
|
|
|
|
IDBFileHandle* aFileHandle)
|
2017-01-13 11:40:58 +03:00
|
|
|
: mOwningThread(aFileHandle->GetMutableFile()->Database()->EventTarget())
|
2015-09-09 14:15:05 +03:00
|
|
|
, mInputStream(aInputStream)
|
|
|
|
, mFileHandle(aFileHandle)
|
|
|
|
, mFinished(false)
|
2018-04-10 18:33:09 +03:00
|
|
|
, mMutex("StreamWrapper::mMutex")
|
2015-09-09 14:15:05 +03:00
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aInputStream);
|
|
|
|
MOZ_ASSERT(aFileHandle);
|
|
|
|
aFileHandle->AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
mFileHandle->OnNewRequest();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~StreamWrapper();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsOnOwningThread() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mOwningThread);
|
|
|
|
|
|
|
|
bool current;
|
|
|
|
return NS_SUCCEEDED(mOwningThread->
|
|
|
|
IsOnCurrentThread(¤t)) && current;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AssertIsOnOwningThread() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsOnOwningThread());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Finish()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
if (mFinished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFinished = true;
|
|
|
|
|
|
|
|
mFileHandle->OnRequestFinished(/* aActorDestroyedNormally */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Destroy()
|
|
|
|
{
|
|
|
|
if (IsOnOwningThread()) {
|
|
|
|
delete this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-13 11:40:58 +03:00
|
|
|
RefPtr<Runnable> destroyRunnable =
|
|
|
|
NewNonOwningRunnableMethod("StreamWrapper::Destroy",
|
|
|
|
this,
|
|
|
|
&StreamWrapper::Destroy);
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2016-03-28 20:28:15 +03:00
|
|
|
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(destroyRunnable,
|
|
|
|
NS_DISPATCH_NORMAL));
|
2015-09-09 14:15:05 +03:00
|
|
|
}
|
|
|
|
|
2017-05-09 23:35:42 +03:00
|
|
|
bool
|
|
|
|
IsCloneableInputStream() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream =
|
|
|
|
do_QueryInterface(mInputStream);
|
|
|
|
return !!stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsIPCSerializableInputStream() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
|
|
|
do_QueryInterface(mInputStream);
|
|
|
|
return !!stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsAsyncInputStream() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
return !!stream;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIINPUTSTREAM
|
2017-05-09 23:35:42 +03:00
|
|
|
NS_DECL_NSIASYNCINPUTSTREAM
|
|
|
|
NS_DECL_NSIINPUTSTREAMCALLBACK
|
|
|
|
NS_DECL_NSICLONEABLEINPUTSTREAM
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
|
|
|
|
};
|
|
|
|
|
|
|
|
class StreamWrapper::CloseRunnable final
|
2016-04-26 03:23:21 +03:00
|
|
|
: public Runnable
|
2015-09-09 14:15:05 +03:00
|
|
|
{
|
|
|
|
friend class StreamWrapper;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<StreamWrapper> mStreamWrapper;
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
public:
|
2018-02-12 23:44:40 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(CloseRunnable, Runnable)
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit
|
|
|
|
CloseRunnable(StreamWrapper* aStreamWrapper)
|
2017-01-13 11:40:58 +03:00
|
|
|
: Runnable("StreamWrapper::CloseRunnable")
|
|
|
|
, mStreamWrapper(aStreamWrapper)
|
2015-09-09 14:15:05 +03:00
|
|
|
{ }
|
|
|
|
|
|
|
|
~CloseRunnable()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Run() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
BlobImplSnapshot::BlobImplSnapshot(BlobImpl* aFileImpl,
|
|
|
|
IDBFileHandle* aFileHandle)
|
|
|
|
: mBlobImpl(aFileImpl)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFileImpl);
|
|
|
|
MOZ_ASSERT(aFileHandle);
|
2015-01-12 00:35:24 +03:00
|
|
|
|
|
|
|
mFileHandle =
|
|
|
|
do_GetWeakReference(NS_ISUPPORTS_CAST(EventTarget*, aFileHandle));
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
BlobImplSnapshot::BlobImplSnapshot(BlobImpl* aFileImpl,
|
|
|
|
nsIWeakReference* aFileHandle)
|
|
|
|
: mBlobImpl(aFileImpl)
|
|
|
|
, mFileHandle(aFileHandle)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFileImpl);
|
|
|
|
MOZ_ASSERT(aFileHandle);
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
BlobImplSnapshot::~BlobImplSnapshot()
|
2014-07-17 20:40:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(BlobImplSnapshot, BlobImpl, PIBlobImplSnapshot)
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
already_AddRefed<BlobImpl>
|
|
|
|
BlobImplSnapshot::CreateSlice(uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
|
|
|
const nsAString& aContentType,
|
|
|
|
ErrorResult& aRv)
|
2014-09-27 03:21:57 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<BlobImpl> blobImpl =
|
2015-09-09 14:15:05 +03:00
|
|
|
mBlobImpl->CreateSlice(aStart, aLength, aContentType, aRv);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
blobImpl = new BlobImplSnapshot(blobImpl, mFileHandle);
|
|
|
|
return blobImpl.forget();
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-05-19 17:36:37 +03:00
|
|
|
void
|
2017-10-02 14:53:12 +03:00
|
|
|
BlobImplSnapshot::CreateInputStream(nsIInputStream** aStream, ErrorResult& aRv)
|
2014-07-17 20:40:54 +04:00
|
|
|
{
|
2015-01-12 00:35:24 +03:00
|
|
|
nsCOMPtr<EventTarget> et = do_QueryReferent(mFileHandle);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBFileHandle> fileHandle = static_cast<IDBFileHandle*>(et.get());
|
2015-09-09 14:15:05 +03:00
|
|
|
if (!fileHandle || !fileHandle->IsOpen()) {
|
2015-05-19 17:36:37 +03:00
|
|
|
aRv.Throw(NS_ERROR_DOM_FILEHANDLE_INACTIVE_ERR);
|
|
|
|
return;
|
2015-01-12 00:35:24 +03:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
2017-10-02 14:53:12 +03:00
|
|
|
mBlobImpl->CreateInputStream(getter_AddRefs(stream), aRv);
|
2015-05-19 17:36:37 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return;
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<StreamWrapper> wrapper = new StreamWrapper(stream, fileHandle);
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
wrapper.forget(aStream);
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
BlobImpl*
|
|
|
|
BlobImplSnapshot::GetBlobImpl() const
|
2014-07-17 20:40:54 +04:00
|
|
|
{
|
2015-09-09 14:15:05 +03:00
|
|
|
nsCOMPtr<EventTarget> et = do_QueryReferent(mFileHandle);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBFileHandle> fileHandle = static_cast<IDBFileHandle*>(et.get());
|
2015-09-09 14:15:05 +03:00
|
|
|
if (!fileHandle || !fileHandle->IsOpen()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-07-17 20:40:54 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
return mBlobImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamWrapper::~StreamWrapper()
|
|
|
|
{
|
|
|
|
AssertIsOnOwningThread();
|
2014-07-17 20:40:54 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
Finish();
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_IMPL_ADDREF(StreamWrapper)
|
|
|
|
NS_IMPL_RELEASE_WITH_DESTROY(StreamWrapper, Destroy())
|
2017-05-09 23:35:42 +03:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(StreamWrapper)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAsyncInputStream,
|
|
|
|
IsAsyncInputStream())
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIInputStreamCallback,
|
|
|
|
IsAsyncInputStream())
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsICloneableInputStream,
|
|
|
|
IsCloneableInputStream())
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableInputStream,
|
|
|
|
IsIPCSerializableInputStream())
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream)
|
|
|
|
NS_INTERFACE_MAP_END
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::Close()
|
2014-07-17 20:40:54 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<CloseRunnable> closeRunnable = new CloseRunnable(this);
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2016-03-28 20:28:15 +03:00
|
|
|
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(closeRunnable,
|
|
|
|
NS_DISPATCH_NORMAL));
|
2015-09-09 14:15:05 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
2014-07-17 20:40:54 +04:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::Available(uint64_t* _retval)
|
2014-09-27 03:21:57 +04:00
|
|
|
{
|
2015-09-09 14:15:05 +03:00
|
|
|
return mInputStream->Available(_retval);
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::Read(char* aBuf, uint32_t aCount, uint32_t* _retval)
|
|
|
|
{
|
|
|
|
return mInputStream->Read(aBuf, aCount, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
|
|
|
|
uint32_t aCount, uint32_t* _retval)
|
|
|
|
{
|
|
|
|
return mInputStream->ReadSegments(aWriter, aClosure, aCount, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::IsNonBlocking(bool* _retval)
|
|
|
|
{
|
|
|
|
return mInputStream->IsNonBlocking(_retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamWrapper::Serialize(InputStreamParams& aParams,
|
|
|
|
FileDescriptorArray& aFileDescriptors)
|
2014-09-27 03:21:57 +04:00
|
|
|
{
|
2015-09-09 14:15:05 +03:00
|
|
|
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
|
|
|
do_QueryInterface(mInputStream);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
if (stream) {
|
|
|
|
stream->Serialize(aParams, aFileDescriptors);
|
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-09-09 14:15:05 +03:00
|
|
|
StreamWrapper::Deserialize(const InputStreamParams& aParams,
|
|
|
|
const FileDescriptorArray& aFileDescriptors)
|
|
|
|
{
|
2017-05-09 23:35:42 +03:00
|
|
|
MOZ_CRASH("This method should never be called");
|
2015-09-09 14:15:05 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-29 07:20:00 +03:00
|
|
|
Maybe<uint64_t>
|
|
|
|
StreamWrapper::ExpectedSerializedLength()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
|
|
|
do_QueryInterface(mInputStream);
|
|
|
|
|
|
|
|
if (stream) {
|
|
|
|
return stream->ExpectedSerializedLength();
|
|
|
|
}
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
2017-05-09 23:35:42 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::CloseWithStatus(nsresult aStatus)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = stream->CloseWithStatus(aStatus);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::AsyncWait(nsIInputStreamCallback* aCallback,
|
|
|
|
uint32_t aFlags,
|
|
|
|
uint32_t aRequestedCount,
|
|
|
|
nsIEventTarget* aEventTarget)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
2017-05-09 23:35:42 +03:00
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
if (mAsyncWaitCallback && aCallback) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2017-05-09 23:35:42 +03:00
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
mAsyncWaitCallback = aCallback;
|
2017-05-09 23:35:42 +03:00
|
|
|
}
|
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
return stream->AsyncWait(callback, aFlags, aRequestedCount, aEventTarget);
|
2017-05-09 23:35:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIInputStreamCallback
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::OnInputStreamReady(nsIAsyncInputStream* aStream)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStreamCallback> callback;
|
2018-04-10 18:33:09 +03:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
|
|
|
|
// We have been canceled in the meanwhile.
|
|
|
|
if (!mAsyncWaitCallback) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
callback.swap(mAsyncWaitCallback);
|
|
|
|
}
|
2017-05-09 23:35:42 +03:00
|
|
|
|
2018-04-10 18:33:09 +03:00
|
|
|
MOZ_ASSERT(callback);
|
2017-05-09 23:35:42 +03:00
|
|
|
return callback->OnInputStreamReady(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsICloneableInputStream
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::GetCloneable(bool* aCloneable)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
if (!stream) {
|
|
|
|
*aCloneable = false;
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stream->GetCloneable(aCloneable);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::Clone(nsIInputStream** aResult)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream = do_QueryInterface(mInputStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stream->Clone(aResult);
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
StreamWrapper::
|
|
|
|
CloseRunnable::Run()
|
2014-09-27 03:21:57 +04:00
|
|
|
{
|
2015-09-09 14:15:05 +03:00
|
|
|
mStreamWrapper->Finish();
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-09-09 14:15:05 +03:00
|
|
|
return NS_OK;
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
2014-07-17 20:40:54 +04:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|