netwerk/system/android/nsAndroidNetworkLinkService.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/system/android/nsAndroidNetworkLinkService.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsAndroidNetworkLinkService.h"
    1.11 +#include "nsServiceManagerUtils.h"
    1.12 +#include "mozilla/Services.h"
    1.13 +
    1.14 +#include "AndroidBridge.h"
    1.15 +
    1.16 +using namespace mozilla::widget::android;
    1.17 +
    1.18 +NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService,
    1.19 +                  nsINetworkLinkService)
    1.20 +
    1.21 +nsAndroidNetworkLinkService::nsAndroidNetworkLinkService()
    1.22 +{
    1.23 +}
    1.24 +
    1.25 +nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService()
    1.26 +{
    1.27 +}
    1.28 +
    1.29 +NS_IMETHODIMP
    1.30 +nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
    1.31 +{
    1.32 +  if (!mozilla::AndroidBridge::Bridge()) {
    1.33 +    // Fail soft here and assume a connection exists
    1.34 +    NS_WARNING("GetIsLinkUp is not supported without a bridge connection");
    1.35 +    *aIsUp = true;
    1.36 +    return NS_OK;
    1.37 +  }
    1.38 +
    1.39 +  *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp();
    1.40 +  return NS_OK;
    1.41 +}
    1.42 +
    1.43 +NS_IMETHODIMP
    1.44 +nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
    1.45 +{
    1.46 +  NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
    1.47 +
    1.48 +  *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown();
    1.49 +  return NS_OK;
    1.50 +}
    1.51 +
    1.52 +NS_IMETHODIMP
    1.53 +nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType)
    1.54 +{
    1.55 +  NS_ENSURE_ARG_POINTER(aLinkType);
    1.56 +
    1.57 +  if (!mozilla::AndroidBridge::Bridge()) {
    1.58 +    // Fail soft here and assume a connection exists
    1.59 +    NS_WARNING("GetLinkType is not supported without a bridge connection");
    1.60 +    *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
    1.61 +    return NS_OK;
    1.62 +  }
    1.63 +
    1.64 +  *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType();
    1.65 +  return NS_OK;
    1.66 +}

mercurial