Bug 786419 - Part 12: Add getAppOfflineState to nsIIOService r=jduell
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 07 Oct 2014 17:08:07 +0300
changeset 209179 c00a6d8da4d9f14dba076762ef52bee0d67c6942
parent 209178 7e1d2aaeeec1b843ba061552d6e66bd9cc19df85
child 209180 98a881d6282cdf2a20bf9490c45153d90afcf3d1
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjduell
bugs786419
milestone35.0a1
Bug 786419 - Part 12: Add getAppOfflineState to nsIIOService r=jduell
netwerk/base/public/nsIIOService.idl
netwerk/base/src/nsIOService.cpp
--- a/netwerk/base/public/nsIIOService.idl
+++ b/netwerk/base/public/nsIIOService.idl
@@ -101,16 +101,21 @@ interface nsIIOService : nsISupports
     /**
      * Returns true if given appId is currently not allowed to make network
      * connections. It will return true if the app is in the wifi-only state
      * and we are currently on a 3G connection.
      * The returned value does not depend on the offline state of the browser.
      */
     boolean isAppOffline(in uint32_t appId);
 
+    /**
+     * Returns the state of the app with the given appId.
+     * returns nsIAppOfflineInfo::{ONLINE,OFFLINE,WIFI_ONLY}
+     */
+    long getAppOfflineState(in uint32_t appId);
 
     /**
      * Checks if a port number is banned. This involves consulting a list of
      * unsafe ports, corresponding to network services that may be easily
      * exploitable. If the given port is considered unsafe, then the protocol
      * handler (corresponding to aScheme) will be asked whether it wishes to
      * override the IO service's decision to block the port. This gives the
      * protocol handler ultimate control over its own security policy while
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -1501,16 +1501,32 @@ nsIOService::SetAppOfflineInternal(uint3
         break;
     default:
         break;
     }
 
 }
 
 NS_IMETHODIMP
+nsIOService::GetAppOfflineState(uint32_t aAppId, int32_t *aResult)
+{
+    NS_ENSURE_ARG(aResult);
+
+    if (aAppId == NECKO_NO_APP_ID ||
+        aAppId == NECKO_UNKNOWN_APP_ID) {
+        return NS_ERROR_NOT_AVAILABLE;
+    }
+
+    *aResult = nsIAppOfflineInfo::ONLINE;
+    mAppsOfflineStatus.Get(aAppId, aResult);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
 nsIOService::IsAppOffline(uint32_t aAppId, bool* aResult)
 {
     NS_ENSURE_ARG(aResult);
     *aResult = false;
 
     if (aAppId == NECKO_NO_APP_ID ||
         aAppId == NECKO_UNKNOWN_APP_ID) {
         return NS_ERROR_NOT_AVAILABLE;