Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsAndroidNetworkLinkService.h" |
michael@0 | 8 | #include "nsServiceManagerUtils.h" |
michael@0 | 9 | #include "mozilla/Services.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "AndroidBridge.h" |
michael@0 | 12 | |
michael@0 | 13 | using namespace mozilla::widget::android; |
michael@0 | 14 | |
michael@0 | 15 | NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService, |
michael@0 | 16 | nsINetworkLinkService) |
michael@0 | 17 | |
michael@0 | 18 | nsAndroidNetworkLinkService::nsAndroidNetworkLinkService() |
michael@0 | 19 | { |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService() |
michael@0 | 23 | { |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | NS_IMETHODIMP |
michael@0 | 27 | nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp) |
michael@0 | 28 | { |
michael@0 | 29 | if (!mozilla::AndroidBridge::Bridge()) { |
michael@0 | 30 | // Fail soft here and assume a connection exists |
michael@0 | 31 | NS_WARNING("GetIsLinkUp is not supported without a bridge connection"); |
michael@0 | 32 | *aIsUp = true; |
michael@0 | 33 | return NS_OK; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp(); |
michael@0 | 37 | return NS_OK; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | NS_IMETHODIMP |
michael@0 | 41 | nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown) |
michael@0 | 42 | { |
michael@0 | 43 | NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED); |
michael@0 | 44 | |
michael@0 | 45 | *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown(); |
michael@0 | 46 | return NS_OK; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | NS_IMETHODIMP |
michael@0 | 50 | nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType) |
michael@0 | 51 | { |
michael@0 | 52 | NS_ENSURE_ARG_POINTER(aLinkType); |
michael@0 | 53 | |
michael@0 | 54 | if (!mozilla::AndroidBridge::Bridge()) { |
michael@0 | 55 | // Fail soft here and assume a connection exists |
michael@0 | 56 | NS_WARNING("GetLinkType is not supported without a bridge connection"); |
michael@0 | 57 | *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; |
michael@0 | 58 | return NS_OK; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType(); |
michael@0 | 62 | return NS_OK; |
michael@0 | 63 | } |