deleted file mode 100644
--- a/netwerk/base/OfflineObserver.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "OfflineObserver.h"
-#include "nsNetUtil.h"
-#include "nsIOService.h"
-#include "mozilla/net/NeckoCommon.h"
-#include "nsIObserverService.h"
-#include "nsThreadUtils.h"
-namespace mozilla {
-namespace net {
-
-NS_IMPL_ISUPPORTS(OfflineObserver, nsIObserver)
-
-void
-OfflineObserver::RegisterOfflineObserver()
-{
- if (NS_IsMainThread()) {
- RegisterOfflineObserverMainThread();
- } else {
- NS_DispatchToMainThread(NewRunnableMethod(this,
- &OfflineObserver::RegisterOfflineObserverMainThread));
- }
-}
-
-void
-OfflineObserver::RemoveOfflineObserver()
-{
- if (NS_IsMainThread()) {
- RemoveOfflineObserverMainThread();
- } else {
- NS_DispatchToMainThread(NewRunnableMethod(this,
- &OfflineObserver::RemoveOfflineObserverMainThread));
- }
-}
-
-void
-OfflineObserver::RegisterOfflineObserverMainThread()
-{
- nsCOMPtr<nsIObserverService> observerService =
- mozilla::services::GetObserverService();
- if (!observerService) {
- return;
- }
- nsresult rv = observerService->AddObserver(this,
- NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC, false);
- if (NS_FAILED(rv)) {
- NS_WARNING("Failed to register observer");
- }
-}
-
-void
-OfflineObserver::RemoveOfflineObserverMainThread()
-{
- nsCOMPtr<nsIObserverService> observerService =
- mozilla::services::GetObserverService();
- if (observerService) {
- observerService->RemoveObserver(this, NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC);
- }
-}
-
-OfflineObserver::OfflineObserver(DisconnectableParent * parent)
- : mLock("OfflineObserver")
-{
- mParent = parent;
- RegisterOfflineObserver();
-}
-
-void
-OfflineObserver::RemoveObserver()
-{
- {
- mozilla::MutexAutoLock lock(mLock);
- mParent = nullptr;
- }
- RemoveOfflineObserver();
-}
-
-NS_IMETHODIMP
-OfflineObserver::Observe(nsISupports *aSubject,
- const char *aTopic,
- const char16_t *aData)
-{
- mozilla::MutexAutoLock lock(mLock);
- // Since the parent is supposed to call RemoveObserver in its destructor
- // we need to keep the mutex locked while calling OfflineNotification
- // to prevent mParent from going away.
- if (mParent &&
- !strcmp(aTopic, NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC)) {
- mParent->OfflineNotification(aSubject);
- }
- return NS_OK;
-}
-
-nsresult
-DisconnectableParent::OfflineNotification(nsISupports *aSubject)
-{
- nsCOMPtr<nsIAppOfflineInfo> info(do_QueryInterface(aSubject));
- if (!info) {
- return NS_ERROR_NOT_INITIALIZED;
- }
-
- uint32_t targetAppId = NECKO_UNKNOWN_APP_ID;
- info->GetAppId(&targetAppId);
-
- // Obtain App ID
- uint32_t appId = GetAppId();
- if (appId != targetAppId) {
- return NS_OK;
- }
-
- // If the app is offline, close the socket
- if (NS_IsAppOffline(appId)) {
- OfflineDisconnect();
- }
-
- return NS_OK;
-}
-
-} // namespace net
-} // namespace mozilla
deleted file mode 100644
--- a/netwerk/base/OfflineObserver.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsOfflineObserver_h__
-#define nsOfflineObserver_h__
-
-#include "nsIObserver.h"
-
-namespace mozilla {
-namespace net {
-
-/**
- * Parents should extend this class and have a RefPtr<OfflineObserver> member.
- * The constructor should initialize the member to new OfflineObserver(this)
- * and the destructor should call RemoveObserver on the member.
- *
- * GetAppId and OfflineDisconnect are called from the default implementation
- * of OfflineNotification. These should be overridden by classes that don't
- * provide an implementation of OfflineNotification.
- */
-class DisconnectableParent
-{
-public:
- // This is called on the main thread, by the OfflineObserver.
- // aSubject is of type nsAppOfflineInfo and contains appId and offline mode.
- virtual nsresult OfflineNotification(nsISupports *aSubject);
-
- // GetAppId returns the appId for the app associated with the parent
- virtual uint32_t GetAppId() = 0;
-
- // OfflineDisconnect cancels all existing connections in the parent when
- // the app becomes offline.
- // Since the offline observer holds a mutex while calling this,
- // the implementation must make sure it doesn't call back into OfflineObserver
- // or issue a notification for the "network:app-offline-status-changed" topic
- virtual void OfflineDisconnect() { }
-};
-
-/**
- * This class observes the "network:app-offline-status-changed" topic and calls
- * OfflineNotification on the DisconnectableParent with the subject.
- */
-class OfflineObserver
- : public nsIObserver
-{
- NS_DECL_THREADSAFE_ISUPPORTS
- NS_DECL_NSIOBSERVER
-public:
- // A nsRefPtr to this object should be kept by the disconnectable parent.
-
- explicit OfflineObserver(DisconnectableParent * parent);
- // This method needs to be called in the destructor of the parent
- // It removes the observer from the nsObserverService list, and it clears
- // the pointer it holds to the disconnectable parent.
- void RemoveObserver();
-private:
-
- // These methods are called to register and unregister the observer.
- // If they are called on the main thread they register the observer right
- // away, otherwise they dispatch and event to the main thread
- void RegisterOfflineObserver();
- void RemoveOfflineObserver();
- void RegisterOfflineObserverMainThread();
- void RemoveOfflineObserverMainThread();
-private:
- virtual ~OfflineObserver() { }
- // This needs to be a raw pointer, or else the parent's destructor
- // will not get called
- DisconnectableParent * mParent;
- // We need to lock this mutex when accessing the value of mParent
- mozilla::Mutex mLock;
-};
-
-} // namespace net
-} // namespace mozilla
-
-#endif // nsOfflineObserver_h__
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -178,17 +178,16 @@ EXPORTS.mozilla += [
EXPORTS.mozilla.net += [
'CaptivePortalService.h',
'ChannelDiverterChild.h',
'ChannelDiverterParent.h',
'Dashboard.h',
'DashboardTypes.h',
'MemoryDownloader.h',
- 'OfflineObserver.h',
'Predictor.h',
'ReferrerPolicy.h',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
EXPORTS += [
'NetStatistics.h',
]
@@ -247,17 +246,16 @@ UNIFIED_SOURCES += [
'nsStreamTransportService.cpp',
'nsSyncStreamListener.cpp',
'nsTemporaryFileInputStream.cpp',
'nsTransportUtils.cpp',
'nsUDPSocket.cpp',
'nsUnicharStreamLoader.cpp',
'nsURLHelper.cpp',
'nsURLParsers.cpp',
- 'OfflineObserver.cpp',
'PollableEvent.cpp',
'Predictor.cpp',
'ProxyAutoConfig.cpp',
'RedirectChannelRegistrar.cpp',
'RequestContextService.cpp',
'SimpleBuffer.cpp',
'StreamingProtocolService.cpp',
'ThrottleQueue.cpp',
--- a/netwerk/base/nsIIOService.idl
+++ b/netwerk/base/nsIIOService.idl
@@ -145,40 +145,16 @@ interface nsIIOService : nsISupports
attribute boolean offline;
/**
* Returns false if there are no interfaces for a network request
*/
readonly attribute boolean connectivity;
/**
- * Set whether network appears to be offline for network connections from
- * a given appID.
- *
- * Calling this function may fire the "network:app-offline-status-changed"
- * notification, which is also sent to child processes containing this appId.
- * 'state' must one of nsIAppOfflineInfo::{ONLINE|OFFLINE|WIFI_ONLY}.
- */
- void setAppOffline(in uint32_t appId, in long state);
-
- /**
- * 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
* ensuring reasonable, default protection.
*
@@ -197,28 +173,16 @@ interface nsIIOService : nsISupports
* @param aSpec the URL string to parse
* @return URL scheme
*
* @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
*/
ACString extractScheme(in AUTF8String urlString);
};
-[scriptable, uuid(4ac296a0-ca1b-44f4-8787-117a88cb70fb)]
-interface nsIAppOfflineInfo : nsISupports
-{
- readonly attribute unsigned long appId;
-
- const long ONLINE = 1;
- const long OFFLINE = 2;
- const long WIFI_ONLY = 3;
-
- readonly attribute long mode;
-};
-
%{C++
/**
* We send notifications through nsIObserverService with topic
* NS_IOSERVICE_GOING_OFFLINE_TOPIC and data NS_IOSERVICE_OFFLINE
* when 'offline' has changed from false to true, and we are about
* to shut down network services such as DNS. When those
* services have been shut down, we send a notification with
* topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
@@ -229,21 +193,16 @@ interface nsIAppOfflineInfo : nsISupport
* with topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
* NS_IOSERVICE_ONLINE.
*/
#define NS_IOSERVICE_GOING_OFFLINE_TOPIC "network:offline-about-to-go-offline"
#define NS_IOSERVICE_OFFLINE_STATUS_TOPIC "network:offline-status-changed"
#define NS_IOSERVICE_OFFLINE "offline"
#define NS_IOSERVICE_ONLINE "online"
-/**
- * When network:app-offline-status-changed is fired,
- * the 'Subject' argument is a nsIOfflineAppInfo.
- */
-#define NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC "network:app-offline-status-changed"
%}
[builtinclass, uuid(6633c0bf-d97a-428f-8ece-cb6a655fb95a)]
interface nsIIOServiceInternal : nsISupports
{
/**
* This is an internal method that should only be called from ContentChild
* in order to pass the connectivity state from the chrome process to the
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -167,34 +167,31 @@ static const char kProfileChangeNetResto
static const char kProfileDoChange[] = "profile-do-change";
// Necko buffer defaults
uint32_t nsIOService::gDefaultSegmentSize = 4096;
uint32_t nsIOService::gDefaultSegmentCount = 24;
bool nsIOService::sTelemetryEnabled = false;
-NS_IMPL_ISUPPORTS(nsAppOfflineInfo, nsIAppOfflineInfo)
-
////////////////////////////////////////////////////////////////////////////////
nsIOService::nsIOService()
: mOffline(true)
, mOfflineForProfileChange(false)
, mManageLinkStatus(false)
, mConnectivity(true)
, mOfflineMirrorsConnectivity(true)
, mSettingOffline(false)
, mSetOfflineValue(false)
, mShutdown(false)
, mHttpHandlerAlreadyShutingDown(false)
, mNetworkLinkServiceInitialized(false)
, mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY)
, mNetworkNotifyChanged(true)
- , mPreviousWifiState(-1)
, mLastOfflineStateChange(PR_IntervalNow())
, mLastConnectivityChange(PR_IntervalNow())
, mLastNetworkLinkChange(PR_IntervalNow())
, mNetTearingDownStarted(0)
{
}
nsresult
@@ -1342,55 +1339,16 @@ nsIOService::ParsePortList(nsIPrefBranch
void
nsIOService::GetPrefBranch(nsIPrefBranch **result)
{
*result = nullptr;
CallGetService(NS_PREFSERVICE_CONTRACTID, result);
}
-// This returns true if wifi-only apps should have connectivity.
-// Always returns false in the child process (should not depend on this method)
-static bool
-IsWifiActive()
-{
- // We don't need to do this check inside the child process
- if (IsNeckoChild()) {
- return false;
- }
-#ifdef MOZ_WIDGET_GONK
- // On B2G we query the network manager for the active interface
- nsCOMPtr<nsINetworkManager> networkManager =
- do_GetService("@mozilla.org/network/manager;1");
- if (!networkManager) {
- return false;
- }
- nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
- networkManager->GetActiveNetworkInfo(getter_AddRefs(activeNetworkInfo));
- if (!activeNetworkInfo) {
- return false;
- }
- int32_t type;
- if (NS_FAILED(activeNetworkInfo->GetType(&type))) {
- return false;
- }
- switch (type) {
- case nsINetworkInfo::NETWORK_TYPE_WIFI:
- case nsINetworkInfo::NETWORK_TYPE_WIFI_P2P:
- return true;
- default:
- return false;
- }
-#else
- // On anything else than B2G we return true so than wifi-only
- // apps don't think they are offline.
- return true;
-#endif
-}
-
class nsWakeupNotifier : public Runnable
{
public:
explicit nsWakeupNotifier(nsIIOServiceInternal *ioService)
:mIOService(ioService)
{ }
NS_IMETHOD Run() override
@@ -1873,173 +1831,10 @@ nsIOService::SpeculativeConnect(nsIURI *
NS_IMETHODIMP
nsIOService::SpeculativeAnonymousConnect(nsIURI *aURI,
nsIInterfaceRequestor *aCallbacks)
{
return SpeculativeConnectInternal(aURI, aCallbacks, true);
}
-void
-nsIOService::NotifyAppOfflineStatus(uint32_t appId, int32_t state)
-{
- MOZ_RELEASE_ASSERT(NS_IsMainThread(),
- "Should be called on the main thread");
-
- nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
- MOZ_ASSERT(observerService, "The observer service should not be null");
-
- if (observerService) {
- RefPtr<nsAppOfflineInfo> info = new nsAppOfflineInfo(appId, state);
- observerService->NotifyObservers(
- info,
- NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC,
- u"all data in nsIAppOfflineInfo subject argument");
- }
-}
-
-namespace {
-
-class SetAppOfflineMainThread : public Runnable
-{
-public:
- SetAppOfflineMainThread(uint32_t aAppId, int32_t aState)
- : mAppId(aAppId)
- , mState(aState)
- {
- }
-
- NS_IMETHOD Run() override
- {
- MOZ_ASSERT(NS_IsMainThread());
- gIOService->SetAppOfflineInternal(mAppId, mState);
- return NS_OK;
- }
-private:
- uint32_t mAppId;
- int32_t mState;
-};
-
-} // namespace
-
-NS_IMETHODIMP
-nsIOService::SetAppOffline(uint32_t aAppId, int32_t aState)
-{
- NS_ENSURE_TRUE(!IsNeckoChild(),
- NS_ERROR_FAILURE);
- NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::NO_APP_ID,
- NS_ERROR_INVALID_ARG);
- NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
- NS_ERROR_INVALID_ARG);
-
- if (!NS_IsMainThread()) {
- NS_DispatchToMainThread(new SetAppOfflineMainThread(aAppId, aState));
- return NS_OK;
- }
-
- SetAppOfflineInternal(aAppId, aState);
-
- return NS_OK;
-}
-
-// This method may be called in both the parent and the child process
-// In parent it only gets called in from nsIOService::SetAppOffline
-// and SetAppOfflineMainThread::Run
-// In the child, it may get called from NeckoChild::RecvAppOfflineStatus
-// and TabChild::RecvAppOfflineStatus.
-// Note that in the child process, apps should never be in a WIFI_ONLY
-// because wifi status is not available on the child
-void
-nsIOService::SetAppOfflineInternal(uint32_t aAppId, int32_t aState)
-{
- MOZ_ASSERT(NS_IsMainThread());
- NS_ENSURE_TRUE_VOID(NS_IsMainThread());
-
- int32_t state = nsIAppOfflineInfo::ONLINE;
- mAppsOfflineStatus.Get(aAppId, &state);
- if (state == aState) {
- // The app is already in this state. Nothing needs to be done.
- return;
- }
-
- // wifiActive will always be false in the child process
- // but it will be true in the parent process on Desktop Firefox as it does
- // not have wifi-detection capabilities
- bool wifiActive = IsWifiActive();
- bool offline = (state == nsIAppOfflineInfo::OFFLINE) ||
- (state == nsIAppOfflineInfo::WIFI_ONLY && !wifiActive);
-
- switch (aState) {
- case nsIAppOfflineInfo::OFFLINE:
- mAppsOfflineStatus.Put(aAppId, nsIAppOfflineInfo::OFFLINE);
- if (!offline) {
- NotifyAppOfflineStatus(aAppId, nsIAppOfflineInfo::OFFLINE);
- }
- break;
- case nsIAppOfflineInfo::WIFI_ONLY:
- MOZ_RELEASE_ASSERT(!IsNeckoChild());
- mAppsOfflineStatus.Put(aAppId, nsIAppOfflineInfo::WIFI_ONLY);
- if (offline && wifiActive) {
- NotifyAppOfflineStatus(aAppId, nsIAppOfflineInfo::ONLINE);
- } else if (!offline && !wifiActive) {
- NotifyAppOfflineStatus(aAppId, nsIAppOfflineInfo::OFFLINE);
- }
- break;
- case nsIAppOfflineInfo::ONLINE:
- mAppsOfflineStatus.Remove(aAppId);
- if (offline) {
- NotifyAppOfflineStatus(aAppId, nsIAppOfflineInfo::ONLINE);
- }
- 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;
- }
-
- int32_t state;
- if (mAppsOfflineStatus.Get(aAppId, &state)) {
- switch (state) {
- case nsIAppOfflineInfo::OFFLINE:
- *aResult = true;
- break;
- case nsIAppOfflineInfo::WIFI_ONLY:
- MOZ_RELEASE_ASSERT(!IsNeckoChild());
- *aResult = !IsWifiActive();
- break;
- default:
- // The app is online by default
- break;
- }
- }
-
- return NS_OK;
-}
-
} // namespace net
} // namespace mozilla
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -90,19 +90,16 @@ public:
// is in process of tearing down. Moving nsHttpConnectionMgr::Shutdown to nsIOService
// caused problems (bug 1242755) so we doing it in this way.
// As soon as nsIOService gets notification that it is shutdown it is going to
// reset mHttpHandlerAlreadyShutingDown.
void SetHttpHandlerAlreadyShutingDown();
bool IsLinkUp();
- // Should only be called from NeckoChild. Use SetAppOffline instead.
- void SetAppOfflineInternal(uint32_t appId, int32_t status);
-
// Used to trigger a recheck of the captive portal status
nsresult RecheckCaptivePortal();
private:
// These shouldn't be called directly:
// - construct using GetInstance
// - destroy using Release
nsIOService();
~nsIOService();
@@ -127,20 +124,16 @@ private:
nsresult InitializeSocketTransportService();
nsresult InitializeNetworkLinkService();
// consolidated helper function
void LookupProxyInfo(nsIURI *aURI, nsIURI *aProxyURI, uint32_t aProxyFlags,
nsCString *aScheme, nsIProxyInfo **outPI);
- // notify content processes of offline status
- // 'status' must be a nsIAppOfflineInfo mode constant.
- void NotifyAppOfflineStatus(uint32_t appId, int32_t status);
-
nsresult NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
nsIURI* aProxyURI,
uint32_t aProxyFlags,
nsILoadInfo* aLoadInfo,
nsIChannel** result);
nsresult SpeculativeConnectInternal(nsIURI *aURI,
nsIInterfaceRequestor *aCallbacks,
@@ -174,20 +167,16 @@ private:
nsWeakPtr mWeakHandler[NS_N(gScheme)];
// cached categories
nsCategoryCache<nsIChannelEventSink> mChannelEventSinks;
nsTArray<int32_t> mRestrictedPortList;
bool mNetworkNotifyChanged;
- int32_t mPreviousWifiState;
- // Hashtable of (appId, nsIAppOffineInfo::mode) pairs
- // that is used especially in IsAppOffline
- nsDataHashtable<nsUint32HashKey, int32_t> mAppsOfflineStatus;
static bool sTelemetryEnabled;
// These timestamps are needed for collecting telemetry on PR_Connect,
// PR_ConnectContinue and PR_Close blocking time. If we spend very long
// time in any of these functions we want to know if and what network
// change has happened shortly before.
mozilla::Atomic<PRIntervalTime> mLastOfflineStateChange;
@@ -198,49 +187,16 @@ private:
mozilla::Atomic<PRIntervalTime> mNetTearingDownStarted;
public:
// Used for all default buffer sizes that necko allocates.
static uint32_t gDefaultSegmentSize;
static uint32_t gDefaultSegmentCount;
};
/**
- * This class is passed as the subject to a NotifyObservers call for the
- * "network:app-offline-status-changed" topic.
- * Observers will use the appId and mode to get the offline status of an app.
- */
-class nsAppOfflineInfo : public nsIAppOfflineInfo
-{
- NS_DECL_THREADSAFE_ISUPPORTS
-public:
- nsAppOfflineInfo(uint32_t aAppId, int32_t aMode)
- : mAppId(aAppId), mMode(aMode)
- {
- }
-
- NS_IMETHOD GetMode(int32_t *aMode) override
- {
- *aMode = mMode;
- return NS_OK;
- }
-
- NS_IMETHOD GetAppId(uint32_t *aAppId) override
- {
- *aAppId = mAppId;
- return NS_OK;
- }
-
-private:
- virtual ~nsAppOfflineInfo() {}
-
- uint32_t mAppId;
- int32_t mMode;
-};
-
-/**
* Reference to the IO service singleton. May be null.
*/
extern nsIOService* gIOService;
} // namespace net
} // namespace mozilla
#endif // nsIOService_h__
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -1485,39 +1485,16 @@ NS_NewNotificationCallbacksAggregation(n
nsresult
NS_NewNotificationCallbacksAggregation(nsIInterfaceRequestor *callbacks,
nsILoadGroup *loadGroup,
nsIInterfaceRequestor **result)
{
return NS_NewNotificationCallbacksAggregation(callbacks, loadGroup, nullptr, result);
}
-bool
-NS_IsAppOffline(uint32_t appId)
-{
- bool appOffline = false;
- nsCOMPtr<nsIIOService> io(
- do_GetService("@mozilla.org/network/io-service;1"));
- if (io) {
- io->IsAppOffline(appId, &appOffline);
- }
- return appOffline;
-}
-
-bool
-NS_IsAppOffline(nsIPrincipal *principal)
-{
- if (!principal) {
- return NS_IsOffline();
- }
- uint32_t appId = principal->GetAppId();
-
- return NS_IsAppOffline(appId);
-}
-
nsresult
NS_DoImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result)
{
NS_PRECONDITION(nestedURI, "Must have a nested URI!");
NS_PRECONDITION(!*result, "Must have null *result");
nsCOMPtr<nsIURI> inner;
nsresult rv = nestedURI->GetInnerURI(getter_AddRefs(inner));
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -431,28 +431,16 @@ NeckoChild::RecvPredOnPredictDNS(const U
do_GetService("@mozilla.org/network/predictor;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
predictor->OnPredictDNS(uri);
return true;
}
bool
-NeckoChild::RecvAppOfflineStatus(const uint32_t& aId, const bool& aOffline)
-{
- // Instantiate the service to make sure gIOService is initialized
- nsCOMPtr<nsIIOService> ioService = do_GetIOService();
- if (gIOService) {
- gIOService->SetAppOfflineInternal(aId, aOffline ?
- nsIAppOfflineInfo::OFFLINE : nsIAppOfflineInfo::ONLINE);
- }
- return true;
-}
-
-bool
NeckoChild::RecvSpeculativeConnectRequest()
{
nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
if (obsService) {
obsService->NotifyObservers(nullptr, "speculative-connect-request",
nullptr);
}
return true;
--- a/netwerk/ipc/NeckoChild.h
+++ b/netwerk/ipc/NeckoChild.h
@@ -82,17 +82,16 @@ protected:
virtual PTransportProviderChild*
AllocPTransportProviderChild() override;
virtual bool
DeallocPTransportProviderChild(PTransportProviderChild* aActor) override;
virtual bool RecvAsyncAuthPromptForNestedFrame(const TabId& aNestedFrameId,
const nsCString& aUri,
const nsString& aRealm,
const uint64_t& aCallbackId) override;
- virtual bool RecvAppOfflineStatus(const uint32_t& aId, const bool& aOffline) override;
virtual PWebSocketEventListenerChild*
AllocPWebSocketEventListenerChild(const uint64_t& aInnerWindowID) override;
virtual bool DeallocPWebSocketEventListenerChild(PWebSocketEventListenerChild*) override;
/* Predictor Messsages */
virtual bool RecvPredOnPredictPrefetch(const URIParams& aURI,
const uint32_t& aHttpStatus) override;
virtual bool RecvPredOnPredictPreconnect(const URIParams& aURI) override;
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -38,20 +38,18 @@
#include "nsHTMLDNSPrefetch.h"
#include "nsIAppsService.h"
#include "nsEscape.h"
#include "RemoteOpenFileParent.h"
#include "SerializedLoadContext.h"
#include "nsAuthInformationHolder.h"
#include "nsIAuthPromptCallback.h"
#include "nsPrincipal.h"
-#include "nsIOService.h"
#include "nsINetworkPredictor.h"
#include "nsINetworkPredictorVerifier.h"
-#include "mozilla/net/OfflineObserver.h"
#include "nsISpeculativeConnect.h"
using mozilla::DocShellOriginAttributes;
using mozilla::NeckoOriginAttributes;
using mozilla::dom::ContentParent;
using mozilla::dom::TabContext;
using mozilla::dom::TabParent;
using mozilla::net::PTCPSocketParent;
@@ -69,33 +67,28 @@ namespace net {
NeckoParent::NeckoParent()
{
// Init HTTP protocol handler now since we need atomTable up and running very
// early (IPDL argument handling for PHttpChannel constructor needs it) so
// normal init (during 1st Http channel request) isn't early enough.
nsCOMPtr<nsIProtocolHandler> proto =
do_GetService("@mozilla.org/network/protocol;1?name=http");
- mObserver = new OfflineObserver(this);
-
// only register once--we will have multiple NeckoParents if there are
// multiple child processes.
static bool registeredBool = false;
if (!registeredBool) {
Preferences::AddBoolVarCache(&NeckoCommonInternal::gSecurityDisabled,
"network.disable.ipc.security");
registeredBool = true;
}
}
NeckoParent::~NeckoParent()
{
- if (mObserver) {
- mObserver->RemoveObserver();
- }
}
static PBOverrideStatus
PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized)
{
if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) {
return (aSerialized.mOriginAttributes.mPrivateBrowsingId > 0) ?
kPBOverride_Private :
@@ -927,67 +920,16 @@ NeckoParent::RecvPredReset()
nsCOMPtr<nsINetworkPredictor> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
predictor->Reset();
return true;
}
-nsresult
-NeckoParent::OfflineNotification(nsISupports *aSubject)
-{
- nsCOMPtr<nsIAppOfflineInfo> info(do_QueryInterface(aSubject));
- if (!info) {
- return NS_OK;
- }
-
- uint32_t targetAppId = NECKO_UNKNOWN_APP_ID;
- info->GetAppId(&targetAppId);
-
- nsTArray<TabContext> contextArray =
- static_cast<ContentParent*>(Manager())->GetManagedTabContext();
- for (uint32_t i = 0; i < contextArray.Length(); ++i) {
- TabContext tabContext = contextArray[i];
- uint32_t appId = tabContext.OwnOrContainingAppId();
-
- if (appId == targetAppId) {
- if (gIOService) {
- bool offline = false;
- nsresult rv = gIOService->IsAppOffline(appId, &offline);
- if (NS_FAILED(rv)) {
- printf_stderr("Unexpected - NeckoParent: "
- "appId not found by isAppOffline(): %u\n", appId);
- break;
- }
- if (!SendAppOfflineStatus(appId, offline)) {
- printf_stderr("NeckoParent: "
- "SendAppOfflineStatus failed for appId: %u\n", appId);
- }
- // Once we found the targetAppId, we don't need to continue
- break;
- }
- }
-
- }
-
- // XPCShells don't have any TabParents
- // Just send the ipdl message to the child process.
- if (!UsingNeckoIPCSecurity()) {
- bool offline = false;
- gIOService->IsAppOffline(targetAppId, &offline);
- if (!SendAppOfflineStatus(targetAppId, offline)) {
- printf_stderr("NeckoParent: "
- "SendAppOfflineStatus failed for targetAppId: %u\n", targetAppId);
- }
- }
-
- return NS_OK;
-}
-
bool
NeckoParent::RecvRemoveRequestContext(const nsCString& rcid)
{
nsCOMPtr<nsIRequestContextService> rcsvc =
do_GetService("@mozilla.org/network/request-context-service;1");
if (!rcsvc) {
return true;
}
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -3,17 +3,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/BasePrincipal.h"
#include "mozilla/net/PNeckoParent.h"
#include "mozilla/net/NeckoCommon.h"
-#include "mozilla/net/OfflineObserver.h"
#include "nsIAuthPrompt2.h"
#include "nsINetworkPredictor.h"
#include "nsNetUtil.h"
#ifndef mozilla_net_NeckoParent_h
#define mozilla_net_NeckoParent_h
namespace mozilla {
@@ -24,17 +23,16 @@ enum PBOverrideStatus {
kPBOverride_Unset = 0,
kPBOverride_Private,
kPBOverride_NotPrivate
};
// Header file contents
class NeckoParent
: public PNeckoParent
- , public DisconnectableParent
{
public:
NeckoParent();
virtual ~NeckoParent();
MOZ_MUST_USE
static const char *
GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
@@ -51,18 +49,16 @@ public:
MOZ_MUST_USE
static const char*
CreateChannelLoadContext(const PBrowserOrId& aBrowser,
PContentParent* aContent,
const SerializedLoadContext& aSerialized,
nsCOMPtr<nsILoadContext> &aResult);
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
- virtual nsresult OfflineNotification(nsISupports *) override;
- virtual uint32_t GetAppId() override { return NECKO_UNKNOWN_APP_ID; }
virtual PCookieServiceParent* AllocPCookieServiceParent() override;
virtual bool
RecvPCookieServiceConstructor(PCookieServiceParent* aActor) override
{
return PNeckoParent::RecvPCookieServiceConstructor(aActor);
}
/*
@@ -231,17 +227,14 @@ protected:
virtual bool RecvPredLearn(const ipc::URIParams& aTargetURI,
const ipc::OptionalURIParams& aSourceURI,
const PredictorPredictReason& aReason,
const IPC::SerializedLoadContext& aLoadContext) override;
virtual bool RecvPredReset() override;
virtual bool RecvRemoveRequestContext(const nsCString& rcid) override;
-
-private:
- RefPtr<OfflineObserver> mObserver;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_NeckoParent_h
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -123,18 +123,16 @@ parent:
child:
/*
* Bring up the http auth prompt for a nested remote mozbrowser.
* NestedFrameId is the id corresponding to the PBrowser. It is the same id
* that was passed to the PBrowserOrId param in to the PHttpChannel constructor
*/
async AsyncAuthPromptForNestedFrame(TabId nestedFrameId, nsCString uri,
nsString realm, uint64_t callbackId);
- // Notifies child that a given app is now offline (or online)
- async AppOfflineStatus(uint32_t appId, bool offline);
/* Predictor Methods */
async PredOnPredictPrefetch(URIParams uri, uint32_t httpStatus);
async PredOnPredictPreconnect(URIParams uri);
async PredOnPredictDNS(URIParams uri);
async SpeculativeConnectRequest();
--- a/netwerk/protocol/ftp/FTPChannelParent.cpp
+++ b/netwerk/protocol/ftp/FTPChannelParent.cpp
@@ -20,17 +20,16 @@
#include "nsIHttpChannelInternal.h"
#include "nsIForcePendingChannel.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/Unused.h"
#include "SerializedLoadContext.h"
#include "nsIContentPolicy.h"
#include "mozilla/ipc/BackgroundUtils.h"
-#include "nsIOService.h"
#include "mozilla/LoadInfo.h"
using namespace mozilla::dom;
using namespace mozilla::ipc;
#undef LOG
#define LOG(args) MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
@@ -52,27 +51,22 @@ FTPChannelParent::FTPChannelParent(const
nsIProtocolHandler* handler;
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &handler);
MOZ_ASSERT(handler, "no ftp handler");
if (aIframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
mTabParent = static_cast<dom::TabParent*>(aIframeEmbedding.get_PBrowserParent());
}
- mObserver = new OfflineObserver(this);
-
mEventQ = new ChannelEventQueue(static_cast<nsIParentChannel*>(this));
}
FTPChannelParent::~FTPChannelParent()
{
gFtpHandler->Release();
- if (mObserver) {
- mObserver->RemoveObserver();
- }
}
void
FTPChannelParent::ActorDestroy(ActorDestroyReason why)
{
// We may still have refcount>0 if the channel hasn't called OnStopRequest
// yet, but we must not send any more msgs to child.
mIPCClosed = true;
@@ -150,27 +144,16 @@ FTPChannelParent::DoAsyncOpen(const URIP
}
NeckoOriginAttributes attrs;
rv = loadInfo->GetOriginAttributes(&attrs);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
- bool app_offline = false;
- uint32_t appId = attrs.mAppId;
- if (appId != NECKO_UNKNOWN_APP_ID &&
- appId != NECKO_NO_APP_ID) {
- gIOService->IsAppOffline(appId, &app_offline);
- LOG(("FTP app id %u is offline %d\n", appId, app_offline));
- }
-
- if (app_offline)
- return SendFailedAsyncOpen(NS_ERROR_OFFLINE);
-
nsCOMPtr<nsIChannel> chan;
rv = NS_NewChannelInternal(getter_AddRefs(chan), uri, loadInfo,
nullptr, nullptr,
nsIRequest::LOAD_NORMAL, ios);
if (NS_FAILED(rv))
return SendFailedAsyncOpen(rv);
@@ -871,38 +854,16 @@ FTPChannelParent::NotifyDiversionFailed(
mDivertToListener = nullptr;
mChannel = nullptr;
if (!mIPCClosed) {
Unused << SendDeleteSelf();
}
}
-void
-FTPChannelParent::OfflineDisconnect()
-{
- if (mChannel) {
- mChannel->Cancel(NS_ERROR_OFFLINE);
- }
- mStatus = NS_ERROR_OFFLINE;
-}
-
-uint32_t
-FTPChannelParent::GetAppId()
-{
- uint32_t appId = NECKO_UNKNOWN_APP_ID;
- if (mChannel) {
- NeckoOriginAttributes attrs;
- if (NS_GetOriginAttributes(mChannel, attrs)) {
- appId = attrs.mAppId;
- }
- }
- return appId;
-}
-
//-----------------------------------------------------------------------------
// FTPChannelParent::nsIChannelEventSink
//-----------------------------------------------------------------------------
NS_IMETHODIMP
FTPChannelParent::AsyncOnChannelRedirect(
nsIChannel *oldChannel,
nsIChannel *newChannel,
--- a/netwerk/protocol/ftp/FTPChannelParent.h
+++ b/netwerk/protocol/ftp/FTPChannelParent.h
@@ -8,17 +8,16 @@
#ifndef mozilla_net_FTPChannelParent_h
#define mozilla_net_FTPChannelParent_h
#include "ADivertableParentChannel.h"
#include "mozilla/net/PFTPChannelParent.h"
#include "mozilla/net/NeckoParent.h"
#include "nsIParentChannel.h"
#include "nsIInterfaceRequestor.h"
-#include "OfflineObserver.h"
#include "nsIChannelEventSink.h"
#include "nsIFTPChannelParentInternal.h"
class nsILoadContext;
namespace mozilla {
namespace dom {
@@ -29,17 +28,16 @@ class PBrowserOrId;
namespace net {
class ChannelEventQueue;
class FTPChannelParent final : public PFTPChannelParent
, public nsIParentChannel
, public nsIInterfaceRequestor
, public ADivertableParentChannel
, public nsIChannelEventSink
- , public DisconnectableParent
, public nsIFTPChannelParentInternal
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIPARENTCHANNEL
NS_DECL_NSIINTERFACEREQUESTOR
@@ -105,19 +103,16 @@ protected:
virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) override;
virtual bool RecvDivertComplete() override;
nsresult SuspendChannel();
nsresult ResumeChannel();
virtual void ActorDestroy(ActorDestroyReason why) override;
- void OfflineDisconnect() override;
- uint32_t GetAppId() override;
-
// if configured to use HTTP proxy for FTP, this can an an HTTP channel.
nsCOMPtr<nsIChannel> mChannel;
bool mIPCClosed;
nsCOMPtr<nsILoadContext> mLoadContext;
PBOverrideStatus mPBOverride;
@@ -132,17 +127,16 @@ protected:
// received from the child channel.
bool mDivertingFromChild;
// Set if OnStart|StopRequest was called during a diversion from the child.
bool mDivertedOnStartRequest;
// Set if we successfully suspended the nsHttpChannel for diversion. Unset
// when we call ResumeForDiversion.
bool mSuspendedForDiversion;
- RefPtr<OfflineObserver> mObserver;
RefPtr<mozilla::dom::TabParent> mTabParent;
RefPtr<ChannelEventQueue> mEventQ;
nsCString mErrorMsg;
bool mUseUTF8;
};
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -24,17 +24,16 @@
#include "nsIApplicationCacheService.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "SerializedLoadContext.h"
#include "nsIAuthInformation.h"
#include "nsIAuthPromptCallback.h"
#include "nsIContentPolicy.h"
#include "mozilla/ipc/BackgroundUtils.h"
-#include "nsIOService.h"
#include "nsICachingChannel.h"
#include "mozilla/LoadInfo.h"
#include "nsQueryObject.h"
#include "mozilla/BasePrincipal.h"
#include "nsCORSListenerProxy.h"
#include "nsIPrompt.h"
#include "nsIWindowWatcher.h"
#include "nsIDocument.h"
@@ -78,27 +77,22 @@ HttpChannelParent::HttpChannelParent(con
mHttpHandler = gHttpHandler;
if (iframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
mTabParent = static_cast<dom::TabParent*>(iframeEmbedding.get_PBrowserParent());
} else {
mNestedFrameId = iframeEmbedding.get_TabId();
}
- mObserver = new OfflineObserver(this);
-
mEventQ = new ChannelEventQueue(static_cast<nsIParentRedirectingChannel*>(this));
}
HttpChannelParent::~HttpChannelParent()
{
LOG(("Destroying HttpChannelParent [this=%p]\n", this));
- if (mObserver) {
- mObserver->RemoveObserver();
- }
}
void
HttpChannelParent::ActorDestroy(ActorDestroyReason why)
{
// We may still have refcount>0 if nsHttpChannel hasn't called OnStopRequest
// yet, but child process has crashed. We must not try to send any more msgs
// to child, or IPDL will kill chrome process, too.
@@ -298,33 +292,19 @@ HttpChannelParent::DoAsyncOpen( const U
}
NeckoOriginAttributes attrs;
rv = loadInfo->GetOriginAttributes(&attrs);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
- bool appOffline = false;
- uint32_t appId = attrs.mAppId;
- if (appId != NECKO_UNKNOWN_APP_ID &&
- appId != NECKO_NO_APP_ID) {
- gIOService->IsAppOffline(appId, &appOffline);
- }
-
- uint32_t loadFlags = aLoadFlags;
- if (appOffline) {
- loadFlags |= nsICachingChannel::LOAD_ONLY_FROM_CACHE;
- loadFlags |= nsIRequest::LOAD_FROM_CACHE;
- loadFlags |= nsICachingChannel::LOAD_NO_NETWORK_IO;
- }
-
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo,
- nullptr, nullptr, loadFlags, ios);
+ nullptr, nullptr, aLoadFlags, ios);
if (NS_FAILED(rv))
return SendFailedAsyncOpen(rv);
mChannel = static_cast<nsHttpChannel *>(channel.get());
// Set the channelId allocated in child to the parent instance
mChannel->SetChannelId(aChannelId);
@@ -343,18 +323,18 @@ HttpChannelParent::DoAsyncOpen( const U
if (docUri)
mChannel->SetDocumentURI(docUri);
if (referrerUri)
mChannel->SetReferrerWithPolicyInternal(referrerUri, aReferrerPolicy);
if (apiRedirectToUri)
mChannel->RedirectTo(apiRedirectToUri);
if (topWindowUri)
mChannel->SetTopWindowURI(topWindowUri);
- if (loadFlags != nsIRequest::LOAD_NORMAL)
- mChannel->SetLoadFlags(loadFlags);
+ if (aLoadFlags != nsIRequest::LOAD_NORMAL)
+ mChannel->SetLoadFlags(aLoadFlags);
for (uint32_t i = 0; i < requestHeaders.Length(); i++) {
if (requestHeaders[i].mEmpty) {
mChannel->SetEmptyRequestHeader(requestHeaders[i].mHeader);
} else {
mChannel->SetRequestHeader(requestHeaders[i].mHeader,
requestHeaders[i].mValue,
requestHeaders[i].mMerge);
@@ -521,32 +501,16 @@ HttpChannelParent::ConnectChannel(const
if (mPBOverride != kPBOverride_Unset) {
// redirected-to channel may not support PB
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryObject(mChannel);
if (pbChannel) {
pbChannel->SetPrivate(mPBOverride == kPBOverride_Private ? true : false);
}
}
- bool appOffline = false;
- uint32_t appId = GetAppId();
- if (appId != NECKO_UNKNOWN_APP_ID &&
- appId != NECKO_NO_APP_ID) {
- gIOService->IsAppOffline(appId, &appOffline);
- }
-
- if (appOffline) {
- uint32_t loadFlags;
- mChannel->GetLoadFlags(&loadFlags);
- loadFlags |= nsICachingChannel::LOAD_ONLY_FROM_CACHE;
- loadFlags |= nsIRequest::LOAD_FROM_CACHE;
- loadFlags |= nsICachingChannel::LOAD_NO_NETWORK_IO;
- mChannel->SetLoadFlags(loadFlags);
- }
-
return true;
}
bool
HttpChannelParent::RecvSetPriority(const uint16_t& priority)
{
LOG(("HttpChannelParent::RecvSetPriority [this=%p, priority=%u]\n",
this, priority));
@@ -1615,38 +1579,16 @@ HttpChannelParent::OpenAlternativeOutput
// We need to make sure the child does not call SendDocumentChannelCleanup()
// before opening the altOutputStream, because that clears mCacheEntry.
if (!mCacheEntry) {
return NS_ERROR_NOT_AVAILABLE;
}
return mCacheEntry->OpenAlternativeOutputStream(type, _retval);
}
-void
-HttpChannelParent::OfflineDisconnect()
-{
- if (mChannel) {
- mChannel->Cancel(NS_ERROR_OFFLINE);
- }
- mStatus = NS_ERROR_OFFLINE;
-}
-
-uint32_t
-HttpChannelParent::GetAppId()
-{
- uint32_t appId = NECKO_UNKNOWN_APP_ID;
- if (mChannel) {
- NeckoOriginAttributes attrs;
- if (NS_GetOriginAttributes(mChannel, attrs)) {
- appId = attrs.mAppId;
- }
- }
- return appId;
-}
-
NS_IMETHODIMP
HttpChannelParent::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
void** aResult)
{
nsCOMPtr<nsIAuthPrompt2> prompt =
new NeckoParent::NestedFrameAuthPrompt(Manager(), mNestedFrameId);
prompt.forget(aResult);
return NS_OK;
--- a/netwerk/protocol/http/HttpChannelParent.h
+++ b/netwerk/protocol/http/HttpChannelParent.h
@@ -8,17 +8,16 @@
#ifndef mozilla_net_HttpChannelParent_h
#define mozilla_net_HttpChannelParent_h
#include "ADivertableParentChannel.h"
#include "nsHttp.h"
#include "mozilla/net/PHttpChannelParent.h"
#include "mozilla/net/NeckoCommon.h"
#include "mozilla/net/NeckoParent.h"
-#include "OfflineObserver.h"
#include "nsIObserver.h"
#include "nsIParentRedirectingChannel.h"
#include "nsIProgressEventSink.h"
#include "nsHttpChannel.h"
#include "nsIAuthPromptProvider.h"
#include "mozilla/dom/ipc/IdType.h"
#include "nsIDeprecationWarner.h"
@@ -47,17 +46,16 @@ class ChannelEventQueue;
class HttpChannelParent final : public nsIInterfaceRequestor
, public PHttpChannelParent
, public nsIParentRedirectingChannel
, public nsIProgressEventSink
, public ADivertableParentChannel
, public nsIAuthPromptProvider
, public nsIDeprecationWarner
- , public DisconnectableParent
, public HttpChannelSecurityWarningReporter
{
virtual ~HttpChannelParent();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
@@ -175,19 +173,16 @@ protected:
nsresult ResumeForDiversion();
// Asynchronously calls NotifyDiversionFailed.
void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
friend class HttpChannelParentListener;
RefPtr<mozilla::dom::TabParent> mTabParent;
- void OfflineDisconnect() override;
- uint32_t GetAppId() override;
-
nsresult ReportSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) override;
// Calls SendDeleteSelf and sets mIPCClosed to true because we should not
// send any more messages after that. Bug 1274886
bool DoSendDeleteSelf();
private:
@@ -220,18 +215,16 @@ private:
nsresult mStoredStatus;
int64_t mStoredProgress;
int64_t mStoredProgressMax;
bool mSentRedirect1Begin : 1;
bool mSentRedirect1BeginFailed : 1;
bool mReceivedRedirect2Verify : 1;
- RefPtr<OfflineObserver> mObserver;
-
PBOverrideStatus mPBOverride;
nsCOMPtr<nsILoadContext> mLoadContext;
RefPtr<nsHttpHandler> mHttpHandler;
RefPtr<HttpChannelParentListener> mParentListener;
// The listener we are diverting to or will divert to if mPendingDiversion
// is set.
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -3469,26 +3469,18 @@ nsHttpChannel::OpenCacheEntry(bool isHtt
}
}
RefPtr<LoadContextInfo> info = GetLoadContextInfo(this);
if (!info) {
return NS_ERROR_FAILURE;
}
- uint32_t appId = info->OriginAttributesPtr()->mAppId;
- bool appOffline = false;
-
- if (appId != NECKO_NO_APP_ID) {
- gIOService->IsAppOffline(appId, &appOffline);
- LOG(("nsHttpChannel::OpenCacheEntry appId: %u, offline: %d\n", appId, appOffline));
- }
-
uint32_t cacheEntryOpenFlags;
- bool offline = gIOService->IsOffline() || appOffline;
+ bool offline = gIOService->IsOffline();
nsAutoCString cacheControlRequestHeader;
mRequestHead.GetHeader(nsHttp::Cache_Control, cacheControlRequestHeader);
CacheControlParser cacheControlRequest(cacheControlRequestHeader);
if (cacheControlRequest.NoStore() && !PossiblyIntercepted()) {
goto bypassCacheEntryOpen;
}
--- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp
@@ -6,17 +6,16 @@
#include "WebSocketLog.h"
#include "WebSocketChannelParent.h"
#include "nsIAuthPromptProvider.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "SerializedLoadContext.h"
-#include "nsIOService.h"
#include "mozilla/net/NeckoCommon.h"
#include "mozilla/net/WebSocketChannel.h"
using namespace mozilla::ipc;
namespace mozilla {
namespace net {
@@ -30,24 +29,20 @@ WebSocketChannelParent::WebSocketChannel
uint32_t aSerial)
: mAuthProvider(aAuthProvider)
, mLoadContext(aLoadContext)
, mIPCOpen(true)
, mSerial(aSerial)
{
// Websocket channels can't have a private browsing override
MOZ_ASSERT_IF(!aLoadContext, aOverrideStatus == kPBOverride_Unset);
- mObserver = new OfflineObserver(this);
}
WebSocketChannelParent::~WebSocketChannelParent()
{
- if (mObserver) {
- mObserver->RemoveObserver();
- }
}
//-----------------------------------------------------------------------------
// WebSocketChannelParent::PWebSocketChannelParent
//-----------------------------------------------------------------------------
bool
WebSocketChannelParent::RecvDeleteSelf()
{
@@ -71,46 +66,22 @@ WebSocketChannelParent::RecvAsyncOpen(co
const OptionalTransportProvider& aTransportProvider,
const nsCString& aNegotiatedExtensions)
{
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsILoadInfo> loadInfo;
- bool appOffline = false;
- uint32_t appId = NECKO_NO_APP_ID;
- NeckoOriginAttributes attrs;
rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) {
goto fail;
}
- if (loadInfo) {
- rv = loadInfo->GetOriginAttributes(&attrs);
- if (NS_FAILED(rv)) {
- goto fail;
- }
-
- appId = attrs.mAppId;
- } else {
- // If the WebSocket is a server-side socket, then
- // loadInfo will be null (since it's an incoming connection).
- // AppID is irrelevant in these circumstances.
- appId = NECKO_UNKNOWN_APP_ID;
- }
- if (appId != NECKO_UNKNOWN_APP_ID &&
- appId != NECKO_NO_APP_ID) {
- gIOService->IsAppOffline(appId, &appOffline);
- if (appOffline) {
- goto fail;
- }
- }
-
if (aSecure) {
mChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=wss", &rv);
} else {
mChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=ws", &rv);
}
if (NS_FAILED(rv))
@@ -326,38 +297,10 @@ WebSocketChannelParent::GetInterface(con
nsCOMPtr<nsILoadContext> copy = mLoadContext;
copy.forget(result);
return NS_OK;
}
return QueryInterface(iid, result);
}
-void
-WebSocketChannelParent::OfflineDisconnect()
-{
- if (mChannel) {
- mChannel->Close(nsIWebSocketChannel::CLOSE_GOING_AWAY,
- nsCString("App is offline"));
- }
-}
-
-uint32_t
-WebSocketChannelParent::GetAppId()
-{
- nsresult rv;
-
- uint32_t appId = NECKO_UNKNOWN_APP_ID;
- if (mChannel) {
- nsCOMPtr<nsILoadInfo> loadInfo;
- rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
-
- if (NS_SUCCEEDED(rv) && loadInfo) {
- NeckoOriginAttributes attrs;
- loadInfo->GetOriginAttributes(&attrs);
- appId = attrs.mAppId;
- }
- }
- return appId;
-}
-
} // namespace net
} // namespace mozilla
--- a/netwerk/protocol/websocket/WebSocketChannelParent.h
+++ b/netwerk/protocol/websocket/WebSocketChannelParent.h
@@ -10,26 +10,24 @@
#include "mozilla/net/PWebSocketParent.h"
#include "mozilla/net/NeckoParent.h"
#include "nsIInterfaceRequestor.h"
#include "nsIWebSocketListener.h"
#include "nsIWebSocketChannel.h"
#include "nsILoadContext.h"
#include "nsCOMPtr.h"
#include "nsString.h"
-#include "OfflineObserver.h"
class nsIAuthPromptProvider;
namespace mozilla {
namespace net {
class WebSocketChannelParent : public PWebSocketParent,
public nsIWebSocketListener,
- public DisconnectableParent,
public nsIInterfaceRequestor
{
~WebSocketChannelParent();
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIWEBSOCKETLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
@@ -55,20 +53,16 @@ class WebSocketChannelParent : public PW
bool RecvSendMsg(const nsCString& aMsg) override;
bool RecvSendBinaryMsg(const nsCString& aMsg) override;
bool RecvSendBinaryStream(const InputStreamParams& aStream,
const uint32_t& aLength) override;
bool RecvDeleteSelf() override;
void ActorDestroy(ActorDestroyReason why) override;
- void OfflineDisconnect() override;
- uint32_t GetAppId() override;
- RefPtr<OfflineObserver> mObserver;
-
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
nsCOMPtr<nsIWebSocketChannel> mChannel;
nsCOMPtr<nsILoadContext> mLoadContext;
bool mIPCOpen;
uint32_t mSerial;
};
deleted file mode 100644
--- a/netwerk/test/unit_ipc/child_app_offline.js
+++ /dev/null
@@ -1,49 +0,0 @@
-Cu.import("resource://gre/modules/NetUtil.jsm");
-
-function inChildProcess() {
- return Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime)
- .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-}
-
-function makeChan(url, appId, inIsolatedMozBrowser) {
- var chan = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
- .QueryInterface(Ci.nsIHttpChannel);
- chan.loadInfo.originAttributes = { appId: appId,
- inIsolatedMozBrowser: inIsolatedMozBrowser
- };
- return chan;
-}
-
-// Simple online load
-function run_test() {
- do_test_pending();
- var chan = makeChan("http://localhost:12345/first", 14, false);
- chan.asyncOpen2(new ChannelListener(checkResponse, "response0"));
-}
-
-// Should return cached result
-function test1() {
- do_test_pending();
- var chan = makeChan("http://localhost:12345/first", 14, false);
- chan.asyncOpen2(new ChannelListener(checkResponse, "response0"));
-}
-
-// This request should fail
-function test2() {
- do_test_pending();
- var chan = makeChan("http://localhost:12345/second", 14, false);
- chan.asyncOpen2(new ChannelListener(checkResponse, "", CL_EXPECT_FAILURE));
-}
-
-// This request should succeed
-function test3() {
- do_test_pending();
- var chan = makeChan("http://localhost:12345/second", 14, false);
- chan.asyncOpen2(new ChannelListener(checkResponse, "response3"));
-}
-
-function checkResponse(req, buffer, expected) {
- do_check_eq(buffer, expected);
- do_test_finished();
-}
deleted file mode 100644
--- a/netwerk/test/unit_ipc/test_app_offline_http.js
+++ /dev/null
@@ -1,74 +0,0 @@
-
-Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-var test_index = 0;
-
-var responses = [
- "response0", // This should be the first returned value
- "response1", // This response should not be recevied. Load response0 from cache
- "response2", // This request should fail
- "response3", // This request should succeed
- ];
-
-function http_handler(metadata, response) {
- response.setHeader("Content-Type", "text/plain", false);
- response.setHeader("Cache-Control", "no-cache", false);
- response.setStatusLine(metadata.httpVersion, 200, "OK");
- var body = responses[test_index];
- response.bodyOutputStream.write(body, body.length);
-}
-
-
-function set_app_offline(appId, offline) {
- let ioservice = Cc['@mozilla.org/network/io-service;1'].
- getService(Ci.nsIIOService);
-
- ioservice.setAppOffline(appId, offline);
-}
-
-var httpserv;
-
-function setup() {
- httpserv = new HttpServer();
- httpserv.registerPathHandler("/first", http_handler);
- httpserv.registerPathHandler("/second", http_handler);
- httpserv.start(12345);
-}
-
-function run_test() {
- setup();
- test0();
-}
-
-// Test that app 14 can open channel
-function test0() {
- test_index = 0;
- run_test_in_child("child_app_offline.js", test1);
-}
-
-// Set app 14 offline and check that it still gets a cached response
-function test1() {
- test_index = 1;
- set_app_offline(14, Ci.nsIAppOfflineInfo.OFFLINE);
- sendCommand('test1();\n', test2);
-}
-
-// Check that app 14 can't open a channel to a new location
-function test2() {
- test_index = 2;
- sendCommand('test2();\n', test3);
-}
-
-
-// Set app online and check that it now works
-function test3() {
- test_index = 3;
- set_app_offline(14, Ci.nsIAppOfflineInfo.ONLINE);
- sendCommand('test3();\n', ending);
-}
-
-function ending(val) {
- do_test_finished();
-}
deleted file mode 100644
--- a/netwerk/test/unit_ipc/test_app_offline_notifications.js
+++ /dev/null
@@ -1,102 +0,0 @@
-// Checks that app-offline notifications are received in both the parent
-// and the child process, and that after receiving the notification
-// isAppOffline returns the correct value
-
-
-Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-var test_index = 0;
-var APP_ID = 42;
-var events_observed_no = 0;
-
-function set_app_offline(appId, offline) {
- let ioservice = Cc['@mozilla.org/network/io-service;1'].
- getService(Ci.nsIIOService);
- ioservice.setAppOffline(appId, offline);
-}
-
-function is_app_offline(appId) {
- let ioservice = Cc['@mozilla.org/network/io-service;1'].
- getService(Ci.nsIIOService);
- return ioservice.isAppOffline(appId);
-}
-
-// The expected offline status after running each function,
-// and the next function that should be run.
-
-// test0 test1 test2 test3 test4
-let expected_offline = [ false, true, true, false, false];
-let callbacks = [ test1, test2, test3, test4, finished];
-
-function observer(aSubject, aTopic, aData) {
- events_observed_no++;
- let info = aSubject.QueryInterface(Ci.nsIAppOfflineInfo);
- dump("ParentObserver - subject: {" + aSubject.appId + ", " + aSubject.mode + "} " +
- "topic: " + aTopic + "\n");
-
- // Check that the correct offline status is in place
- do_check_eq(is_app_offline(APP_ID), expected_offline[test_index]);
-
- // Execute the callback for the current test
- do_execute_soon(callbacks[test_index]);
-}
-
-function run_test() {
- Services.obs.addObserver(observer, "network:app-offline-status-changed", false);
-
- test_index = 0;
- do_check_eq(is_app_offline(APP_ID), expected_offline[test_index]) // The app should be online at first
- run_test_in_child("child_app_offline_notifications.js", test0);
-}
-
-// Check that the app is online by default in the child
-function test0() {
- dump("parent: RUNNING: test0\n");
- test_index = 0;
- sendCommand('check_status('+APP_ID+','+Ci.nsIAppOfflineInfo.ONLINE+');\n', test1);
-}
-
-// Set the app OFFLINE
-// Check that the notification is emmited in the parent process
-// The observer function will execute test2 which does the check in the child
-function test1() {
- dump("parent: RUNNING: test1\n");
- test_index = 1;
- set_app_offline(APP_ID, Ci.nsIAppOfflineInfo.OFFLINE);
-}
-
-// Checks that child process sees the app OFFLINE
-function test2() {
- dump("parent: RUNNING: test2\n");
- test_index = 2;
- sendCommand('check_notification_and_status('+APP_ID+','+Ci.nsIAppOfflineInfo.OFFLINE+');\n', test3);
-}
-
-// Set the app ONLINE
-// Chech that the notification is received in the parent
-// The observer function will execute test3 and do the check in the child
-function test3() {
- dump("parent: RUNNING: test3\n");
- test_index = 3;
- set_app_offline(APP_ID, Ci.nsIAppOfflineInfo.ONLINE);
-}
-
-// Chech that the app is back online
-function test4() {
- dump("parent: RUNNING: test4\n");
- test_index = 4;
- sendCommand('check_notification_and_status('+APP_ID+','+Ci.nsIAppOfflineInfo.ONLINE+');\n', function() {
- // Send command to unregister observer on the child
- sendCommand('finished();\n', finished);
- });
-}
-
-// Remove observer and end test
-function finished() {
- dump("parent: RUNNING: finished\n");
- Services.obs.removeObserver(observer, "network:app-offline-status-changed");
- do_check_eq(events_observed_no, 2);
- do_test_finished();
-}
--- a/netwerk/test/unit_ipc/xpcshell.ini
+++ b/netwerk/test/unit_ipc/xpcshell.ini
@@ -1,14 +1,13 @@
[DEFAULT]
head = head_channels_clone.js head_cc.js
tail =
skip-if = toolkit == 'android' || toolkit == 'gonk'
-support-files = child_app_offline.js
- child_app_offline_notifications.js
+support-files =
child_channel_id.js
!/netwerk/test/unit/test_XHR_redirects.js
!/netwerk/test/unit/test_bug248970_cookie.js
!/netwerk/test/unit/test_bug528292.js
!/netwerk/test/unit/test_cache_jar.js
!/netwerk/test/unit/test_cacheflags.js
!/netwerk/test/unit/test_channel_close.js
!/netwerk/test/unit/test_cookie_header.js
@@ -88,15 +87,13 @@ skip-if = true
[test_reentrancy_wrap.js]
[test_resumable_channel_wrap.js]
[test_simple_wrap.js]
[test_synthesized_response_wrap.js]
[test_xmlhttprequest_wrap.js]
[test_XHR_redirects.js]
[test_redirect_history_wrap.js]
[test_reply_without_content_type_wrap.js]
-[test_app_offline_http.js]
[test_getHost_wrap.js]
[test_alt-data_simple_wrap.js]
[test_alt-data_stream_wrap.js]
-[test_app_offline_notifications.js]
[test_original_sent_received_head_wrap.js]
[test_channel_id.js]