Bug 1864095 - Remove superflous OOM throwing test cases. r=jandem
[gecko.git] / mobile / android / components / geckoview / GeckoViewContentChannel.cpp
blob49236b074cb97d44e2940c98640783a0c392a374
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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/. */
7 #include "GeckoViewContentChannel.h"
8 #include "GeckoViewInputStream.h"
9 #include "mozilla/java/ContentInputStreamWrappers.h"
11 using namespace mozilla;
13 GeckoViewContentChannel::GeckoViewContentChannel(nsIURI* aURI) {
14 SetURI(aURI);
15 SetOriginalURI(aURI);
18 NS_IMETHODIMP
19 GeckoViewContentChannel::OpenContentStream(bool aAsync,
20 nsIInputStream** aResult,
21 nsIChannel** aChannel) {
22 nsCOMPtr<nsIURI> uri;
23 nsresult rv = GetURI(getter_AddRefs(uri));
24 NS_ENSURE_SUCCESS(rv, NS_ERROR_MALFORMED_URI);
26 nsAutoCString spec;
27 rv = uri->GetSpec(spec);
28 NS_ENSURE_SUCCESS(rv, rv);
30 bool isReadable = GeckoViewContentInputStream::isReadable(spec);
31 if (!isReadable) {
32 return NS_ERROR_FILE_NOT_FOUND;
35 nsCOMPtr<nsIInputStream> inputStream;
36 rv = GeckoViewContentInputStream::getInstance(spec,
37 getter_AddRefs(inputStream));
38 NS_ENSURE_SUCCESS(rv, rv);
40 if (NS_WARN_IF(!inputStream)) {
41 return NS_ERROR_MALFORMED_URI;
44 inputStream.forget(aResult);
46 return NS_OK;