зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1836432 - Use nsresult exception mode for GeckoAppShell.getDNSDomains. r=geckoview-reviewers,necko-reviewers,valentin,ohall
There is some OOM errors by `GeckoAppShell.getDNSDomains`. Since `nsAndroidNetworkLinkService::GetDnsSuffixList` can returns `nsresult`, we should return error instead of crash. Differential Revision: https://phabricator.services.mozilla.com/D179791
This commit is contained in:
Родитель
8fb7636d74
Коммит
19f275b625
|
@ -1052,7 +1052,7 @@ public class GeckoAppShell {
|
|||
}
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
@WrapForJNI(calledFrom = "gecko", exceptionMode = "nsresult")
|
||||
private static String getDNSDomains() {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return "";
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
#include "AndroidBridge.h"
|
||||
#include "mozilla/java/GeckoAppShellWrappers.h"
|
||||
#include "mozilla/jni/Utils.h"
|
||||
|
||||
namespace java = mozilla::java;
|
||||
namespace jni = mozilla::jni;
|
||||
|
||||
static mozilla::LazyLogModule gNotifyAddrLog("nsAndroidNetworkLinkService");
|
||||
#define LOG(args) MOZ_LOG(gNotifyAddrLog, mozilla::LogLevel::Debug, args)
|
||||
|
@ -135,13 +137,18 @@ NS_IMETHODIMP
|
|||
nsAndroidNetworkLinkService::GetDnsSuffixList(
|
||||
nsTArray<nsCString>& aDnsSuffixList) {
|
||||
aDnsSuffixList.Clear();
|
||||
if (!mozilla::AndroidBridge::Bridge()) {
|
||||
NS_WARNING("GetDnsSuffixList is not supported without a bridge connection");
|
||||
if (!jni::IsAvailable()) {
|
||||
NS_WARNING("GetDnsSuffixList is not supported without JNI");
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
auto suffixList = java::GeckoAppShell::GetDNSDomains();
|
||||
if (!suffixList) {
|
||||
jni::String::LocalRef suffixList;
|
||||
nsresult rv = java::GeckoAppShell::GetDNSDomains(&suffixList);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!suffixList || !suffixList->Length()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче