GeckoViewInputStream.h (1651B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cin: */ 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 GeckoViewInputStream_h__ 8 #define GeckoViewInputStream_h__ 9 10 #include "mozilla/java/GeckoViewInputStreamWrappers.h" 11 #include "mozilla/java/ContentInputStreamWrappers.h" 12 #include "nsIAndroidContentInputStream.h" 13 #include "nsIInputStream.h" 14 15 class GeckoViewInputStream : public nsIAndroidContentInputStream { 16 NS_DECL_ISUPPORTS 17 NS_DECL_NSIINPUTSTREAM 18 NS_DECL_NSIANDROIDCONTENTINPUTSTREAM 19 20 GeckoViewInputStream() = default; 21 22 bool IsClosed() const; 23 24 protected: 25 explicit GeckoViewInputStream( 26 mozilla::java::GeckoViewInputStream::LocalRef aInstance) 27 : mInstance(aInstance) {}; 28 29 virtual ~GeckoViewInputStream() = default; 30 31 private: 32 mozilla::java::GeckoViewInputStream::GlobalRef mInstance; 33 bool mClosed{false}; 34 }; 35 36 class GeckoViewContentInputStream final : public GeckoViewInputStream { 37 public: 38 enum class Allow { 39 All, 40 PDFOnly, 41 }; 42 static nsresult GetInstance(const nsAutoCString& aUri, Allow aAllow, 43 nsIInputStream** aInstance); 44 static bool isReadable(const nsAutoCString& aUri); 45 46 private: 47 explicit GeckoViewContentInputStream(const nsAutoCString& aUri, bool aPDFOnly) 48 : GeckoViewInputStream(mozilla::java::ContentInputStream::GetInstance( 49 mozilla::jni::StringParam(aUri), aPDFOnly)) {} 50 }; 51 52 #endif // !GeckoViewInputStream_h__