diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /mobile/android/components/geckoview/GeckoViewOutputStream.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
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.cpp | 61 |
1 files changed, 61 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..6368363f59 --- /dev/null +++ b/mobile/android/components/geckoview/GeckoViewOutputStream.cpp @@ -0,0 +1,61 @@ +/* -*- 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::StreamStatus() { + return mStream->IsStreamClosed() ? NS_BASE_STREAM_CLOSED : NS_OK; +} + +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; +} |