Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_workers_filereadersync_h__ |
michael@0 | 8 | #define mozilla_dom_workers_filereadersync_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "Workers.h" |
michael@0 | 11 | |
michael@0 | 12 | class nsIInputStream; |
michael@0 | 13 | class nsIDOMBlob; |
michael@0 | 14 | |
michael@0 | 15 | namespace mozilla { |
michael@0 | 16 | class ErrorResult; |
michael@0 | 17 | |
michael@0 | 18 | namespace dom { |
michael@0 | 19 | class GlobalObject; |
michael@0 | 20 | template<typename> class Optional; |
michael@0 | 21 | } |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | BEGIN_WORKERS_NAMESPACE |
michael@0 | 25 | |
michael@0 | 26 | class FileReaderSync MOZ_FINAL |
michael@0 | 27 | { |
michael@0 | 28 | NS_INLINE_DECL_REFCOUNTING(FileReaderSync) |
michael@0 | 29 | |
michael@0 | 30 | private: |
michael@0 | 31 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 32 | ~FileReaderSync() |
michael@0 | 33 | { |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset, |
michael@0 | 37 | nsAString &aResult); |
michael@0 | 38 | |
michael@0 | 39 | public: |
michael@0 | 40 | static already_AddRefed<FileReaderSync> |
michael@0 | 41 | Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); |
michael@0 | 42 | |
michael@0 | 43 | JSObject* WrapObject(JSContext* aCx); |
michael@0 | 44 | |
michael@0 | 45 | void ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aScopeObj, |
michael@0 | 46 | JS::Handle<JSObject*> aBlob, |
michael@0 | 47 | JS::MutableHandle<JSObject*> aRetval, |
michael@0 | 48 | ErrorResult& aRv); |
michael@0 | 49 | void ReadAsBinaryString(JS::Handle<JSObject*> aBlob, nsAString& aResult, |
michael@0 | 50 | ErrorResult& aRv); |
michael@0 | 51 | void ReadAsText(JS::Handle<JSObject*> aBlob, |
michael@0 | 52 | const Optional<nsAString>& aEncoding, |
michael@0 | 53 | nsAString& aResult, ErrorResult& aRv); |
michael@0 | 54 | void ReadAsDataURL(JS::Handle<JSObject*> aBlob, nsAString& aResult, |
michael@0 | 55 | ErrorResult& aRv); |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | END_WORKERS_NAMESPACE |
michael@0 | 59 | |
michael@0 | 60 | #endif // mozilla_dom_workers_filereadersync_h__ |