FileReaderSync.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_filereadersync_h__
  6. #define mozilla_dom_filereadersync_h__
  7. #include "Workers.h"
  8. class nsIInputStream;
  9. namespace mozilla {
  10. class ErrorResult;
  11. namespace dom {
  12. class Blob;
  13. class GlobalObject;
  14. template<typename> class Optional;
  15. class FileReaderSync final
  16. {
  17. NS_INLINE_DECL_REFCOUNTING(FileReaderSync)
  18. private:
  19. // Private destructor, to discourage deletion outside of Release():
  20. ~FileReaderSync()
  21. {
  22. }
  23. nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset,
  24. nsAString &aResult);
  25. public:
  26. static already_AddRefed<FileReaderSync>
  27. Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
  28. bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
  29. void ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aScopeObj,
  30. Blob& aBlob, JS::MutableHandle<JSObject*> aRetval,
  31. ErrorResult& aRv);
  32. void ReadAsBinaryString(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
  33. void ReadAsText(Blob& aBlob, const Optional<nsAString>& aEncoding,
  34. nsAString& aResult, ErrorResult& aRv);
  35. void ReadAsDataURL(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
  36. };
  37. } // namespace dom
  38. } // namespace mozilla
  39. #endif // mozilla_dom_filereadersync_h__