summaryrefslogtreecommitdiffstats
path: root/mobile/android/components/geckoview/GeckoViewOutputStream.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /mobile/android/components/geckoview/GeckoViewOutputStream.cpp
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mobile/android/components/geckoview/GeckoViewOutputStream.cpp')
-rw-r--r--mobile/android/components/geckoview/GeckoViewOutputStream.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/mobile/android/components/geckoview/GeckoViewOutputStream.cpp b/mobile/android/components/geckoview/GeckoViewOutputStream.cpp
new file mode 100644
index 0000000000..3744b8e82d
--- /dev/null
+++ b/mobile/android/components/geckoview/GeckoViewOutputStream.cpp
@@ -0,0 +1,56 @@
+/* -*- Mode: c++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil; -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "GeckoViewOutputStream.h"
+#include "mozilla/fallible.h"
+
+using namespace mozilla;
+
+NS_IMPL_ISUPPORTS(GeckoViewOutputStream, nsIOutputStream);
+
+NS_IMETHODIMP
+GeckoViewOutputStream::Close() {
+ mStream->SendEof();
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+GeckoViewOutputStream::Flush() { return NS_ERROR_NOT_IMPLEMENTED; }
+
+NS_IMETHODIMP
+GeckoViewOutputStream::Write(const char* buf, uint32_t count,
+ uint32_t* retval) {
+ jni::ByteArray::LocalRef buffer = jni::ByteArray::New(
+ reinterpret_cast<const int8_t*>(buf), count, fallible);
+ if (!buffer) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ if (NS_FAILED(mStream->AppendBuffer(buffer))) {
+ // The stream was closed, abort reading this channel.
+ return NS_BASE_STREAM_CLOSED;
+ }
+ // Return amount of bytes written
+ *retval = count;
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+GeckoViewOutputStream::WriteFrom(nsIInputStream* fromStream, uint32_t count,
+ uint32_t* retval) {
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+GeckoViewOutputStream::WriteSegments(nsReadSegmentFun reader, void* closure,
+ uint32_t count, uint32_t* retval) {
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+GeckoViewOutputStream::IsNonBlocking(bool* retval) {
+ *retval = true;
+ return NS_OK;
+}