diff options
Diffstat (limited to 'netwerk')
33 files changed, 295 insertions, 637 deletions
diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index cfe94e35b..b338c2a08 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -9,7 +9,6 @@ #include "ScopedNSSTypes.h" #include "mozilla/Casting.h" #include "mozilla/Logging.h" -#include "mozilla/Telemetry.h" #include "nsCOMArray.h" #include "nsIAsyncInputStream.h" #include "nsIFile.h" @@ -85,7 +84,6 @@ private: //// BackgroundFileSaver uint32_t BackgroundFileSaver::sThreadCount = 0; -uint32_t BackgroundFileSaver::sTelemetryMaxThreadCount = 0; BackgroundFileSaver::BackgroundFileSaver() : mControlThread(nullptr) @@ -156,9 +154,6 @@ BackgroundFileSaver::Init() NS_ENSURE_SUCCESS(rv, rv); sThreadCount++; - if (sThreadCount > sTelemetryMaxThreadCount) { - sTelemetryMaxThreadCount = sThreadCount; - } return NS_OK; } @@ -793,14 +788,6 @@ BackgroundFileSaver::NotifySaveComplete() sThreadCount--; - // When there are no more active downloads, we consider the download session - // finished. We record the maximum number of concurrent downloads reached - // during the session in a telemetry histogram, and we reset the maximum - // thread counter for the next download session - if (sThreadCount == 0) { - sTelemetryMaxThreadCount = 0; - } - return NS_OK; } diff --git a/netwerk/base/BackgroundFileSaver.h b/netwerk/base/BackgroundFileSaver.h index 1fa9268f8..86d3a1ba7 100644 --- a/netwerk/base/BackgroundFileSaver.h +++ b/netwerk/base/BackgroundFileSaver.h @@ -61,15 +61,6 @@ public: */ static uint32_t sThreadCount; - /** - * Maximum number of worker threads reached during the current download session, - * used for telemetry. - * - * When there are no more worker threads running, we consider the download - * session finished, and this counter is reset. - */ - static uint32_t sTelemetryMaxThreadCount; - protected: virtual ~BackgroundFileSaver(); diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 435294315..e0dc7d8e8 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -48,7 +48,6 @@ #include "mozilla/LoadInfo.h" #include "mozilla/net/NeckoCommon.h" #include "mozilla/Services.h" -#include "mozilla/Telemetry.h" #include "mozilla/net/DNS.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/NeckoChild.h" @@ -166,8 +165,6 @@ static const char kProfileDoChange[] = "profile-do-change"; uint32_t nsIOService::gDefaultSegmentSize = 4096; uint32_t nsIOService::gDefaultSegmentCount = 24; -bool nsIOService::sTelemetryEnabled = false; - bool nsIOService::sBlockToplevelDataUriNavigations = false; //////////////////////////////////////////////////////////////////////////////// @@ -185,9 +182,6 @@ nsIOService::nsIOService() , mNetworkLinkServiceInitialized(false) , mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY) , mNetworkNotifyChanged(true) - , mLastOfflineStateChange(PR_IntervalNow()) - , mLastConnectivityChange(PR_IntervalNow()) - , mLastNetworkLinkChange(PR_IntervalNow()) , mNetTearingDownStarted(0) { } @@ -247,7 +241,6 @@ nsIOService::Init() else NS_WARNING("failed to get observer service"); - Preferences::AddBoolVarCache(&sTelemetryEnabled, "toolkit.telemetry.enabled", false); Preferences::AddBoolVarCache(&sBlockToplevelDataUriNavigations, "security.data_uri.block_toplevel_data_uri_navigations", false); Preferences::AddBoolVarCache(&mOfflineMirrorsConnectivity, OFFLINE_MIRRORS_CONNECTIVITY, true); @@ -1068,7 +1061,6 @@ nsIOService::SetOffline(bool offline) if (mSocketTransportService) mSocketTransportService->SetOffline(true); - mLastOfflineStateChange = PR_IntervalNow(); if (observerService) observerService->NotifyObservers(subject, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, @@ -1088,7 +1080,6 @@ nsIOService::SetOffline(bool offline) if (mProxyService) mProxyService->ReloadPAC(); - mLastOfflineStateChange = PR_IntervalNow(); // don't care if notification fails // Only send the ONLINE notification if there is connectivity if (observerService && mConnectivity) { @@ -1147,10 +1138,6 @@ nsIOService::SetConnectivityInternal(bool aConnectivity) } mConnectivity = aConnectivity; - // This is used for PR_Connect PR_Close telemetry so it is important that - // we have statistic about network change event even if we are offline. - mLastConnectivityChange = PR_IntervalNow(); - if (mCaptivePortalService) { if (aConnectivity && !xpc::AreNonLocalConnectionsDisabled()) { // This will also trigger a captive portal check for the new network @@ -1621,7 +1608,6 @@ nsIOService::OnNetworkLinkEvent(const char *data) bool isUp = true; if (!strcmp(data, NS_NETWORK_LINK_DATA_CHANGED)) { - mLastNetworkLinkChange = PR_IntervalNow(); // CHANGED means UP/DOWN didn't change // but the status of the captive portal may have changed. RecheckCaptivePortal(); diff --git a/netwerk/base/nsIOService.h b/netwerk/base/nsIOService.h index e592c4d1c..19eed743a 100644 --- a/netwerk/base/nsIOService.h +++ b/netwerk/base/nsIOService.h @@ -79,9 +79,6 @@ public: nsAsyncRedirectVerifyHelper *helper); bool IsOffline() { return mOffline; } - PRIntervalTime LastOfflineStateChange() { return mLastOfflineStateChange; } - PRIntervalTime LastConnectivityChange() { return mLastConnectivityChange; } - PRIntervalTime LastNetworkLinkChange() { return mLastNetworkLinkChange; } bool IsNetTearingDown() { return mShutdown || mOfflineForProfileChange || mHttpHandlerAlreadyShutingDown; } PRIntervalTime NetTearingDownStarted() { return mNetTearingDownStarted; } @@ -176,18 +173,8 @@ private: bool mNetworkNotifyChanged; - static bool sTelemetryEnabled; - static bool sBlockToplevelDataUriNavigations; - // 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; - mozilla::Atomic<PRIntervalTime> mLastConnectivityChange; - mozilla::Atomic<PRIntervalTime> mLastNetworkLinkChange; - // Time a network tearing down started. mozilla::Atomic<PRIntervalTime> mNetTearingDownStarted; public: diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index 9981bd698..48d9a6621 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -108,9 +108,6 @@ nsLoadGroup::nsLoadGroup(nsISupports* outer) , mStatus(NS_OK) , mPriority(PRIORITY_NORMAL) , mIsCanceling(false) - , mDefaultLoadIsTimed(false) - , mTimedRequests(0) - , mCachedRequests(0) , mTimedNonCachedRequestsUntilOnEndPageLoad(0) { NS_INIT_AGGREGATED(outer); @@ -431,13 +428,6 @@ nsLoadGroup::SetDefaultLoadRequest(nsIRequest *aRequest) // in particular, nsIChannel::LOAD_DOCUMENT_URI... // mLoadFlags &= nsIRequest::LOAD_REQUESTMASK; - - nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(aRequest); - mDefaultLoadIsTimed = timedChannel != nullptr; - if (mDefaultLoadIsTimed) { - timedChannel->GetChannelCreation(&mDefaultRequestCreationTime); - timedChannel->SetTimingEnabled(true); - } } // Else, do not change the group's load flags (see bug 95981) return NS_OK; @@ -492,10 +482,6 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) if (mPriority != 0) RescheduleRequest(request, mPriority); - nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(request); - if (timedChannel) - timedChannel->SetTimingEnabled(true); - if (!(flags & nsIRequest::LOAD_BACKGROUND)) { // Update the count of foreground URIs.. mForegroundCount += 1; @@ -573,10 +559,6 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, mRequests.RemoveEntry(entry); - if (mRequests.EntryCount() == 0) { - TelemetryReport(); - } - // Undo any group priority delta... if (mPriority != 0) RescheduleRequest(request, -mPriority); @@ -777,82 +759,6 @@ nsLoadGroup::SetDefaultLoadFlags(uint32_t aFlags) //////////////////////////////////////////////////////////////////////////////// -void -nsLoadGroup::TelemetryReport() -{ - /* STUB */ - mTimedRequests = 0; - mCachedRequests = 0; - mDefaultLoadIsTimed = false; -} - -void -nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel, - bool aDefaultRequest) -{ - nsresult rv; - bool timingEnabled; - rv = aTimedChannel->GetTimingEnabled(&timingEnabled); - if (NS_FAILED(rv) || !timingEnabled) - return; - - TimeStamp asyncOpen; - rv = aTimedChannel->GetAsyncOpen(&asyncOpen); - // We do not check !asyncOpen.IsNull() bellow, prevent ASSERTIONs this way - if (NS_FAILED(rv) || asyncOpen.IsNull()) - return; - - TimeStamp cacheReadStart; - rv = aTimedChannel->GetCacheReadStart(&cacheReadStart); - if (NS_FAILED(rv)) - return; - - TimeStamp cacheReadEnd; - rv = aTimedChannel->GetCacheReadEnd(&cacheReadEnd); - if (NS_FAILED(rv)) - return; - - TimeStamp domainLookupStart; - rv = aTimedChannel->GetDomainLookupStart(&domainLookupStart); - if (NS_FAILED(rv)) - return; - - TimeStamp domainLookupEnd; - rv = aTimedChannel->GetDomainLookupEnd(&domainLookupEnd); - if (NS_FAILED(rv)) - return; - - TimeStamp connectStart; - rv = aTimedChannel->GetConnectStart(&connectStart); - if (NS_FAILED(rv)) - return; - - TimeStamp secureConnectionStart; - rv = aTimedChannel->GetSecureConnectionStart(&secureConnectionStart); - if (NS_FAILED(rv)) - return; - - TimeStamp connectEnd; - rv = aTimedChannel->GetConnectEnd(&connectEnd); - if (NS_FAILED(rv)) - return; - - TimeStamp requestStart; - rv = aTimedChannel->GetRequestStart(&requestStart); - if (NS_FAILED(rv)) - return; - - TimeStamp responseStart; - rv = aTimedChannel->GetResponseStart(&responseStart); - if (NS_FAILED(rv)) - return; - - TimeStamp responseEnd; - rv = aTimedChannel->GetResponseEnd(&responseEnd); - if (NS_FAILED(rv)) - return; -} - nsresult nsLoadGroup::MergeLoadFlags(nsIRequest *aRequest, nsLoadFlags& outFlags) { diff --git a/netwerk/base/nsLoadGroup.h b/netwerk/base/nsLoadGroup.h index 20dd94cf9..9b5e70868 100644 --- a/netwerk/base/nsLoadGroup.h +++ b/netwerk/base/nsLoadGroup.h @@ -62,11 +62,6 @@ protected: nsresult MergeLoadFlags(nsIRequest *aRequest, nsLoadFlags& flags); nsresult MergeDefaultLoadFlags(nsIRequest *aRequest, nsLoadFlags& flags); -private: - void TelemetryReport(); - void TelemetryReportChannel(nsITimedChannel *timedChannel, - bool defaultRequest); - protected: uint32_t mForegroundCount; uint32_t mLoadFlags; @@ -87,12 +82,6 @@ protected: int32_t mPriority; bool mIsCanceling; - /* Telemetry */ - mozilla::TimeStamp mDefaultRequestCreationTime; - bool mDefaultLoadIsTimed; - uint32_t mTimedRequests; - uint32_t mCachedRequests; - /* For nsPILoadGroupInternal */ uint32_t mTimedNonCachedRequestsUntilOnEndPageLoad; }; diff --git a/netwerk/base/nsProtocolProxyService.cpp b/netwerk/base/nsProtocolProxyService.cpp index 26eca0e88..237a2a3bd 100644 --- a/netwerk/base/nsProtocolProxyService.cpp +++ b/netwerk/base/nsProtocolProxyService.cpp @@ -1841,6 +1841,13 @@ nsProtocolProxyService::Resolve_Internal(nsIChannel *channel, if (mPACMan && mPACMan->IsPACURI(uri)) return NS_OK; + // If proxies are enabled and this host:port combo is supposed to use a
+ // proxy, check for a proxy.
+ if ((mProxyConfig == PROXYCONFIG_DIRECT) ||
+ !CanUseProxy(uri, info.defaultPort)) {
+ return NS_OK;
+ }
+ bool mainThreadOnly; if (mSystemProxySettings && mProxyConfig == PROXYCONFIG_SYSTEM && diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index f9b55ead4..0c8434813 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -7,7 +7,6 @@ #include "nsSocketTransport2.h" #include "mozilla/Attributes.h" -#include "mozilla/Telemetry.h" #include "nsIOService.h" #include "nsStreamUtils.h" #include "nsNetSegmentUtils.h" @@ -1226,8 +1225,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, bool &proxyTransparent, bool &us if (NS_FAILED(rv)) { SOCKET_LOG((" error pushing io layer [%u:%s rv=%x]\n", i, mTypes[i], rv)); if (fd) { - CloseSocket(fd, - mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()); + CloseSocket(fd); } } } @@ -1395,8 +1393,7 @@ nsSocketTransport::InitiateSocket() // inform socket transport about this newly created socket... rv = mSocketTransportService->AttachSocket(fd, this); if (NS_FAILED(rv)) { - CloseSocket(fd, - mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()); + CloseSocket(fd); return rv; } mAttached = true; @@ -1453,26 +1450,8 @@ nsSocketTransport::InitiateSocket() } #endif - // We use PRIntervalTime here because we need - // nsIOService::LastOfflineStateChange time and - // nsIOService::LastConectivityChange time to be atomic. - PRIntervalTime connectStarted = 0; - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) { - connectStarted = PR_IntervalNow(); - } - status = PR_Connect(fd, &prAddr, NS_SOCKET_CONNECT_TIMEOUT); - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase() && - connectStarted) { - SendPRBlockingTelemetry(connectStarted, - Telemetry::PRCONNECT_BLOCKING_TIME_NORMAL, - Telemetry::PRCONNECT_BLOCKING_TIME_SHUTDOWN, - Telemetry::PRCONNECT_BLOCKING_TIME_CONNECTIVITY_CHANGE, - Telemetry::PRCONNECT_BLOCKING_TIME_LINK_CHANGE, - Telemetry::PRCONNECT_BLOCKING_TIME_OFFLINE); - } - if (status == PR_SUCCESS) { // // we are connected! @@ -1531,16 +1510,6 @@ nsSocketTransport::InitiateSocket() // The connection was refused... // else { - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase() && - connectStarted) { - SendPRBlockingTelemetry(connectStarted, - Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_NORMAL, - Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_SHUTDOWN, - Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_CONNECTIVITY_CHANGE, - Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_LINK_CHANGE, - Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_OFFLINE); - } - rv = ErrorAccordingToNSPR(code); if ((rv == NS_ERROR_CONNECTION_REFUSED) && !mProxyHost.IsEmpty()) rv = NS_ERROR_PROXY_CONNECTION_REFUSED; @@ -1763,8 +1732,7 @@ public: NS_IMETHOD Run() override { - nsSocketTransport::CloseSocket(mFD, - gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()); + nsSocketTransport::CloseSocket(mFD); return NS_OK; } private: @@ -1801,8 +1769,7 @@ nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd) SOCKET_LOG(("Intentional leak")); } else if (PR_GetCurrentThread() == gSocketThread) { SOCKET_LOG(("nsSocketTransport: calling PR_Close [this=%p]\n", this)); - CloseSocket(mFD, - mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()); + CloseSocket(mFD); } else { // Can't PR_Close() a socket off STS thread. Thunk it to STS to die STS_PRCloseOnSocketTransport(mFD); @@ -1960,26 +1927,7 @@ nsSocketTransport::OnSocketReady(PRFileDesc *fd, int16_t outFlags) // We do not need to do PR_ConnectContinue when we are already // shutting down. - // We use PRIntervalTime here because we need - // nsIOService::LastOfflineStateChange time and - // nsIOService::LastConectivityChange time to be atomic. - PRIntervalTime connectStarted = 0; - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) { - connectStarted = PR_IntervalNow(); - } - PRStatus status = PR_ConnectContinue(fd, outFlags); - - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase() && - connectStarted) { - SendPRBlockingTelemetry(connectStarted, - Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_NORMAL, - Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_SHUTDOWN, - Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_CONNECTIVITY_CHANGE, - Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_LINK_CHANGE, - Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_OFFLINE); - } - if (status == PR_SUCCESS) { // // we are connected! @@ -3144,41 +3092,13 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveVals(bool aEnabled, } void -nsSocketTransport::CloseSocket(PRFileDesc *aFd, bool aTelemetryEnabled) +nsSocketTransport::CloseSocket(PRFileDesc *aFd) { #if defined(XP_WIN) AttachShutdownLayer(aFd); #endif - // We use PRIntervalTime here because we need - // nsIOService::LastOfflineStateChange time and - // nsIOService::LastConectivityChange time to be atomic. - PRIntervalTime closeStarted; - if (aTelemetryEnabled) { - closeStarted = PR_IntervalNow(); - } - PR_Close(aFd); - - if (aTelemetryEnabled) { - SendPRBlockingTelemetry(closeStarted, - Telemetry::PRCLOSE_TCP_BLOCKING_TIME_NORMAL, - Telemetry::PRCLOSE_TCP_BLOCKING_TIME_SHUTDOWN, - Telemetry::PRCLOSE_TCP_BLOCKING_TIME_CONNECTIVITY_CHANGE, - Telemetry::PRCLOSE_TCP_BLOCKING_TIME_LINK_CHANGE, - Telemetry::PRCLOSE_TCP_BLOCKING_TIME_OFFLINE); - } -} - -void -nsSocketTransport::SendPRBlockingTelemetry(PRIntervalTime aStart, - Telemetry::ID aIDNormal, - Telemetry::ID aIDShutdown, - Telemetry::ID aIDConnectivityChange, - Telemetry::ID aIDLinkChange, - Telemetry::ID aIDOffline) -{ - /* STUB */ } } // namespace net diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index 7c85ccdc4..310cc58d3 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -22,7 +22,6 @@ #include "nsIClassInfo.h" #include "mozilla/net/DNS.h" #include "nsASocketHandler.h" -#include "mozilla/Telemetry.h" #include "prerror.h" #include "nsAutoPtr.h" @@ -169,13 +168,7 @@ public: uint64_t ByteCountReceived() override { return mInput.ByteCount(); } uint64_t ByteCountSent() override { return mOutput.ByteCount(); } - static void CloseSocket(PRFileDesc *aFd, bool aTelemetryEnabled); - static void SendPRBlockingTelemetry(PRIntervalTime aStart, - Telemetry::ID aIDNormal, - Telemetry::ID aIDShutdown, - Telemetry::ID aIDConnectivityChange, - Telemetry::ID aIDLinkChange, - Telemetry::ID aIDOffline); + static void CloseSocket(PRFileDesc *aFd); protected: virtual ~nsSocketTransport(); diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 739388b0f..af5742564 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -22,7 +22,6 @@ #include "mozilla/PublicSSL.h" #include "mozilla/ChaosMode.h" #include "mozilla/PodOperations.h" -#include "mozilla/Telemetry.h" #include "nsThreadUtils.h" #include "nsIFile.h" #include "nsIWidget.h" @@ -47,7 +46,6 @@ Atomic<PRThread*, Relaxed> gSocketThread; #define SOCKET_LIMIT_MIN 50U #define BLIP_INTERVAL_PREF "network.activity.blipIntervalMilliseconds" #define MAX_TIME_BETWEEN_TWO_POLLS "network.sts.max_time_for_events_between_two_polls" -#define TELEMETRY_PREF "toolkit.telemetry.enabled" #define MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN "network.sts.max_time_for_pr_close_during_shutdown" #define REPAIR_POLLABLE_EVENT_TIME 10 @@ -79,9 +77,7 @@ nsSocketTransportService::nsSocketTransportService() , mKeepaliveEnabledPref(false) , mServingPendingQueue(false) , mMaxTimePerPollIter(100) - , mTelemetryEnabledPref(false) , mMaxTimeForPrClosePref(PR_SecondsToInterval(5)) - , mSleepPhase(false) , mProbedMaxCount(false) #if defined(XP_WIN) , mPolling(false) @@ -211,16 +207,9 @@ nsSocketTransportService::AttachSocket(PRFileDesc *fd, nsASocketHandler *handler bool nsSocketTransportService::CanAttachSocket() { - static bool reported900FDLimit = false; - uint32_t total = mActiveCount + mIdleCount; bool rv = total < gMaxCount; - if (mTelemetryEnabledPref && - (((total >= 900) || !rv) && !reported900FDLimit)) { - reported900FDLimit = true; - } - return rv; } @@ -438,13 +427,11 @@ nsSocketTransportService::PollTimeout() } int32_t -nsSocketTransportService::Poll(uint32_t *interval, - TimeDuration *pollDuration) +nsSocketTransportService::Poll(uint32_t *interval) { PRPollDesc *pollList; uint32_t pollCount; PRIntervalTime pollTimeout; - *pollDuration = 0; // If there are pending events for this thread then // DoPollIteration() should service the network without blocking. @@ -470,8 +457,6 @@ nsSocketTransportService::Poll(uint32_t *interval, PRIntervalTime ts = PR_IntervalNow(); - TimeStamp pollStart; - SOCKET_LOG((" timeout = %i milliseconds\n", PR_IntervalToMilliseconds(pollTimeout))); int32_t rv = PR_Poll(pollList, pollCount, pollTimeout); @@ -530,7 +515,6 @@ nsSocketTransportService::Init() tmpPrefService->AddObserver(KEEPALIVE_RETRY_INTERVAL_PREF, this, false); tmpPrefService->AddObserver(KEEPALIVE_PROBE_COUNT_PREF, this, false); tmpPrefService->AddObserver(MAX_TIME_BETWEEN_TWO_POLLS, this, false); - tmpPrefService->AddObserver(TELEMETRY_PREF, this, false); tmpPrefService->AddObserver(MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN, this, false); } UpdatePrefs(); @@ -539,8 +523,6 @@ nsSocketTransportService::Init() if (obsSvc) { obsSvc->AddObserver(this, "profile-initial-state", false); obsSvc->AddObserver(this, "last-pb-context-exited", false); - obsSvc->AddObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC, true); - obsSvc->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true); obsSvc->AddObserver(this, "xpcom-shutdown-threads", false); } @@ -607,16 +589,9 @@ nsSocketTransportService::ShutdownThread() if (obsSvc) { obsSvc->RemoveObserver(this, "profile-initial-state"); obsSvc->RemoveObserver(this, "last-pb-context-exited"); - obsSvc->RemoveObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC); - obsSvc->RemoveObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC); obsSvc->RemoveObserver(this, "xpcom-shutdown-threads"); } - if (mAfterWakeUpTimer) { - mAfterWakeUpTimer->Cancel(); - mAfterWakeUpTimer = nullptr; - } - NetworkActivityMonitor::Shutdown(); mInitialized = false; @@ -851,24 +826,16 @@ nsSocketTransportService::Run() // make sure the pseudo random number generator is seeded on this thread srand(static_cast<unsigned>(PR_Now())); - // Time blocked in poll(). - TimeDuration singlePollDuration; - int numberOfPendingEvents; // If there is too many pending events queued, we will run some poll() - // between them and the following variable is cumulative time spent - // blocking in poll(). - TimeDuration pollDuration; - + // between them. for (;;) { bool pendingEvents = false; - numberOfPendingEvents = 0; - pollDuration = 0; do { - DoPollIteration(&singlePollDuration); + DoPollIteration(); mRawThread->HasPendingEvents(&pendingEvents); if (pendingEvents) { @@ -959,7 +926,7 @@ nsSocketTransportService::Reset(bool aGuardLocals) } nsresult -nsSocketTransportService::DoPollIteration(TimeDuration *pollDuration) +nsSocketTransportService::DoPollIteration() { SOCKET_LOG(("STS poll iter\n")); @@ -1019,13 +986,12 @@ nsSocketTransportService::DoPollIteration(TimeDuration *pollDuration) // Measures seconds spent while blocked on PR_Poll uint32_t pollInterval = 0; int32_t n = 0; - *pollDuration = 0; if (!gIOService->IsNetTearingDown()) { // Let's not do polling during shutdown. #if defined(XP_WIN) StartPolling(); #endif - n = Poll(&pollInterval, pollDuration); + n = Poll(&pollInterval); #if defined(XP_WIN) EndPolling(); #endif @@ -1171,13 +1137,6 @@ nsSocketTransportService::UpdatePrefs() mMaxTimePerPollIter = maxTimePref; } - bool telemetryPref = false; - rv = tmpPrefService->GetBoolPref(TELEMETRY_PREF, - &telemetryPref); - if (NS_SUCCEEDED(rv)) { - mTelemetryEnabledPref = telemetryPref; - } - int32_t maxTimeForPrClosePref; rv = tmpPrefService->GetIntPref(MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN, &maxTimeForPrClosePref); @@ -1255,10 +1214,6 @@ nsSocketTransportService::Observe(nsISupports *subject, if (!strcmp(topic, NS_TIMER_CALLBACK_TOPIC)) { nsCOMPtr<nsITimer> timer = do_QueryInterface(subject); - if (timer == mAfterWakeUpTimer) { - mAfterWakeUpTimer = nullptr; - mSleepPhase = false; - } #if defined(XP_WIN) if (timer == mPollRepairTimer) { @@ -1266,19 +1221,6 @@ nsSocketTransportService::Observe(nsISupports *subject, } #endif - } else if (!strcmp(topic, NS_WIDGET_SLEEP_OBSERVER_TOPIC)) { - mSleepPhase = true; - if (mAfterWakeUpTimer) { - mAfterWakeUpTimer->Cancel(); - mAfterWakeUpTimer = nullptr; - } - } else if (!strcmp(topic, NS_WIDGET_WAKE_OBSERVER_TOPIC)) { - if (mSleepPhase && !mAfterWakeUpTimer) { - mAfterWakeUpTimer = do_CreateInstance("@mozilla.org/timer;1"); - if (mAfterWakeUpTimer) { - mAfterWakeUpTimer->Init(this, 2000, nsITimer::TYPE_ONE_SHOT); - } - } } else if (!strcmp(topic, "xpcom-shutdown-threads")) { ShutdownThread(); } diff --git a/netwerk/base/nsSocketTransportService2.h b/netwerk/base/nsSocketTransportService2.h index 81c806793..0b88a6535 100644 --- a/netwerk/base/nsSocketTransportService2.h +++ b/netwerk/base/nsSocketTransportService2.h @@ -118,8 +118,6 @@ public: // Returns true if keepalives are enabled in prefs. bool IsKeepaliveEnabled() { return mKeepaliveEnabledPref; } - bool IsTelemetryEnabledAndNotSleepPhase() { return mTelemetryEnabledPref && - !mSleepPhase; } PRIntervalTime MaxTimeForPrClosePref() {return mMaxTimeForPrClosePref; } protected: @@ -191,7 +189,7 @@ private: bool GrowActiveList(); bool GrowIdleList(); - void InitMaxCount(); + void InitMaxCount(); // Total bytes number transfered through all the sockets except active ones uint64_t mSentBytesCount; @@ -206,15 +204,12 @@ private: PRPollDesc *mPollList; /* mListSize + 1 entries */ PRIntervalTime PollTimeout(); // computes ideal poll timeout - nsresult DoPollIteration(TimeDuration *pollDuration); + nsresult DoPollIteration(); // perfoms a single poll iteration - int32_t Poll(uint32_t *interval, - TimeDuration *pollDuration); + int32_t Poll(uint32_t *interval); // calls PR_Poll. the out param // interval indicates the poll // duration in seconds. - // pollDuration is used only for - // telemetry //------------------------------------------------------------------------- // pending socket queue - see NotifyWhenCanAttachSocket @@ -236,14 +231,8 @@ private: Atomic<bool> mServingPendingQueue; Atomic<int32_t, Relaxed> mMaxTimePerPollIter; - Atomic<bool, Relaxed> mTelemetryEnabledPref; Atomic<PRIntervalTime, Relaxed> mMaxTimeForPrClosePref; - // Between a computer going to sleep and waking up the PR_*** telemetry - // will be corrupted - so do not record it. - Atomic<bool, Relaxed> mSleepPhase; - nsCOMPtr<nsITimer> mAfterWakeUpTimer; - void OnKeepaliveEnabledPrefChange(); void NotifyKeepaliveEnabledPrefChange(SocketContext *sock); diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 445b62d9c..8b6a81bf5 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -7,7 +7,6 @@ #include "mozilla/EndianUtils.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/HoldDropJSObjects.h" -#include "mozilla/Telemetry.h" #include "nsSocketTransport2.h" #include "nsUDPSocket.h" @@ -173,7 +172,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsUDPMessage) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsUDPMessage) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsUDPMessage) @@ -275,7 +273,6 @@ void nsUDPSocket::AddOutputBytes(uint64_t aBytes) { mByteWriteCount += aBytes; - SaveNetworkStats(false); } void @@ -465,7 +462,6 @@ nsUDPSocket::OnSocketReady(PRFileDesc *fd, int16_t outFlags) return; } mByteReadCount += count; - SaveNetworkStats(false); FallibleTArray<uint8_t> data; if (!data.AppendElements(buff, count, fallible)) { @@ -512,7 +508,6 @@ nsUDPSocket::OnSocketDetached(PRFileDesc *fd) NS_ASSERTION(mFD == fd, "wrong file descriptor"); CloseSocket(); } - SaveNetworkStats(true); if (mListener) { @@ -726,7 +721,6 @@ nsUDPSocket::Close() // expects this happen synchronously. CloseSocket(); - SaveNetworkStats(true); return NS_OK; } } @@ -755,12 +749,6 @@ nsUDPSocket::GetLocalAddr(nsINetAddr * *aResult) } void -nsUDPSocket::SaveNetworkStats(bool aEnforce) -{ - /*** STUB ***/ -} - -void nsUDPSocket::CloseSocket() { if (mFD) { diff --git a/netwerk/base/nsUDPSocket.h b/netwerk/base/nsUDPSocket.h index f8ae87cee..2910a49dd 100644 --- a/netwerk/base/nsUDPSocket.h +++ b/netwerk/base/nsUDPSocket.h @@ -53,8 +53,6 @@ private: const PRNetAddr& aIface); nsresult SetMulticastInterfaceInternal(const PRNetAddr& aIface); - void SaveNetworkStats(bool aEnforce); - void CloseSocket(); // lock protects access to mListener; diff --git a/netwerk/base/security-prefs.js b/netwerk/base/security-prefs.js index 7d63267a6..ea0b2236d 100644 --- a/netwerk/base/security-prefs.js +++ b/netwerk/base/security-prefs.js @@ -17,6 +17,11 @@ pref("security.ssl.false_start.require-npn", false); pref("security.ssl.enable_npn", true); pref("security.ssl.enable_alpn", true); +// TLS 1.3 cipher suites +pref("security.tls13.aes_128_gcm_sha256", true); +pref("security.tls13.chacha20_poly1305_sha256", true); +pref("security.tls13.aes_256_gcm_sha384", true); + // TLS 1.0-1.2 cipher suites pref("security.ssl3.ecdhe_rsa_aes_128_gcm_sha256", true); pref("security.ssl3.ecdhe_ecdsa_aes_128_gcm_sha256", true); @@ -36,11 +41,14 @@ pref("security.ssl3.rsa_camellia_128_sha", true); pref("security.ssl3.rsa_camellia_256_sha", true); pref("security.ssl3.rsa_aes_128_sha", true); pref("security.ssl3.rsa_aes_256_sha", true); -// Weak / deprecated + +// Deprecated pref("security.ssl3.dhe_rsa_aes_256_sha", false); pref("security.ssl3.dhe_rsa_aes_128_sha", false); pref("security.ssl3.rsa_aes_128_gcm_sha256", false); pref("security.ssl3.rsa_aes_128_sha256", false); + +// Weak/broken (requires fallback_hosts) pref("security.ssl3.rsa_des_ede3_sha", false); pref("security.ssl3.rsa_rc4_128_sha", false); pref("security.ssl3.rsa_rc4_128_md5", false); diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 85f364e4e..3ee1e15cd 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -964,8 +964,6 @@ CacheStorageService::RegisterEntry(CacheEntry* aEntry) if (mShutdown || !aEntry->CanRegister()) return; - TelemetryRecordEntryCreation(aEntry); - LOG(("CacheStorageService::RegisterEntry [entry=%p]", aEntry)); MemoryPool& pool = Pool(aEntry->IsUsingDisk()); @@ -983,8 +981,6 @@ CacheStorageService::UnregisterEntry(CacheEntry* aEntry) if (!aEntry->IsRegistered()) return; - TelemetryRecordEntryRemoval(aEntry); - LOG(("CacheStorageService::UnregisterEntry [entry=%p]", aEntry)); MemoryPool& pool = Pool(aEntry->IsUsingDisk()); @@ -2018,100 +2014,6 @@ uint32_t CacheStorageService::CacheQueueSize(bool highPriority) return thread->QueueSize(highPriority); } -// Telementry collection - -namespace { - -bool TelemetryEntryKey(CacheEntry const* entry, nsAutoCString& key) -{ - nsAutoCString entryKey; - nsresult rv = entry->HashingKey(entryKey); - if (NS_FAILED(rv)) - return false; - - if (entry->GetStorageID().IsEmpty()) { - // Hopefully this will be const-copied, saves some memory - key = entryKey; - } else { - key.Assign(entry->GetStorageID()); - key.Append(':'); - key.Append(entryKey); - } - - return true; -} - -} // namespace - -void -CacheStorageService::TelemetryPrune(TimeStamp &now) -{ - static TimeDuration const oneMinute = TimeDuration::FromSeconds(60); - static TimeStamp dontPruneUntil = now + oneMinute; - if (now < dontPruneUntil) - return; - - static TimeDuration const fifteenMinutes = TimeDuration::FromSeconds(900); - for (auto iter = mPurgeTimeStamps.Iter(); !iter.Done(); iter.Next()) { - if (now - iter.Data() > fifteenMinutes) { - // We are not interested in resurrection of entries after 15 minutes - // of time. This is also the limit for the telemetry. - iter.Remove(); - } - } - dontPruneUntil = now + oneMinute; -} - -void -CacheStorageService::TelemetryRecordEntryCreation(CacheEntry const* entry) -{ - MOZ_ASSERT(CacheStorageService::IsOnManagementThread()); - - nsAutoCString key; - if (!TelemetryEntryKey(entry, key)) - return; - - TimeStamp now = TimeStamp::NowLoRes(); - TelemetryPrune(now); - - // When an entry is craeted (registered actually) we check if there is - // a timestamp marked when this very same cache entry has been removed - // (deregistered) because of over-memory-limit purging. If there is such - // a timestamp found accumulate telemetry on how long the entry was away. - TimeStamp timeStamp; - if (!mPurgeTimeStamps.Get(key, &timeStamp)) - return; - - mPurgeTimeStamps.Remove(key); - -} - -void -CacheStorageService::TelemetryRecordEntryRemoval(CacheEntry const* entry) -{ - MOZ_ASSERT(CacheStorageService::IsOnManagementThread()); - - // Doomed entries must not be considered, we are only interested in purged - // entries. Note that the mIsDoomed flag is always set before deregistration - // happens. - if (entry->IsDoomed()) - return; - - nsAutoCString key; - if (!TelemetryEntryKey(entry, key)) - return; - - // When an entry is removed (deregistered actually) we put a timestamp for this - // entry to the hashtable so that when the entry is created (registered) again - // we know how long it was away. Also accumulate number of AsyncOpen calls on - // the entry, this tells us how efficiently the pool actually works. - - TimeStamp now = TimeStamp::NowLoRes(); - TelemetryPrune(now); - mPurgeTimeStamps.Put(key, now); - -} - // nsIMemoryReporter size_t diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index f40459d84..7e968e359 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -188,12 +188,6 @@ private: bool IsForcedValidEntry(nsACString const &aEntryKeyWithContext); private: - // These are helpers for telemetry monitoring of the memory pools. - void TelemetryPrune(TimeStamp &now); - void TelemetryRecordEntryCreation(CacheEntry const* entry); - void TelemetryRecordEntryRemoval(CacheEntry const* entry); - -private: // Following methods are thread safe to call. friend class CacheStorage; @@ -370,12 +364,6 @@ private: uint32_t mWhat; }; - // Used just for telemetry purposes, accessed only on the management thread. - // Note: not included in the memory reporter, this is not expected to be huge - // and also would be complicated to report since reporting happens on the main - // thread but this table is manipulated on the management thread. - nsDataHashtable<nsCStringHashKey, mozilla::TimeStamp> mPurgeTimeStamps; - // nsICacheTesting class IOThreadSuspender : public Runnable { diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 7bc5abcd1..6740f7310 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -49,7 +49,6 @@ #include "mozilla/storage.h" #include "mozilla/AutoRestore.h" #include "mozilla/FileUtils.h" -#include "mozilla/Telemetry.h" #include "nsIAppsService.h" #include "mozIApplication.h" #include "mozIApplicationClearPrivateDataParams.h" @@ -120,15 +119,6 @@ static const char kPrefCookiePurgeAge[] = "network.cookie.purgeAge"; static const char kPrefThirdPartySession[] = "network.cookie.thirdparty.sessionOnly"; static const char kCookieLeaveSecurityAlone[] = "network.cookie.leave-secure-alone"; -// For telemetry COOKIE_LEAVE_SECURE_ALONE -#define BLOCKED_SECURE_SET_FROM_HTTP 0 -#define BLOCKED_DOWNGRADE_SECURE 1 -#define DOWNGRADE_SECURE_FROM_SECURE 2 -#define EVICTED_NEWER_INSECURE 3 -#define EVICTED_OLDEST_COOKIE 4 -#define EVICTED_PREFERRED_COOKIE 5 -#define EVICTING_SECURE_BLOCKED 6 - static void bindCookieParameters(mozIStorageBindingParamsArray *aParamsArray, const nsCookieKey &aKey, @@ -3592,9 +3582,6 @@ nsCookieService::AddInternal(const nsCookieKey &aKey, MOZ_ASSERT(iter.entry); oldCookie = iter.Cookie(); - if (oldestCookieTime > 0 && mLeaveSecureAlone) { - TelemetryForEvictingStaleCookie(oldCookie, oldestCookieTime); - } // remove the oldest cookie from the domain RemoveCookieFromList(iter); @@ -4619,13 +4606,6 @@ nsCookieService::FindStaleCookie(nsCookieEntry *aEntry, return actualOldestCookieTime; } -void -nsCookieService::TelemetryForEvictingStaleCookie(nsCookie *aEvicted, - int64_t oldestCookieTime) -{ - /* STUB */ -} - // count the number of cookies stored by a particular host. this is provided by the // nsICookieManager2 interface. NS_IMETHODIMP diff --git a/netwerk/cookie/nsCookieService.h b/netwerk/cookie/nsCookieService.h index e3b2d3e8a..185f0b492 100644 --- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -314,7 +314,6 @@ class nsCookieService final : public nsICookieService bool FindCookie(const nsCookieKey& aKey, const nsAFlatCString &aHost, const nsAFlatCString &aName, const nsAFlatCString &aPath, nsListIter &aIter); bool FindSecureCookie(const nsCookieKey& aKey, nsCookie* aCookie); int64_t FindStaleCookie(nsCookieEntry *aEntry, int64_t aCurrentTime, nsIURI* aSource, mozilla::Maybe<bool> aIsSecure, nsListIter &aIter); - void TelemetryForEvictingStaleCookie(nsCookie* aEvicted, int64_t oldestCookieTime); void NotifyRejected(nsIURI *aHostURI); void NotifyThirdParty(nsIURI *aHostURI, bool aAccepted, nsIChannel *aChannel); void NotifyChanged(nsISupports *aSubject, const char16_t *aData); diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index c4883ab29..323470c34 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -32,7 +32,6 @@ #include "mozilla/HashFunctions.h" #include "mozilla/TimeStamp.h" -#include "mozilla/Telemetry.h" #include "mozilla/DebugOnly.h" #include "mozilla/Preferences.h" @@ -1419,7 +1418,6 @@ nsHostResolver::ThreadFunc(void *arg) LOG(("DNS lookup thread - Calling getaddrinfo for host [%s%s%s].\n", LOG_HOST(rec->host, rec->netInterface))); - TimeStamp startTime = TimeStamp::Now(); #if TTL_AVAILABLE bool getTtl = rec->mGetTtl; #else diff --git a/netwerk/mime/nsMimeTypes.h b/netwerk/mime/nsMimeTypes.h index 215d20507..57a85e9bc 100644 --- a/netwerk/mime/nsMimeTypes.h +++ b/netwerk/mime/nsMimeTypes.h @@ -107,6 +107,9 @@ #define IMAGE_TIFF "image/tiff" #define IMAGE_BMP "image/bmp" #define IMAGE_BMP_MS "image/x-ms-bmp" +// This is used internally to represent Windows clipboard BMPs which remove +// part of the header. +#define IMAGE_BMP_MS_CLIPBOARD "image/x-ms-clipboard-bmp" #define IMAGE_ICO "image/x-icon" #define IMAGE_ICO_MS "image/vnd.microsoft.icon" #define IMAGE_ICON_MS "image/icon" diff --git a/netwerk/protocol/http/AlternateServices.cpp b/netwerk/protocol/http/AlternateServices.cpp index b3e6babe3..ee2fa9331 100644 --- a/netwerk/protocol/http/AlternateServices.cpp +++ b/netwerk/protocol/http/AlternateServices.cpp @@ -654,8 +654,13 @@ private: { nsID channelId; nsLoadFlags flags; + + nsContentPolicyType contentPolicyType = + loadInfo ? loadInfo->GetExternalContentPolicyType() + : nsIContentPolicy::TYPE_OTHER; + if (NS_FAILED(gHttpHandler->NewChannelId(&channelId)) || - NS_FAILED(chan->Init(uri, caps, nullptr, 0, nullptr, channelId)) || + NS_FAILED(chan->Init(uri, caps, nullptr, 0, nullptr, channelId, contentPolicyType)) || NS_FAILED(chan->SetAllowAltSvc(false)) || NS_FAILED(chan->SetRedirectMode(nsIHttpChannelInternal::REDIRECT_MODE_ERROR)) || NS_FAILED(chan->SetLoadInfo(loadInfo)) || diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 3471985dd..581ebe016 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -657,12 +657,6 @@ Http2Stream::GenerateOpen() outputOffset += frameLen; } - // The size of the input headers is approximate - uint32_t ratio = - compressedData.Length() * 100 / - (11 + requestURI.Length() + - mFlatHttpRequestHeaders.Length()); - mFlatHttpRequestHeaders.Truncate(); return NS_OK; } @@ -980,7 +974,7 @@ Http2Stream::GenerateDataFrameHeader(uint32_t dataLength, bool lastFrame) } // ConvertResponseHeaders is used to convert the response headers -// into HTTP/1 format and report some telemetry +// into HTTP/1 format nsresult Http2Stream::ConvertResponseHeaders(Http2Decompressor *decompressor, nsACString &aHeadersIn, @@ -1036,7 +1030,7 @@ Http2Stream::ConvertResponseHeaders(Http2Decompressor *decompressor, } // ConvertPushHeaders is used to convert the pushed request headers -// into HTTP/1 format and report some telemetry +// into HTTP/1 format nsresult Http2Stream::ConvertPushHeaders(Http2Decompressor *decompressor, nsACString &aHeadersIn, diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 21b661c2b..86e177e71 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -151,7 +151,8 @@ HttpBaseChannel::Init(nsIURI *aURI, nsProxyInfo *aProxyInfo, uint32_t aProxyResolveFlags, nsIURI *aProxyURI, - const nsID& aChannelId) + const nsID& aChannelId, + nsContentPolicyType aContentPolicyType) { LOG(("HttpBaseChannel::Init [this=%p]\n", this)); @@ -200,7 +201,7 @@ HttpBaseChannel::Init(nsIURI *aURI, rv = mRequestHead.SetHeader(nsHttp::Host, hostLine); if (NS_FAILED(rv)) return rv; - rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, isHTTPS); + rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, isHTTPS, aContentPolicyType); if (NS_FAILED(rv)) return rv; nsAutoCString type; @@ -996,16 +997,6 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, } LOG(("converter removed '%s' content-encoding\n", val)); - if (gHttpHandler->IsTelemetryEnabled()) { - int mode = 0; - if (from.Equals("gzip") || from.Equals("x-gzip")) { - mode = 1; - } else if (from.Equals("deflate") || from.Equals("x-deflate")) { - mode = 2; - } else if (from.Equals("br")) { - mode = 3; - } - } nextListener = converter; } else { diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 9aa696a70..8def0f23c 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -99,7 +99,8 @@ public: virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo, uint32_t aProxyResolveFlags, nsIURI *aProxyURI, - const nsID& aChannelId); + const nsID& aChannelId, + nsContentPolicyType aContentPolicyType); // nsIRequest NS_IMETHOD GetName(nsACString& aName) override; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index be5539a02..481df5ff0 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -83,7 +83,6 @@ #include "nsCRT.h" #include "CacheObserver.h" #include "mozilla/dom/Performance.h" -#include "mozilla/Telemetry.h" #include "AlternateServices.h" #include "InterceptedChannel.h" #include "nsIHttpPushListener.h" @@ -123,19 +122,6 @@ static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID); static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID); -enum CacheDisposition { - kCacheHit = 1, - kCacheHitViaReval = 2, - kCacheMissedViaReval = 3, - kCacheMissed = 4 -}; - -void -AccumulateCacheHitTelemetry(CacheDisposition hitOrMiss) -{ - /* STUB */ -} - // Computes and returns a SHA1 hash of the input buffer. The input buffer // must be a null-terminated string. nsresult @@ -338,10 +324,16 @@ nsHttpChannel::Init(nsIURI *uri, nsProxyInfo *proxyInfo, uint32_t proxyResolveFlags, nsIURI *proxyURI, - const nsID& channelId) -{ - nsresult rv = HttpBaseChannel::Init(uri, caps, proxyInfo, - proxyResolveFlags, proxyURI, channelId); + const nsID& channelId, + nsContentPolicyType aContentPolicyType) +{ + nsresult rv = HttpBaseChannel::Init(uri, + caps, + proxyInfo, + proxyResolveFlags, + proxyURI, + channelId, + aContentPolicyType); if (NS_FAILED(rv)) return rv; @@ -494,11 +486,6 @@ nsHttpChannel::ContinueConnect() event->Revoke(); } - // Don't accumulate the cache hit telemetry for intercepted channels. - if (mInterceptCache != INTERCEPTED) { - AccumulateCacheHitTelemetry(kCacheHit); - } - return rv; } else if (mLoadFlags & LOAD_ONLY_FROM_CACHE) { @@ -1085,10 +1072,8 @@ ProcessXCTO(nsIURI* aURI, nsHttpResponseHead* aResponseHead, nsILoadInfo* aLoadI if (aLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_IMAGE) { if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("image/"))) { - Accumulate(Telemetry::XCTO_NOSNIFF_BLOCK_IMAGE, 0); return NS_OK; } - Accumulate(Telemetry::XCTO_NOSNIFF_BLOCK_IMAGE, 1); // Instead of consulting Preferences::GetBool() all the time we // can cache the result to speed things up. static bool sXCTONosniffBlockImages = false; @@ -2116,29 +2101,6 @@ nsHttpChannel::ContinueProcessResponse2(nsresult rv) break; } - if (gHttpHandler->IsTelemetryEnabled()) { - CacheDisposition cacheDisposition; - if (!mDidReval) { - cacheDisposition = kCacheMissed; - } else if (successfulReval) { - cacheDisposition = kCacheHitViaReval; - } else { - cacheDisposition = kCacheMissedViaReval; - } - AccumulateCacheHitTelemetry(cacheDisposition); - - if (mResponseHead->Version() == NS_HTTP_VERSION_0_9) { - // DefaultPortTopLevel = 0, DefaultPortSubResource = 1, - // NonDefaultPortTopLevel = 2, NonDefaultPortSubResource = 3 - uint32_t v09Info = 0; - if (!(mLoadFlags & LOAD_INITIAL_DOCUMENT_URI)) { - v09Info += 1; - } - if (mConnectionInfo->OriginPort() != mConnectionInfo->DefaultPort()) { - v09Info += 2; - } - } - } return rv; } @@ -3784,8 +3746,6 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC (!mCachedResponseHead->ExpiresInPast() || !mCachedResponseHead->MustValidateIfExpired())) { LOG(("NOT validating based on isForcedValid being true.\n")); - Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PREFETCHES_USED> used; - ++used; doValidation = false; } // If the LOAD_FROM_CACHE flag is set, any cached data can simply be used @@ -6546,8 +6506,6 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st if (mTimingEnabled && request == mCachePump) { mCacheReadEnd = TimeStamp::Now(); - - ReportNetVSCacheTelemetry(); } // allow content to be cached if it was loaded successfully (bug #482935) @@ -8104,12 +8062,5 @@ nsHttpChannel::SetDoNotTrack() } } - -void -nsHttpChannel::ReportNetVSCacheTelemetry() -{ - /* STUB */ -} - } // namespace net } // namespace mozilla diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 152cf1503..0038e1f71 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -123,7 +123,8 @@ public: virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo, uint32_t aProxyResolveFlags, nsIURI *aProxyURI, - const nsID& aChannelId) override; + const nsID& aChannelId, + nsContentPolicyType aContentPolicyType) override; nsresult OnPush(const nsACString &uri, Http2PushedStream *pushedStream); @@ -431,9 +432,6 @@ private: rv == NS_ERROR_MALFORMED_URI; } - // Report net vs cache time telemetry - void ReportNetVSCacheTelemetry(); - // Create a aggregate set of the current notification callbacks // and ensure the transaction is updated to use it. void UpdateAggregateCallbacks(); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 731cdff39..907f33436 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -35,8 +35,6 @@ #include "mozilla/Unused.h" #include "nsIURI.h" -#include "mozilla/Telemetry.h" - namespace mozilla { namespace net { @@ -1186,14 +1184,6 @@ nsHttpConnectionMgr::MakeNewConnection(nsConnectionEntry *ent, transport->SetConnectionFlags(flags); } - Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_USED_SPECULATIVE_CONN> usedSpeculativeConn; - ++usedSpeculativeConn; - - if (ent->mHalfOpens[i]->IsFromPredictor()) { - Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS_USED> totalPreconnectsUsed; - ++totalPreconnectsUsed; - } - // return OK because we have essentially opened a new connection // by converting a speculative half-open to general use return NS_OK; @@ -1387,14 +1377,6 @@ nsHttpConnectionMgr::AddToShortestPipeline(nsConnectionEntry *ent, ent->SetYellowConnection(bestConn); if (!trans->GetPendingTime().IsNull()) { - if (trans->UsesPipelining()) - AccumulateTimeDelta( - Telemetry::TRANSACTION_WAIT_TIME_HTTP_PIPELINES, - trans->GetPendingTime(), TimeStamp::Now()); - else - AccumulateTimeDelta( - Telemetry::TRANSACTION_WAIT_TIME_HTTP, - trans->GetPendingTime(), TimeStamp::Now()); trans->SetPendingTime(false); } return true; @@ -1677,8 +1659,6 @@ nsHttpConnectionMgr::DispatchTransaction(nsConnectionEntry *ent, rv = conn->Activate(trans, caps, priority); MOZ_ASSERT(NS_SUCCEEDED(rv), "SPDY Cannot Fail Dispatch"); if (NS_SUCCEEDED(rv) && !trans->GetPendingTime().IsNull()) { - AccumulateTimeDelta(Telemetry::TRANSACTION_WAIT_TIME_SPDY, - trans->GetPendingTime(), TimeStamp::Now()); trans->SetPendingTime(false); } return rv; @@ -1695,12 +1675,6 @@ nsHttpConnectionMgr::DispatchTransaction(nsConnectionEntry *ent, rv = DispatchAbstractTransaction(ent, trans, caps, conn, priority); if (NS_SUCCEEDED(rv) && !trans->GetPendingTime().IsNull()) { - if (trans->UsesPipelining()) - AccumulateTimeDelta(Telemetry::TRANSACTION_WAIT_TIME_HTTP_PIPELINES, - trans->GetPendingTime(), TimeStamp::Now()); - else - AccumulateTimeDelta(Telemetry::TRANSACTION_WAIT_TIME_HTTP, - trans->GetPendingTime(), TimeStamp::Now()); trans->SetPendingTime(false); } return rv; @@ -1829,12 +1803,6 @@ nsHttpConnectionMgr::BuildPipeline(nsConnectionEntry *ent, return NS_OK; } -void -nsHttpConnectionMgr::ReportProxyTelemetry(nsConnectionEntry *ent) -{ - /* STUB */ -} - nsresult nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans) { @@ -1878,8 +1846,6 @@ nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans) ent = preferredEntry; } - ReportProxyTelemetry(ent); - // Check if the transaction already has a sticky reference to a connection. // If so, then we can just use it directly by transferring its reference // to the new connection variable instead of searching for a new one @@ -1976,13 +1942,9 @@ nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent, if (speculative) { sock->SetSpeculative(true); sock->SetAllow1918(allow1918); - Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_TOTAL_SPECULATIVE_CONN> totalSpeculativeConn; - ++totalSpeculativeConn; if (isFromPredictor) { sock->SetIsFromPredictor(true); - Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS_CREATED> totalPreconnectsCreated; - ++totalPreconnectsCreated; } } @@ -3894,16 +3856,6 @@ nsConnectionEntry::RemoveHalfOpen(nsHalfOpenSocket *halfOpen) // will result in it not being present in the halfopen table. That's expected. if (mHalfOpens.RemoveElement(halfOpen)) { - if (halfOpen->IsSpeculative()) { - Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_UNUSED_SPECULATIVE_CONN> unusedSpeculativeConn; - ++unusedSpeculativeConn; - - if (halfOpen->IsFromPredictor()) { - Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS_UNUSED> totalPreconnectsUnused; - ++totalPreconnectsUnused; - } - } - MOZ_ASSERT(gHttpHandler->ConnMgr()->mNumHalfOpenConns); if (gHttpHandler->ConnMgr()->mNumHalfOpenConns) { // just in case gHttpHandler->ConnMgr()->mNumHalfOpenConns--; diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index 7ca2a2b28..a2c88c402 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -529,7 +529,6 @@ private: nsresult ProcessNewTransaction(nsHttpTransaction *); nsresult EnsureSocketThreadTarget(); void ClosePersistentConnections(nsConnectionEntry *ent); - void ReportProxyTelemetry(nsConnectionEntry *ent); nsresult CreateTransport(nsConnectionEntry *, nsAHttpTransaction *, uint32_t, bool, bool, bool); void AddActiveConn(nsHttpConnection *, nsConnectionEntry *); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 6d58a7004..0f4c94202 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -90,7 +90,6 @@ #define BROWSER_PREF_PREFIX "browser.cache." #define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled" #define H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" -#define TELEMETRY_ENABLED "toolkit.telemetry.enabled" #define ALLOW_EXPERIMENTS "network.allow-experiments" #define SAFE_HINT_HEADER_VALUE "safeHint.enabled" #define SECURITY_PREFIX "security." @@ -209,7 +208,6 @@ nsHttpHandler::nsHttpHandler() , mSafeHintEnabled(false) , mParentalControlEnabled(false) , mHandlerActive(false) - , mTelemetryEnabled(false) , mAllowExperiments(true) , mDebugObservations(false) , mEnableSpdy(false) @@ -305,7 +303,6 @@ nsHttpHandler::Init() prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true); prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true); prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true); - prefBranch->AddObserver(TELEMETRY_ENABLED, this, true); prefBranch->AddObserver(H2MANDATORY_SUITE, this, true); prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true); prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true); @@ -471,7 +468,9 @@ nsHttpHandler::InitConnectionMgr() } nsresult -nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, bool isSecure) +nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, + bool isSecure, + nsContentPolicyType aContentPolicyType) { nsresult rv; @@ -484,7 +483,20 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, bool isSecu // Add the "Accept" header. Note, this is set as an override because the // service worker expects to see it. The other "default" headers are // hidden from service worker interception. - rv = request->SetHeader(nsHttp::Accept, mAccept, + nsAutoCString accept; + if (aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT || + aContentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT) { + accept.Assign(mAcceptNavigation); + } else if (aContentPolicyType == nsIContentPolicy::TYPE_IMAGE || + aContentPolicyType == nsIContentPolicy::TYPE_IMAGESET) { + accept.Assign(mAcceptImage); + } else if (aContentPolicyType == nsIContentPolicy::TYPE_STYLESHEET) { + accept.Assign(mAcceptStyle); + } else { + accept.Assign(mAcceptDefault); + } + + rv = request->SetHeader(nsHttp::Accept, accept, false, nsHttpHeaderArray::eVarietyRequestOverride); if (NS_FAILED(rv)) return rv; @@ -1271,12 +1283,36 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) mQoSBits = (uint8_t) clamped(val, 0, 0xff); } + if (PREF_CHANGED(HTTP_PREF("accept.navigation"))) { + nsXPIDLCString accept; + rv = prefs->GetCharPref(HTTP_PREF("accept.navigation"), + getter_Copies(accept)); + if (NS_SUCCEEDED(rv)) + SetAccept(accept, ACCEPT_NAVIGATION); + } + + if (PREF_CHANGED(HTTP_PREF("accept.image"))) { + nsXPIDLCString accept; + rv = prefs->GetCharPref(HTTP_PREF("accept.image"), + getter_Copies(accept)); + if (NS_SUCCEEDED(rv)) + SetAccept(accept, ACCEPT_IMAGE); + } + + if (PREF_CHANGED(HTTP_PREF("accept.style"))) { + nsXPIDLCString accept; + rv = prefs->GetCharPref(HTTP_PREF("accept.style"), + getter_Copies(accept)); + if (NS_SUCCEEDED(rv)) + SetAccept(accept, ACCEPT_STYLE); + } + if (PREF_CHANGED(HTTP_PREF("accept.default"))) { nsXPIDLCString accept; rv = prefs->GetCharPref(HTTP_PREF("accept.default"), getter_Copies(accept)); if (NS_SUCCEEDED(rv)) - SetAccept(accept); + SetAccept(accept, ACCEPT_DEFAULT); } if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) { @@ -1547,19 +1583,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) // includes telemetry and allow-experiments because of the abtest profile bool requestTokenBucketUpdated = false; - // - // Telemetry - // - - if (PREF_CHANGED(TELEMETRY_ENABLED)) { - cVar = false; - requestTokenBucketUpdated = true; - rv = prefs->GetBoolPref(TELEMETRY_ENABLED, &cVar); - if (NS_SUCCEEDED(rv)) { - mTelemetryEnabled = cVar; - } - } - // "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" is the required h2 interop // suite. @@ -1913,9 +1936,21 @@ nsHttpHandler::SetAcceptLanguages() } nsresult -nsHttpHandler::SetAccept(const char *aAccept) +nsHttpHandler::SetAccept(const char *aAccept, AcceptType aType) { - mAccept = aAccept; + switch (aType) { + case ACCEPT_NAVIGATION: + mAcceptNavigation = aAccept; + break; + case ACCEPT_IMAGE: + mAcceptImage = aAccept; + break; + case ACCEPT_STYLE: + mAcceptStyle = aAccept; + break; + case ACCEPT_DEFAULT: + mAcceptDefault = aAccept; + } return NS_OK; } @@ -2073,7 +2108,11 @@ nsHttpHandler::NewProxiedChannel2(nsIURI *uri, rv = NewChannelId(&channelId); NS_ENSURE_SUCCESS(rv, rv); - rv = httpChannel->Init(uri, caps, proxyInfo, proxyResolveFlags, proxyURI, channelId); + nsContentPolicyType contentPolicyType = + aLoadInfo ? aLoadInfo->GetExternalContentPolicyType() + : nsIContentPolicy::TYPE_OTHER; + + rv = httpChannel->Init(uri, caps, proxyInfo, proxyResolveFlags, proxyURI, channelId, contentPolicyType); if (NS_FAILED(rv)) return rv; diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 848dd25b1..67b9ebe0e 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -15,6 +15,7 @@ #include "nsCOMPtr.h" #include "nsWeakReference.h" +#include "nsIContentPolicy.h" #include "nsIHttpProtocolHandler.h" #include "nsIObserver.h" #include "nsISpeculativeConnect.h" @@ -50,6 +51,14 @@ enum FrameCheckLevel { FRAMECHECK_STRICT }; +// Fetch spec different http Accept types +enum AcceptType { + ACCEPT_NAVIGATION, + ACCEPT_IMAGE, + ACCEPT_STYLE, + ACCEPT_DEFAULT, +}; + //----------------------------------------------------------------------------- // nsHttpHandler - protocol handler for HTTP and HTTPS //----------------------------------------------------------------------------- @@ -70,7 +79,7 @@ public: nsHttpHandler(); nsresult Init(); - nsresult AddStandardRequestHeaders(nsHttpRequestHead *, bool isSecure); + nsresult AddStandardRequestHeaders(nsHttpRequestHead *, bool isSecure, nsContentPolicyType aContentPolicyType); nsresult AddConnectionHeader(nsHttpRequestHead *, uint32_t capabilities); bool IsAcceptableEncoding(const char *encoding, bool isSecure); @@ -105,8 +114,10 @@ public: bool EnforceAssocReq() { return mEnforceAssocReq; } bool IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; } - bool IsTelemetryEnabled() { return mTelemetryEnabled; } - bool AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; } + + // Since telemetry has been removed, experiments should also not be allowed. + // Making this function return `false` for now, it will be cleaned up later. + bool AllowExperiments() { return false; } bool IsSpdyEnabled() { return mEnableSpdy; } bool IsHttp2Enabled() { return mHttp2Enabled; } @@ -383,7 +394,7 @@ private: void InitUserAgentComponents(); void PrefsChanged(nsIPrefBranch *prefs, const char *pref); - nsresult SetAccept(const char *); + nsresult SetAccept(const char *, AcceptType aType); nsresult SetAcceptLanguages(); nsresult SetAcceptEncodings(const char *, bool mIsSecure); @@ -392,8 +403,8 @@ private: void NotifyObservers(nsIHttpChannel *chan, const char *event); static void TimerCallback(nsITimer * aTimer, void * aClosure); + private: - // cached services nsMainThreadPtrHandle<nsIIOService> mIOService; nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc; @@ -458,7 +469,10 @@ private: bool mPipeliningOverSSL; bool mEnforceAssocReq; - nsCString mAccept; + nsCString mAcceptNavigation; + nsCString mAcceptImage; + nsCString mAcceptStyle; + nsCString mAcceptDefault; nsCString mAcceptLanguages; nsCString mHttpAcceptEncodings; nsCString mHttpsAcceptEncodings; @@ -509,9 +523,6 @@ private: // true in between init and shutdown states Atomic<bool, Relaxed> mHandlerActive; - // Whether telemetry is reported or not - uint32_t mTelemetryEnabled : 1; - // The value of network.allow-experiments uint32_t mAllowExperiments : 1; diff --git a/netwerk/test/mochitests/mochitest.ini b/netwerk/test/mochitests/mochitest.ini index f8a919031..3cd5a674b 100644 --- a/netwerk/test/mochitests/mochitest.ini +++ b/netwerk/test/mochitests/mochitest.ini @@ -25,3 +25,5 @@ support-files = [test_viewsource_unlinkable.html] [test_xhr_method_case.html] [test_1396395.html] +[test_accept_header.html] +support-files = test_accept_header.sjs diff --git a/netwerk/test/mochitests/test_accept_header.html b/netwerk/test/mochitests/test_accept_header.html new file mode 100644 index 000000000..b8434230f --- /dev/null +++ b/netwerk/test/mochitests/test_accept_header.html @@ -0,0 +1,106 @@ +<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Accept header</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script>
+
+// All the requests are sent to test_accept_header.sjs which will return
+// different content based on the queryString. When the queryString is 'get',
+// test_accept_header.sjs returns a JSON object with the latest request and its
+// accept header value.
+
+function test_last_request_and_continue(query, expected) {
+ fetch("test_accept_header.sjs?get").then(r => r.json()).then(json => {
+ is(json.type, query, "Expected: " + query);
+ is(json.accept, expected, "Accept header: " + expected);
+ next();
+ });
+}
+
+function test_iframe() {
+ let observer = new PerformanceObserver(function(list, obj) {
+ obj.disconnect();
+
+ list.getEntries().forEach(entry => {
+ if (entry.name.endsWith("test_accept_header.sjs?iframe")) {
+ obj.disconnect();
+ test_last_request_and_continue("iframe", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+ }
+ });
+ });
+
+ observer.observe({entryTypes: ["resource"]});
+
+ let ifr = document.createElement("iframe");
+ ifr.src = "test_accept_header.sjs?iframe";
+ document.body.appendChild(ifr);
+}
+
+function test_image() {
+ let i = new Image();
+ i.src = "test_accept_header.sjs?image";
+ i.onload = function() {
+ // Fetch spec says we should have: "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"
+ test_last_request_and_continue("image", "image/webp,image/png,image/*;q=0.8,*/*;q=0.5");
+ }
+}
+
+function test_style() {
+ let observer = new PerformanceObserver(function(list, obj) {
+ obj.disconnect();
+
+ list.getEntries().forEach(entry => {
+ if (entry.name.endsWith("test_accept_header.sjs?style")) {
+ obj.disconnect();
+ test_last_request_and_continue("style", "text/css,*/*;q=0.1");
+ }
+ });
+ });
+
+ observer.observe({entryTypes: ["resource"]});
+
+ let head = document.getElementsByTagName("head")[0];
+ let link = document.createElement("link");
+ link.rel = "stylesheet";
+ link.type = "text/css";
+ link.href = "test_accept_header.sjs?style";
+ head.appendChild(link);
+}
+
+function test_worker() {
+ let w = new Worker("test_accept_header.sjs?worker");
+ w.onmessage = function() {
+ test_last_request_and_continue("worker", "*/*");
+ }
+}
+
+let tests = [
+ test_iframe,
+ test_image,
+ test_style,
+ test_worker,
+];
+
+function next() {
+ if (tests.length == 0) {
+ SimpleTest.finish();
+ return;
+ }
+
+ let test = tests.shift();
+ test();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv({ "set": [
+ [ "dom.enable_performance_observer", true ]
+]}, next);
+
+</script>
+</body>
+</html>
diff --git a/netwerk/test/mochitests/test_accept_header.sjs b/netwerk/test/mochitests/test_accept_header.sjs new file mode 100644 index 000000000..035c886aa --- /dev/null +++ b/netwerk/test/mochitests/test_accept_header.sjs @@ -0,0 +1,48 @@ +function handleRequest(request, response) {
+ response.setStatusLine(request.httpVersion, "200", "OK");
+
+ if (request.queryString == "worker") {
+ response.setHeader("Content-Type", "application/json", false);
+ response.write("postMessage(42)");
+
+ setState("data", JSON.stringify({type: "worker", accept: request.getHeader("Accept") }));
+ return;
+ }
+
+ if (request.queryString == "image") {
+ // A 1x1 PNG image.
+ // Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
+ const IMAGE = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
+ "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
+
+ response.setHeader("Content-Type", "image/png", false);
+ response.write(IMAGE);
+
+ setState("data", JSON.stringify({type: "image", accept: request.getHeader("Accept") }));
+ return;
+ }
+
+ if (request.queryString == "style") {
+ response.setHeader("Content-Type", "text/css", false);
+ response.write("");
+
+ setState("data", JSON.stringify({type: "style", accept: request.getHeader("Accept") }));
+ return;
+ }
+
+ if (request.queryString == "iframe") {
+ response.setHeader("Content-Type", "text/html", false);
+ response.write("<h1>Hello world!</h1>");
+
+ setState("data", JSON.stringify({type: "iframe", accept: request.getHeader("Accept") }));
+ return;
+ }
+
+ if (request.queryString == "get") {
+ response.setHeader("Content-Type", "text/javascript", false);
+ response.write(getState("data"));
+
+ setState("data", "");
+ return;
+ }
+}
|