Skip to content

Commit

Permalink
Backed out 6 changesets (bug 939318) for Windows xpcshell failures on…
Browse files Browse the repository at this point in the history
… a CLOSED TREE.

Backed out changeset faece15110ef (bug 939318)
Backed out changeset ecc0368d9283 (bug 939318)
Backed out changeset 4dcb889cf913 (bug 939318)
Backed out changeset 2fe8c65c26c2 (bug 939318)
Backed out changeset 0b9c1bbc7826 (bug 939318)
Backed out changeset fc191ae0a0e8 (bug 939318)
  • Loading branch information
rvandermeulen committed Aug 29, 2014
1 parent 2cd0c96 commit 5c2f080
Show file tree
Hide file tree
Showing 29 changed files with 150 additions and 762 deletions.
9 changes: 0 additions & 9 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,6 @@ pref("security.fileuri.strict_origin_policy", true);
// the results
pref("network.allow-experiments", true);

// Allow the network changed event to get sent when a network topology or
// setup change is noticed while running.
pref("network.notify.changed", true);

// Transmit UDP busy-work to the LAN when anticipating low latency
// network reads and on wifi to mitigate 802.11 Power Save Polling delays
pref("network.tickle-wifi.enabled", false);
Expand Down Expand Up @@ -1170,11 +1166,6 @@ pref("network.http.connection-retry-timeout", 250);
// to give up if the OS does not give up first
pref("network.http.connection-timeout", 90);

// The number of seconds to allow active connections to prove that they have
// traffic before considered stalled, after a network change has been detected
// and signalled.
pref("network.http.network-changed.timeout", 5);

// The maximum number of current global half open sockets allowable
// when starting a new speculative connection.
pref("network.http.speculative-parallel-limit", 6);
Expand Down
7 changes: 1 addition & 6 deletions netwerk/base/public/nsINetworkLinkService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Network link status monitoring service.
*/
[scriptable, uuid(2deead82-1d29-45f5-8c59-5dbee477cff8)]
[scriptable, uuid(f7d3be87-7403-4a1e-b89f-2797776e9b08)]
interface nsINetworkLinkService : nsISupports
{
/* Link type constants */
Expand Down Expand Up @@ -64,11 +64,6 @@ interface nsINetworkLinkService : nsISupports
* isLinkUp is now false, linkStatusKnown is true.
*/
#define NS_NETWORK_LINK_DATA_DOWN "down"
/**
* isLinkUp is still true, but the network setup is modified.
* linkStatusKnown is true.
*/
#define NS_NETWORK_LINK_DATA_CHANGED "changed"
/**
* linkStatusKnown is now false.
*/
Expand Down
133 changes: 48 additions & 85 deletions netwerk/base/src/nsIOService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "nsPIDNSService.h"
#include "nsIProtocolProxyService2.h"
#include "MainThreadUtils.h"
#include "nsIWidget.h"

#if defined(XP_WIN)
#include "nsNativeConnectionHelper.h"
Expand All @@ -55,15 +54,14 @@ using namespace mozilla;
// but the old names are still used to preserve backward compatibility.
#define NECKO_BUFFER_CACHE_COUNT_PREF "network.buffer.cache.count"
#define NECKO_BUFFER_CACHE_SIZE_PREF "network.buffer.cache.size"
#define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed"

#define MAX_RECURSION_COUNT 50

nsIOService* gIOService = nullptr;
static bool gHasWarnedUploadChannel2;

// A general port blacklist. Connections to these ports will not be allowed
// unless the protocol overrides.
// A general port blacklist. Connections to these ports will not be allowed unless
// the protocol overrides.
//
// TODO: I am sure that there are more ports to be added.
// This cut is based on the classic mozilla codebase
Expand Down Expand Up @@ -150,7 +148,6 @@ nsIOService::nsIOService()
, mNetworkLinkServiceInitialized(false)
, mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY)
, mAutoDialEnabled(false)
, mNetworkNotifyChanged(true)
{
}

Expand Down Expand Up @@ -190,7 +187,6 @@ nsIOService::Init()
prefBranch->AddObserver(MANAGE_OFFLINE_STATUS_PREF, this, true);
prefBranch->AddObserver(NECKO_BUFFER_CACHE_COUNT_PREF, this, true);
prefBranch->AddObserver(NECKO_BUFFER_CACHE_SIZE_PREF, this, true);
prefBranch->AddObserver(NETWORK_NOTIFY_CHANGED_PREF, this, true);
PrefsChanged(prefBranch);
}

Expand All @@ -203,7 +199,6 @@ nsIOService::Init()
observerService->AddObserver(this, kProfileDoChange, true);
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
observerService->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true);
}
else
NS_WARNING("failed to get observer service");
Expand Down Expand Up @@ -270,9 +265,10 @@ nsIOService::InitializeNetworkLinkService()
// so let's cross our fingers!
mManageOfflineStatus = false;
}


if (mManageOfflineStatus)
OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
TrackNetworkLinkStatusForOffline();
else
SetOffline(false);

Expand Down Expand Up @@ -855,14 +851,6 @@ nsIOService::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
gDefaultSegmentSize = size;
NS_WARN_IF_FALSE( (!(size & (size - 1))) , "network segment size is not a power of 2!");
}

if (!pref || strcmp(pref, NETWORK_NOTIFY_CHANGED_PREF) == 0) {
bool allow;
nsresult rv = prefs->GetBoolPref(NETWORK_NOTIFY_CHANGED_PREF, &allow);
if (NS_SUCCEEDED(rv)) {
mNetworkNotifyChanged = allow;
}
}
}

void
Expand Down Expand Up @@ -923,20 +911,23 @@ nsIOService::Observe(nsISupports *subject,
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(subject);
if (prefBranch)
PrefsChanged(prefBranch, NS_ConvertUTF16toUTF8(data).get());
} else if (!strcmp(topic, kProfileChangeNetTeardownTopic)) {
}
else if (!strcmp(topic, kProfileChangeNetTeardownTopic)) {
if (!mOffline) {
mOfflineForProfileChange = true;
SetOffline(true);
}
} else if (!strcmp(topic, kProfileChangeNetRestoreTopic)) {
}
else if (!strcmp(topic, kProfileChangeNetRestoreTopic)) {
if (mOfflineForProfileChange) {
mOfflineForProfileChange = false;
if (!mManageOfflineStatus ||
NS_FAILED(OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN))) {
NS_FAILED(TrackNetworkLinkStatusForOffline())) {
SetOffline(false);
}
}
} else if (!strcmp(topic, kProfileDoChange)) {
}
else if (!strcmp(topic, kProfileDoChange)) {
if (data && NS_LITERAL_STRING("startup").Equals(data)) {
// Lazy initialization of network link service (see bug 620472)
InitializeNetworkLinkService();
Expand All @@ -948,7 +939,8 @@ nsIOService::Observe(nsISupports *subject,
GetPrefBranch(getter_AddRefs(prefBranch));
PrefsChanged(prefBranch, MANAGE_OFFLINE_STATUS_PREF);
}
} else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
}
else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
// Remember we passed XPCOM shutdown notification to prevent any
// changes of the offline status from now. We must not allow going
// online after this point.
Expand All @@ -958,25 +950,13 @@ nsIOService::Observe(nsISupports *subject,

// Break circular reference.
mProxyService = nullptr;
} else if (!strcmp(topic, NS_NETWORK_LINK_TOPIC)) {
if (!mOfflineForProfileChange) {
OnNetworkLinkEvent(NS_ConvertUTF16toUTF8(data).get());
}
} else if (!strcmp(topic, NS_WIDGET_WAKE_OBSERVER_TOPIC)) {
// coming back alive from sleep
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();

NS_ASSERTION(observerService, "The observer service should not be null");

if (observerService && mNetworkNotifyChanged) {
(void)observerService->
NotifyObservers(nullptr,
NS_NETWORK_LINK_TOPIC,
MOZ_UTF16(NS_NETWORK_LINK_DATA_CHANGED));
}
else if (!strcmp(topic, NS_NETWORK_LINK_TOPIC)) {
if (!mOfflineForProfileChange && mManageOfflineStatus) {
TrackNetworkLinkStatusForOffline();
}
}

return NS_OK;
}

Expand Down Expand Up @@ -1074,25 +1054,24 @@ nsIOService::NewSimpleNestedURI(nsIURI* aURI, nsIURI** aResult)
}

NS_IMETHODIMP
nsIOService::SetManageOfflineStatus(bool aManage)
{
nsIOService::SetManageOfflineStatus(bool aManage) {
nsresult rv = NS_OK;

// SetManageOfflineStatus must throw when we fail to go from non-managed
// to managed. Usually because there is no link monitoring service
// available. Failure to do this switch is detected by a failure of
// OnNetworkLinkEvent(). When there is no network link available during
// call to InitializeNetworkLinkService(), application is put to offline
// mode. And when we change mMangeOfflineStatus to false on the next line
// we get stuck on being offline even though the link becomes later
// available.
// to managed. Usually because there is no link monitoring service
// available. Failure to do this switch is detected by a failure of
// TrackNetworkLinkStatusForOffline(). When there is no network link
// available during call to InitializeNetworkLinkService(), application is
// put to offline mode. And when we change mMangeOfflineStatus to false
// on the next line we get stuck on being offline even though the link
// becomes later available.
bool wasManaged = mManageOfflineStatus;
mManageOfflineStatus = aManage;

InitializeNetworkLinkService();

if (mManageOfflineStatus && !wasManaged) {
rv = OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
rv = TrackNetworkLinkStatusForOffline();
if (NS_FAILED(rv))
mManageOfflineStatus = false;
}
Expand All @@ -1105,57 +1084,41 @@ nsIOService::GetManageOfflineStatus(bool* aManage) {
return NS_OK;
}

// input argument 'data' is already UTF8'ed
nsresult
nsIOService::OnNetworkLinkEvent(const char *data)
nsIOService::TrackNetworkLinkStatusForOffline()
{
NS_ASSERTION(mManageOfflineStatus,
"Don't call this unless we're managing the offline status");
if (!mNetworkLinkService)
return NS_ERROR_FAILURE;

if (mShutdown)
return NS_ERROR_NOT_AVAILABLE;

if (mManageOfflineStatus)
return NS_OK;

if (!strcmp(data, NS_NETWORK_LINK_DATA_DOWN)) {
// check to make sure this won't collide with Autodial
if (mSocketTransportService) {
bool autodialEnabled = false;
mSocketTransportService->GetAutodialEnabled(&autodialEnabled);
// If autodialing-on-link-down is enabled, check if the OS auto
// dial option is set to always autodial. If so, then we are
// always up for the purposes of offline management.
if (autodialEnabled) {

// check to make sure this won't collide with Autodial
if (mSocketTransportService) {
bool autodialEnabled = false;
mSocketTransportService->GetAutodialEnabled(&autodialEnabled);
// If autodialing-on-link-down is enabled, check if the OS auto dial
// option is set to always autodial. If so, then we are
// always up for the purposes of offline management.
if (autodialEnabled) {
#if defined(XP_WIN)
// On Windows, we should first check with the OS to see if
// autodial is enabled. If it is enabled then we are allowed
// to manage the offline state.
if (nsNativeConnectionHelper::IsAutodialEnabled()) {
return SetOffline(false);
}
#else
// On Windows, we should first check with the OS
// to see if autodial is enabled. If it is
// enabled then we are allowed to manage the
// offline state.
if(nsNativeConnectionHelper::IsAutodialEnabled())
return SetOffline(false);
#else
return SetOffline(false);
#endif
}
}
}

bool isUp;
if (!strcmp(data, NS_NETWORK_LINK_DATA_DOWN)) {
isUp = false;
} else if (!strcmp(data, NS_NETWORK_LINK_DATA_UP)) {
isUp = true;
} else if (!strcmp(data, NS_NETWORK_LINK_DATA_CHANGED)) {
// CHANGED events are handled by others
return NS_OK;
} else if (!strcmp(data, NS_NETWORK_LINK_DATA_UNKNOWN)) {
nsresult rv = mNetworkLinkService->GetIsLinkUp(&isUp);
NS_ENSURE_SUCCESS(rv, rv);
} else {
NS_WARNING("Unhandled network event!");
return NS_OK;
}
nsresult rv = mNetworkLinkService->GetIsLinkUp(&isUp);
NS_ENSURE_SUCCESS(rv, rv);
return SetOffline(!isUp);
}

Expand Down
3 changes: 1 addition & 2 deletions netwerk/base/src/nsIOService.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class nsIOService MOZ_FINAL : public nsIIOService2
nsIOService();
~nsIOService();

nsresult OnNetworkLinkEvent(const char *data);
nsresult TrackNetworkLinkStatusForOffline();

nsresult GetCachedProtocolHandler(const char *scheme,
nsIProtocolHandler* *hdlrResult,
Expand Down Expand Up @@ -129,7 +129,6 @@ class nsIOService MOZ_FINAL : public nsIIOService2
nsTArray<int32_t> mRestrictedPortList;

bool mAutoDialEnabled;
bool mNetworkNotifyChanged;
public:
// Used for all default buffer sizes that necko allocates.
static uint32_t gDefaultSegmentSize;
Expand Down
16 changes: 2 additions & 14 deletions netwerk/base/src/nsProtocolProxyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "mozilla/Mutex.h"
#include "mozilla/CondVar.h"
#include "nsISystemProxySettings.h"
#include "nsINetworkLinkService.h"

//----------------------------------------------------------------------------

Expand Down Expand Up @@ -415,15 +414,11 @@ nsProtocolProxyService::Init()
PrefsChanged(prefBranch, nullptr);
}

// register for shutdown notification so we can clean ourselves up properly.
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
// register for shutdown notification so we can clean ourselves up
// properly.
if (obs)
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);

obs->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);
}

return NS_OK;
}

Expand All @@ -445,13 +440,6 @@ nsProtocolProxyService::Observe(nsISupports *aSubject,
mPACMan->Shutdown();
mPACMan = nullptr;
}
} else if (strcmp(aTopic, NS_NETWORK_LINK_TOPIC) == 0) {
nsCString converted = NS_ConvertUTF16toUTF8(aData);
const char *state = converted.get();
if (strcmp(state, NS_NETWORK_LINK_DATA_CHANGED) == 0) {
LOG((": received network event: %s, reload PAC", state));
ReloadPAC();
}
}
else {
NS_ASSERTION(strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
Expand Down
Loading

0 comments on commit 5c2f080

Please sign in to comment.