Bug 1854550 - pt 10. Allow LOG() with zero extra arguments r=glandium
[gecko.git] / dom / file / FileReaderSync.h
blob84eb5a73a8352353f07d2881c62e965b33c59a6e
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"
13 class nsIInputStream;
15 namespace mozilla {
16 class ErrorResult;
18 namespace dom {
19 class Blob;
20 class GlobalObject;
21 template <typename>
22 class Optional;
24 class FileReaderSync final {
25 NS_INLINE_DECL_REFCOUNTING(FileReaderSync)
27 private:
28 // Private destructor, to discourage deletion outside of Release():
29 ~FileReaderSync() = default;
31 nsresult ConvertStream(nsIInputStream* aStream, const char* aCharset,
32 nsAString& aResult);
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);
41 public:
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,
50 ErrorResult& aRv);
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);
57 } // namespace dom
58 } // namespace mozilla
60 #endif // mozilla_dom_filereadersync_h__