diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 52f0ac840f3..639acea17cf 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -379,8 +379,6 @@ @BINPATH@/components/PeerConnection.js @BINPATH@/components/PeerConnection.manifest #endif -@BINPATH@/components/HttpDataUsage.manifest -@BINPATH@/components/HttpDataUsage.js @BINPATH@/components/SiteSpecificUserAgent.js @BINPATH@/components/SiteSpecificUserAgent.manifest @BINPATH@/components/storage-mozStorage.js diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index c2935b207dc..e95cece9559 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -559,9 +559,6 @@ @BINPATH@/components/PeerConnection.manifest #endif -@BINPATH@/components/HttpDataUsage.manifest -@BINPATH@/components/HttpDataUsage.js - @BINPATH@/chrome/marionette@JAREXT@ @BINPATH@/chrome/marionette.manifest @BINPATH@/components/MarionetteComponents.manifest diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index dbfd8346827..9a5b79bef5f 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -406,9 +406,6 @@ @BINPATH@/components/PeerConnection.manifest #endif -@BINPATH@/components/HttpDataUsage.manifest -@BINPATH@/components/HttpDataUsage.js - #ifdef MOZ_SERVICES_HEALTHREPORT @BINPATH@/components/HealthReportComponents.manifest @BINPATH@/components/HealthReportService.js diff --git a/netwerk/protocol/http/HttpDataUsage.js b/netwerk/protocol/http/HttpDataUsage.js deleted file mode 100644 index 39e06331bd1..00000000000 --- a/netwerk/protocol/http/HttpDataUsage.js +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- indent-tabs-mode: nil -*- */ -/* 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/. */ - -/* HTTPDATA_* telemetry producer - every 3 minutes of idle time we update a data file and report it - once a day. this avoids adding io to the shutdown path -*/ - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cr = Components.results; -const Cu = Components.utils; -const CC = Components.Constructor; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/NetUtil.jsm"); - -XPCOMUtils.defineLazyServiceGetter(this, "idleService", - "@mozilla.org/widget/idleservice;1", - "nsIIdleService"); -XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", - "resource://gre/modules/FileUtils.jsm"); - -const MB = 1000000; - -var gDataUsage; -function HttpDataUsage() {} -HttpDataUsage.prototype = { - classID: Components.ID("{6d72bfca-2747-4859-887f-6f06d4ce6787}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), - contractID: "@mozilla.org/network/HttpDataUsage;1", - - _isIdleObserver: false, - _locked : false, - _idle_timeout : 15, - _quanta : 86400000, // per day - - _logtime : new Date(), - _ethernetRead : 0, - _ethernetWritten : 0, - _cellRead : 0, - _cellWritten : 0, - - _dataFile : FileUtils.getFile("ProfD", ["httpDataUsage.dat"], true), - _dataUsage : Cc["@mozilla.org/network/protocol;1?name=http"] - .getService(Ci.nsIHttpProtocolHandler) - .QueryInterface(Ci.nsIHttpDataUsage), - _pipe : CC("@mozilla.org/pipe;1", "nsIPipe", "init"), - _outputStream : CC("@mozilla.org/network/file-output-stream;1", - "nsIFileOutputStream", "init"), - - setup: function setup() { - gDataUsage = this; - - var enabled = false; - try { - if (Services.prefs.getBoolPref("toolkit.telemetry.enabled")) - enabled = true; - } catch (e) { } - try { - if (Services.prefs.getBoolPref("toolkit.telemetry.enabledPreRelease")) - enabled = true; - } catch (e) { } - - // this isn't important enough to worry about getting a - // runtime telemetry config change for - if (!enabled) - return; - - if (this._dataUsage == null) - return; - - Services.obs.addObserver(this, "quit-application", false); - idleService.addIdleObserver(this, this._idle_timeout); - this._isIdleObserver = true; - }, - - shutdown: function shutdown() { - if (this._isIdleObserver) { - idleService.removeIdleObserver(this, this._idle_timeout); - Services.obs.removeObserver(this, "quit-application"); - } - this._isIdleObserver = false; - }, - - sUpdateStats2: function sUpdateStats2(stream, result) { - gDataUsage.updateStats2(stream, result); - }, - - readCounters: function readCounters(stream, result) { - if (Components.isSuccessCode(result)) { - let count = stream.available(); - let data = NetUtil.readInputStreamToString(stream, count); - var list = data.split(","); - if (list.length == 5) { - this._logtime = new Date(Number(list[0])); - this._ethernetRead = Number(list[1]); - this._ethernetWritten = Number(list[2]); - this._cellRead = Number(list[3]); - this._cellWritten = Number(list[4]); - } - } - - this._ethernetRead += this._dataUsage.ethernetBytesRead; - this._ethernetWritten += this._dataUsage.ethernetBytesWritten; - this._cellRead += this._dataUsage.cellBytesRead; - this._cellWritten += this._dataUsage.cellBytesWritten; - this._dataUsage.resetHttpDataUsage(); - }, - - writeCounters: function writeCounters() { - var dataout = this._logtime.getTime().toString() + "," + - this._ethernetRead.toString() + "," + - this._ethernetWritten.toString() + "," + - this._cellRead.toString() + "," + - this._cellWritten.toString() + "\n"; - - var buffer = new this._pipe(true, false, 4096, 1, null); - buffer.outputStream.write(dataout, dataout.length); - buffer.outputStream.close(); - var fileOut = new this._outputStream(this._dataFile, -1, -1, 0); - - NetUtil.asyncCopy(buffer.inputStream, fileOut, - function (result) { gDataUsage.finishedWriting(); }); - }, - - updateStats2: function updateStats2(stream, result) { - this.readCounters(stream, result); - this.submitTelemetry(); - }, - - submitTelemetry: function submitTelemetry() { - var now = new Date(); - var elapsed = now.getTime() - this._logtime.getTime(); - // make sure we have at least 1 day of data.. if not just write new data out - if (elapsed < this._quanta) { - this.writeCounters(); - return; - } - - var days = elapsed / this._quanta; - var eInPerQuanta = Math.floor(this._ethernetRead / days); - var eOutPerQuanta = Math.floor(this._ethernetWritten / days); - var cInPerQuanta = Math.floor(this._cellRead / days); - var cOutPerQuanta = Math.floor(this._cellWritten / days); - - var histogram; - - while (elapsed >= this._quanta) { - histogram = Services.telemetry.getHistogramById("HTTPDATA_DAILY_ETHERNET_IN"); - histogram.add(Math.round(eInPerQuanta / MB)); - histogram = Services.telemetry.getHistogramById("HTTPDATA_DAILY_ETHERNET_OUT"); - histogram.add(Math.round(eOutPerQuanta / MB)); - histogram = Services.telemetry.getHistogramById("HTTPDATA_DAILY_CELL_IN"); - histogram.add(Math.round(cInPerQuanta / MB)); - histogram = Services.telemetry.getHistogramById("HTTPDATA_DAILY_CELL_OUT"); - histogram.add(Math.round(cOutPerQuanta / MB)); - - elapsed -= this._quanta; - this._ethernetRead -= eInPerQuanta; - this._ethernetWritten -= eOutPerQuanta; - this._cellRead -= cInPerQuanta; - this._cellWritten -= cOutPerQuanta; - } - this._logtime = new Date(now.getTime() - elapsed); - - // need to write back the decremented counters - this.writeCounters(); - }, - - finishedWriting : function finishedWriting() { - this._locked = false; // all done - }, - - updateStats: function updateStats() { - if (this._locked) - return; - this._locked = true; - - NetUtil.asyncFetch(this._dataFile, this.sUpdateStats2); - }, - - observe: function (aSubject, aTopic, aData) { - switch (aTopic) { - case "profile-after-change": - this.setup(); - break; - case "idle": - this.updateStats(); - break; - case "quit-application": - this.updateStats(); - this.shutdown(); - break; - } - }, -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([HttpDataUsage]); diff --git a/netwerk/protocol/http/HttpDataUsage.manifest b/netwerk/protocol/http/HttpDataUsage.manifest deleted file mode 100644 index 4888f3fcf5d..00000000000 --- a/netwerk/protocol/http/HttpDataUsage.manifest +++ /dev/null @@ -1,3 +0,0 @@ -component {6d72bfca-2747-4859-887f-6f06d4ce6787} HttpDataUsage.js -contract @mozilla.org/network/HttpDataUsage;1 {6d72bfca-2747-4859-887f-6f06d4ce6787} -category profile-after-change HttpDataUsage @mozilla.org/network/HttpDataUsage;1 diff --git a/netwerk/protocol/http/moz.build b/netwerk/protocol/http/moz.build index f87ef4e24ad..a042bffd727 100644 --- a/netwerk/protocol/http/moz.build +++ b/netwerk/protocol/http/moz.build @@ -13,7 +13,6 @@ XPIDL_SOURCES += [ 'nsIHttpChannelAuthProvider.idl', 'nsIHttpChannelChild.idl', 'nsIHttpChannelInternal.idl', - 'nsIHttpDataUsage.idl', 'nsIHttpEventSink.idl', 'nsIHttpHeaderVisitor.idl', 'nsIHttpProtocolHandler.idl', @@ -94,11 +93,6 @@ EXTRA_JS_MODULES += [ 'UserAgentUpdates.jsm', ] -EXTRA_COMPONENTS += [ - 'HttpDataUsage.js', - 'HttpDataUsage.manifest', -] - FAIL_ON_WARNINGS = True MSVC_ENABLE_PGO = True diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 65d80dc8733..39cb19f584e 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -54,8 +54,6 @@ nsHttpConnection::nsHttpConnection() , mMaxBytesRead(0) , mTotalBytesRead(0) , mTotalBytesWritten(0) - , mUnreportedBytesRead(0) - , mUnreportedBytesWritten(0) , mKeepAlive(true) // assume to keep-alive by default , mKeepAliveMask(true) , mDontReuse(false) @@ -87,7 +85,6 @@ nsHttpConnection::~nsHttpConnection() { LOG(("Destroying nsHttpConnection @%x\n", this)); - ReportDataUsage(false); if (!mEverUsedSpdy) { LOG(("nsHttpConnection %p performed %d HTTP/1.x transactions\n", this, mHttp1xTransactionCount)); @@ -1276,8 +1273,6 @@ nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason) mCallbacks = nullptr; } - ReportDataUsage(false); - if (NS_FAILED(reason)) Close(reason); @@ -1320,11 +1315,8 @@ nsHttpConnection::OnReadSegment(const char *buf, else { mLastWriteTime = PR_IntervalNow(); mSocketOutCondition = NS_OK; // reset condition - if (!mProxyConnectInProgress) { + if (!mProxyConnectInProgress) mTotalBytesWritten += *countRead; - mUnreportedBytesWritten += *countRead; - ReportDataUsage(true); - } } return mSocketOutCondition; @@ -1545,8 +1537,6 @@ nsHttpConnection::OnSocketReadable() else { mCurrentBytesRead += n; mTotalBytesRead += n; - mUnreportedBytesRead += n; - ReportDataUsage(true); if (NS_FAILED(mSocketInCondition)) { // continue waiting for the socket if necessary... if (mSocketInCondition == NS_BASE_STREAM_WOULD_BLOCK) @@ -1611,27 +1601,6 @@ nsHttpConnection::SetupProxyConnect() return NS_NewCStringInputStream(getter_AddRefs(mProxyConnectStream), buf); } -void -nsHttpConnection::ReportDataUsage(bool allowDefer) -{ - static const uint64_t kDeferThreshold = 128000; - - if (!mUnreportedBytesRead && !mUnreportedBytesWritten) - return; - - if (!gHttpHandler->IsTelemetryEnabled()) - return; - - if (allowDefer && - (mUnreportedBytesRead + mUnreportedBytesWritten) < kDeferThreshold) { - return; - } - - gHttpHandler->UpdateDataUsage(mCallbacks, - mUnreportedBytesRead, mUnreportedBytesWritten); - mUnreportedBytesRead = mUnreportedBytesWritten = 0; -} - nsresult nsHttpConnection::StartShortLivedTCPKeepalives() { diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h index fb7c579734b..4c052da1e17 100644 --- a/netwerk/protocol/http/nsHttpConnection.h +++ b/netwerk/protocol/http/nsHttpConnection.h @@ -206,15 +206,13 @@ private: // Directly Add a transaction to an active connection for SPDY nsresult AddTransaction(nsAHttpTransaction *, int32_t); - // used to inform nsIHttpDataUsage of transfer - void ReportDataUsage(bool); - // Used to set TCP keepalives for fast detection of dead connections during // an initial period, and slower detection for long-lived connections. nsresult StartShortLivedTCPKeepalives(); nsresult StartLongLivedTCPKeepalives(); nsresult DisableTCPKeepalives(); +private: nsCOMPtr mSocketTransport; nsCOMPtr mSocketIn; nsCOMPtr mSocketOut; @@ -247,10 +245,6 @@ private: int64_t mTotalBytesRead; // total data read int64_t mTotalBytesWritten; // does not include CONNECT tunnel - // for nsIHttpDataUsage - uint64_t mUnreportedBytesRead; // subset of totalBytesRead - uint64_t mUnreportedBytesWritten; // subset of totalBytesWritten - nsRefPtr mInputOverflow; PRIntervalTime mRtt; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 76938e69c18..ec0929f84ea 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -62,10 +62,6 @@ #include "nsCocoaFeatures.h" #endif -#if defined(MOZ_WIDGET_GONK) -#include "nsINetworkManager.h" -#endif - //----------------------------------------------------------------------------- #include "mozilla/net/HttpChannelChild.h" @@ -201,18 +197,11 @@ nsHttpHandler::nsHttpHandler() , mRequestTokenBucketMinParallelism(6) , mRequestTokenBucketHz(100) , mRequestTokenBucketBurst(32) - , mCriticalRequestPrioritization(true) , mTCPKeepaliveShortLivedEnabled(false) , mTCPKeepaliveShortLivedTimeS(60) , mTCPKeepaliveShortLivedIdleTimeS(10) , mTCPKeepaliveLongLivedEnabled(false) , mTCPKeepaliveLongLivedIdleTimeS(600) - , mEthernetBytesRead(0) - , mEthernetBytesWritten(0) - , mCellBytesRead(0) - , mCellBytesWritten(0) - , mNetworkTypeKnown(false) - , mNetworkTypeWasEthernet(true) { #if defined(PR_LOGGING) gHttpLog = PR_NewLogModule("nsHttp"); @@ -1584,14 +1573,13 @@ nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings) // nsHttpHandler::nsISupports //----------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS7(nsHttpHandler, +NS_IMPL_ISUPPORTS6(nsHttpHandler, nsIHttpProtocolHandler, nsIProxiedProtocolHandler, nsIProtocolHandler, nsIObserver, nsISupportsWeakReference, - nsISpeculativeConnect, - nsIHttpDataUsage) + nsISpeculativeConnect) //----------------------------------------------------------------------------- // nsHttpHandler::nsIProtocolHandler @@ -1915,248 +1903,45 @@ nsHttpHandler::SpeculativeConnect(nsIURI *aURI, return SpeculativeConnect(ci, aCallbacks); } -// nsIHttpDataUsage - -NS_IMETHODIMP -nsHttpHandler::GetEthernetBytesRead(uint64_t *aEthernetBytesRead) -{ - MOZ_ASSERT(NS_IsMainThread()); - *aEthernetBytesRead = mEthernetBytesRead; - return NS_OK; -} - -NS_IMETHODIMP -nsHttpHandler::GetEthernetBytesWritten(uint64_t *aEthernetBytesWritten) -{ - MOZ_ASSERT(NS_IsMainThread()); - *aEthernetBytesWritten = mEthernetBytesWritten; - return NS_OK; -} - -NS_IMETHODIMP -nsHttpHandler::GetCellBytesRead(uint64_t *aCellBytesRead) -{ - MOZ_ASSERT(NS_IsMainThread()); - *aCellBytesRead = mCellBytesRead; - return NS_OK; -} - -NS_IMETHODIMP -nsHttpHandler::GetCellBytesWritten(uint64_t *aCellBytesWritten) -{ - MOZ_ASSERT(NS_IsMainThread()); - *aCellBytesWritten = mCellBytesWritten; - return NS_OK; -} - -NS_IMETHODIMP -nsHttpHandler::ResetHttpDataUsage() -{ - MOZ_ASSERT(NS_IsMainThread()); - mEthernetBytesRead = mEthernetBytesWritten = 0; - mCellBytesRead = mCellBytesWritten = 0; - return NS_OK; -} - -class DataUsageEvent : public nsRunnable -{ -public: - explicit DataUsageEvent(nsIInterfaceRequestor *cb, - uint64_t bytesRead, - uint64_t bytesWritten) - : mCB(cb), mRead(bytesRead), mWritten(bytesWritten) { } - - NS_IMETHOD Run() MOZ_OVERRIDE - { - MOZ_ASSERT(NS_IsMainThread()); - if (gHttpHandler) - gHttpHandler->UpdateDataUsage(mCB, mRead, mWritten); - return NS_OK; - } - -private: - ~DataUsageEvent() { } - nsCOMPtr mCB; - uint64_t mRead; - uint64_t mWritten; -}; - -void -nsHttpHandler::UpdateDataUsage(nsIInterfaceRequestor *cb, - uint64_t bytesRead, uint64_t bytesWritten) -{ - if (!IsTelemetryEnabled()) - return; - - if (!NS_IsMainThread()) { - nsRefPtr event = new DataUsageEvent(cb, bytesRead, bytesWritten); - NS_DispatchToMainThread(event); - return; - } - - bool isEthernet = true; - - if (NS_FAILED(GetNetworkEthernetInfo(cb, &isEthernet))) { - // without a window it is hard for android to determine the network type - // so on failures we will just use the last value - if (!mNetworkTypeKnown) - return; - isEthernet = mNetworkTypeWasEthernet; - } - - if (isEthernet) { - mEthernetBytesRead += bytesRead; - mEthernetBytesWritten += bytesWritten; - } else { - mCellBytesRead += bytesRead; - mCellBytesWritten += bytesWritten; - } -} - -nsresult -nsHttpHandler::GetNetworkEthernetInfo(nsIInterfaceRequestor *cb, - bool *aEthernet) -{ - NS_ENSURE_ARG_POINTER(aEthernet); - - nsresult rv = GetNetworkEthernetInfoInner(cb, aEthernet); - if (NS_SUCCEEDED(rv)) { - mNetworkTypeKnown = true; - mNetworkTypeWasEthernet = *aEthernet; - } - return rv; -} - -// aEthernet and aGateway are required out parameters -// on b2g and desktop gateway cannot be determined yet and -// this function returns ERROR_NOT_IMPLEMENTED. -nsresult -nsHttpHandler::GetNetworkInfo(nsIInterfaceRequestor *cb, - bool *aEthernet, - uint32_t *aGateway) -{ - NS_ENSURE_ARG_POINTER(aEthernet); - NS_ENSURE_ARG_POINTER(aGateway); - - nsresult rv = GetNetworkInfoInner(cb, aEthernet, aGateway); - if (NS_SUCCEEDED(rv)) { - mNetworkTypeKnown = true; - mNetworkTypeWasEthernet = *aEthernet; - } - return rv; -} - -nsresult -nsHttpHandler::GetNetworkInfoInner(nsIInterfaceRequestor *cb, - bool *aEthernet, - uint32_t *aGateway) -{ - NS_ENSURE_ARG_POINTER(aEthernet); - NS_ENSURE_ARG_POINTER(aGateway); - - *aGateway = 0; - *aEthernet = true; - -#if defined(MOZ_WIDGET_GONK) - // b2g only allows you to ask for ethernet or not right now. - return NS_ERROR_NOT_IMPLEMENTED; -#endif - -#if defined(ANDROID) - if (!cb) - return NS_ERROR_FAILURE; - - nsCOMPtr domWindow; - cb->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow)); - if (!domWindow) - return NS_ERROR_FAILURE; - - nsCOMPtr domNavigator; - domWindow->GetNavigator(getter_AddRefs(domNavigator)); - nsCOMPtr networkNavigator = - do_QueryInterface(domNavigator); - if (!networkNavigator) - return NS_ERROR_FAILURE; - - nsCOMPtr mozConnection; - networkNavigator->GetMozConnection(getter_AddRefs(mozConnection)); - nsCOMPtr networkProperties = - do_QueryInterface(mozConnection); - if (!networkProperties) - return NS_ERROR_FAILURE; - - nsresult rv; - rv = networkProperties->GetDhcpGateway(aGateway); - if (NS_FAILED(rv)) - return rv; - - return networkProperties->GetIsWifi(aEthernet); -#endif - - // desktop does not currently know about the gateway - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -nsHttpHandler::GetNetworkEthernetInfoInner(nsIInterfaceRequestor *cb, - bool *aEthernet) -{ - *aEthernet = true; - -#if defined(MOZ_WIDGET_GONK) - int32_t networkType; - nsCOMPtr networkManager = - do_GetService("@mozilla.org/network/manager;1"); - if (!networkManager) - return NS_ERROR_FAILURE; - if (NS_FAILED(networkManager->GetPreferredNetworkType(&networkType))) - return NS_ERROR_FAILURE; - *aEthernet = networkType == nsINetworkInterface::NETWORK_TYPE_WIFI; - return NS_OK; -#endif - -#if defined(ANDROID) - if (!cb) - return NS_ERROR_FAILURE; - - nsCOMPtr domWindow; - cb->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow)); - if (!domWindow) - return NS_ERROR_FAILURE; - - nsCOMPtr domNavigator; - domWindow->GetNavigator(getter_AddRefs(domNavigator)); - nsCOMPtr networkNavigator = - do_QueryInterface(domNavigator); - if (!networkNavigator) - return NS_ERROR_FAILURE; - - nsCOMPtr mozConnection; - networkNavigator->GetMozConnection(getter_AddRefs(mozConnection)); - nsCOMPtr networkProperties = - do_QueryInterface(mozConnection); - if (!networkProperties) - return NS_ERROR_FAILURE; - - return networkProperties->GetIsWifi(aEthernet); -#endif - - // desktop assumes never on cell data - *aEthernet = true; - return NS_OK; -} - void nsHttpHandler::TickleWifi(nsIInterfaceRequestor *cb) { if (!cb || !mWifiTickler) return; + // If B2G requires a similar mechanism nsINetworkManager, currently only avail + // on B2G, contains the necessary information on wifi and gateway + + nsCOMPtr domWindow; + cb->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow)); + if (!domWindow) + return; + + nsCOMPtr domNavigator; + domWindow->GetNavigator(getter_AddRefs(domNavigator)); + nsCOMPtr networkNavigator = + do_QueryInterface(domNavigator); + if (!networkNavigator) + return; + + nsCOMPtr mozConnection; + networkNavigator->GetMozConnection(getter_AddRefs(mozConnection)); + nsCOMPtr networkProperties = + do_QueryInterface(mozConnection); + if (!networkProperties) + return; + uint32_t gwAddress; bool isWifi; + nsresult rv; - nsresult rv = GetNetworkInfo(cb, &isWifi, &gwAddress); - if (NS_FAILED(rv) || !gwAddress || !isWifi) + rv = networkProperties->GetDhcpGateway(&gwAddress); + if (NS_SUCCEEDED(rv)) + rv = networkProperties->GetIsWifi(&isWifi); + if (NS_FAILED(rv)) + return; + + if (!gwAddress || !isWifi) return; mWifiTickler->SetIPV4Address(gwAddress); diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index da7a7ebcb71..4586b9e8a1c 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -15,7 +15,6 @@ #include "nsCOMPtr.h" #include "nsWeakReference.h" -#include "nsIHttpDataUsage.h" #include "nsIHttpProtocolHandler.h" #include "nsIObserver.h" #include "nsISpeculativeConnect.h" @@ -48,7 +47,6 @@ class nsHttpHandler : public nsIHttpProtocolHandler , public nsIObserver , public nsSupportsWeakReference , public nsISpeculativeConnect - , public nsIHttpDataUsage { public: NS_DECL_THREADSAFE_ISUPPORTS @@ -57,7 +55,6 @@ public: NS_DECL_NSIHTTPPROTOCOLHANDLER NS_DECL_NSIOBSERVER NS_DECL_NSISPECULATIVECONNECT - NS_DECL_NSIHTTPDATAUSAGE nsHttpHandler(); virtual ~nsHttpHandler(); @@ -528,30 +525,8 @@ public: } private: - // for nsIHttpDataUsage - uint64_t mEthernetBytesRead; - uint64_t mEthernetBytesWritten; - uint64_t mCellBytesRead; - uint64_t mCellBytesWritten; - bool mNetworkTypeKnown; - bool mNetworkTypeWasEthernet; - nsRefPtr mWifiTickler; - nsresult GetNetworkEthernetInfo(nsIInterfaceRequestor *cb, - bool *ethernet); - nsresult GetNetworkEthernetInfoInner(nsIInterfaceRequestor *cb, - bool *ethernet); - nsresult GetNetworkInfo(nsIInterfaceRequestor *cb, - bool *ethernet, uint32_t *gw); - nsresult GetNetworkInfoInner(nsIInterfaceRequestor *cb, - bool *ethernet, uint32_t *gw); void TickleWifi(nsIInterfaceRequestor *cb); - -public: - // this is called to update the member variables used for nsIHttpDataUsage - // it can be called from any thread - void UpdateDataUsage(nsIInterfaceRequestor *cb, - uint64_t bytesRead, uint64_t bytesWritten); }; extern nsHttpHandler *gHttpHandler; diff --git a/netwerk/protocol/http/nsIHttpDataUsage.idl b/netwerk/protocol/http/nsIHttpDataUsage.idl deleted file mode 100644 index ecbb52976c9..00000000000 --- a/netwerk/protocol/http/nsIHttpDataUsage.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* 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 "nsISupports.idl" - -/** - * nsIHttpDataUsage contains counters for the amount of HTTP data transferred - * in and out of this session since the last time it was reset with the - * resetHttpDataUsage() method. These counters are normally reset on each - * telemetry ping. - * - * Data is split into ethernet and cell. ethernet includes wifi. - * - */ - -[scriptable, uuid(79dee3eb-9323-4d5c-b0a8-1baa18934d9e)] -interface nsIHttpDataUsage : nsISupports -{ - readonly attribute unsigned long long ethernetBytesRead; - readonly attribute unsigned long long ethernetBytesWritten; - readonly attribute unsigned long long cellBytesRead; - readonly attribute unsigned long long cellBytesWritten; - - void resetHttpDataUsage(); -}; diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 62d26fe7d37..6760697710c 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1140,38 +1140,6 @@ "kind": "boolean", "description": "Whether a HTTP base page load was over SSL or not." }, - "HTTPDATA_DAILY_ETHERNET_IN": { - "expires_in_version": "never", - "kind": "exponential", - "high": "10000", - "n_buckets": 200, - "extended_statistics_ok": true, - "description": "MB of http ethernet data recvd in one day" - }, - "HTTPDATA_DAILY_ETHERNET_OUT": { - "expires_in_version": "never", - "kind": "exponential", - "high": "10000", - "n_buckets": 200, - "extended_statistics_ok": true, - "description": "MB of http ethernet data sent in one day" - }, - "HTTPDATA_DAILY_CELL_IN": { - "expires_in_version": "never", - "kind": "exponential", - "high": "10000", - "n_buckets": 200, - "extended_statistics_ok": true, - "description": "MB of http cell data recvd in one day" - }, - "HTTPDATA_DAILY_CELL_OUT": { - "expires_in_version": "never", - "kind": "exponential", - "high": "10000", - "n_buckets": 200, - "extended_statistics_ok": true, - "description": "MB of http cell data sent in one day" - }, "SSL_HANDSHAKE_VERSION": { "expires_in_version": "never", "kind": "enumerated",