Line data Source code
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 "Workers.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 0 : class FileReaderSync final
23 : {
24 0 : NS_INLINE_DECL_REFCOUNTING(FileReaderSync)
25 :
26 : private:
27 : // Private destructor, to discourage deletion outside of Release():
28 0 : ~FileReaderSync()
29 0 : {
30 0 : }
31 :
32 : nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset,
33 : nsAString &aResult);
34 :
35 : nsresult ConvertAsyncToSyncStream(nsIInputStream* aAsyncStream,
36 : nsIInputStream** aSyncStream);
37 :
38 : nsresult SyncRead(nsIInputStream* aStream, char* aBuffer,
39 : uint32_t aBufferSize, uint32_t* aRead);
40 :
41 : public:
42 : static already_AddRefed<FileReaderSync>
43 : Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
44 :
45 : bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
46 :
47 : void ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aScopeObj,
48 : Blob& aBlob, JS::MutableHandle<JSObject*> aRetval,
49 : ErrorResult& aRv);
50 : void ReadAsBinaryString(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
51 : void ReadAsText(Blob& aBlob, const Optional<nsAString>& aEncoding,
52 : nsAString& aResult, ErrorResult& aRv);
53 : void ReadAsDataURL(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
54 : };
55 :
56 : } // namespace dom
57 : } // namespace mozilla
58 :
59 : #endif // mozilla_dom_filereadersync_h__
|