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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_filereadersync_h__
8 #define mozilla_dom_filereadersync_h__
10 #include "mozilla/dom/WorkerCommon.h"
11 #include "nsISupports.h"
24 class FileReaderSync final
{
25 NS_INLINE_DECL_REFCOUNTING(FileReaderSync
)
28 // Private destructor, to discourage deletion outside of Release():
29 ~FileReaderSync() = default;
31 nsresult
ConvertStream(nsIInputStream
* aStream
, const char* aCharset
,
34 nsresult
ConvertAsyncToSyncStream(
35 uint64_t aStreamSize
, already_AddRefed
<nsIInputStream
> aAsyncStream
,
36 nsIInputStream
** aSyncStream
);
38 nsresult
SyncRead(nsIInputStream
* aStream
, char* aBuffer
,
39 uint32_t aBufferSize
, uint32_t* aTotalBytesRead
);
42 static already_AddRefed
<FileReaderSync
> Constructor(
43 const GlobalObject
& aGlobal
);
45 bool WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
,
46 JS::MutableHandle
<JSObject
*> aReflector
);
48 void ReadAsArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aScopeObj
,
49 Blob
& aBlob
, JS::MutableHandle
<JSObject
*> aRetval
,
51 void ReadAsBinaryString(Blob
& aBlob
, nsAString
& aResult
, ErrorResult
& aRv
);
52 void ReadAsText(Blob
& aBlob
, const Optional
<nsAString
>& aEncoding
,
53 nsAString
& aResult
, ErrorResult
& aRv
);
54 void ReadAsDataURL(Blob
& aBlob
, nsAString
& aResult
, ErrorResult
& aRv
);
58 } // namespace mozilla
60 #endif // mozilla_dom_filereadersync_h__