netwerk/system/android/nsAndroidNetworkLinkService.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=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 "nsAndroidNetworkLinkService.h"
     8 #include "nsServiceManagerUtils.h"
     9 #include "mozilla/Services.h"
    11 #include "AndroidBridge.h"
    13 using namespace mozilla::widget::android;
    15 NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService,
    16                   nsINetworkLinkService)
    18 nsAndroidNetworkLinkService::nsAndroidNetworkLinkService()
    19 {
    20 }
    22 nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService()
    23 {
    24 }
    26 NS_IMETHODIMP
    27 nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
    28 {
    29   if (!mozilla::AndroidBridge::Bridge()) {
    30     // Fail soft here and assume a connection exists
    31     NS_WARNING("GetIsLinkUp is not supported without a bridge connection");
    32     *aIsUp = true;
    33     return NS_OK;
    34   }
    36   *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp();
    37   return NS_OK;
    38 }
    40 NS_IMETHODIMP
    41 nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
    42 {
    43   NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
    45   *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown();
    46   return NS_OK;
    47 }
    49 NS_IMETHODIMP
    50 nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType)
    51 {
    52   NS_ENSURE_ARG_POINTER(aLinkType);
    54   if (!mozilla::AndroidBridge::Bridge()) {
    55     // Fail soft here and assume a connection exists
    56     NS_WARNING("GetLinkType is not supported without a bridge connection");
    57     *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
    58     return NS_OK;
    59   }
    61   *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType();
    62   return NS_OK;
    63 }

mercurial