/work/obj-fuzz/dist/include/mozilla/dom/FileReaderSync.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_filereadersync_h__ |
8 | | #define mozilla_dom_filereadersync_h__ |
9 | | |
10 | | #include "mozilla/dom/WorkerCommon.h" |
11 | | |
12 | | class nsIInputStream; |
13 | | |
14 | | namespace mozilla { |
15 | | class ErrorResult; |
16 | | |
17 | | namespace dom { |
18 | | class Blob; |
19 | | class GlobalObject; |
20 | | template<typename> class Optional; |
21 | | |
22 | | class FileReaderSync final |
23 | | { |
24 | | NS_INLINE_DECL_REFCOUNTING(FileReaderSync) |
25 | | |
26 | | private: |
27 | | // Private destructor, to discourage deletion outside of Release(): |
28 | | ~FileReaderSync() |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | | nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset, |
33 | | nsAString &aResult); |
34 | | |
35 | | nsresult ConvertAsyncToSyncStream(uint64_t aStreamSize, |
36 | | already_AddRefed<nsIInputStream> aAsyncStream, |
37 | | nsIInputStream** aSyncStream); |
38 | | |
39 | | nsresult SyncRead(nsIInputStream* aStream, char* aBuffer, |
40 | | uint32_t aBufferSize, uint32_t* aRead); |
41 | | |
42 | | public: |
43 | | static already_AddRefed<FileReaderSync> |
44 | | Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); |
45 | | |
46 | | bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
47 | | |
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); |
55 | | }; |
56 | | |
57 | | } // namespace dom |
58 | | } // namespace mozilla |
59 | | |
60 | | #endif // mozilla_dom_filereadersync_h__ |