Backed out changeset f3c4d03ad677 (bug 922924) for bustage.

This commit is contained in:
Ryan VanderMeulen 2013-11-15 08:32:23 -05:00
Родитель 526076b1c7
Коммит 1e6ecbf0e0
7 изменённых файлов: 85 добавлений и 48 удалений

Просмотреть файл

@ -86,10 +86,6 @@
#include <limits>
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#endif
#ifdef MOZILLA_INTERNAL_API
#include "nsReadableUtils.h"
@ -2364,30 +2360,4 @@ NS_IsSrcdocChannel(nsIChannel *aChannel)
return false;
}
// The following members are used for network per-app metering.
const static uint64_t NETWORK_STATS_THRESHOLD = 65536;
inline nsresult
NS_GetActiveNetworkInterface(nsCOMPtr<nsINetworkInterface> &aNetworkInterface)
{
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(NS_IsMainThread());
nsresult rv;
nsCOMPtr<nsINetworkManager> networkManager =
do_GetService("@mozilla.org/network/manager;1", &rv);
if (NS_FAILED(rv) || !networkManager) {
aNetworkInterface = nullptr;
return rv;
}
networkManager->GetActive(getter_AddRefs(aNetworkInterface));
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
#endif // !nsNetUtil_h__

Просмотреть файл

@ -1691,10 +1691,6 @@ nsFtpState::Init(nsFtpChannel *channel)
// initialize counter for network metering
mCountRecv = 0;
#ifdef MOZ_WIDGET_GONK
NS_GetActiveNetworkInterface(mActiveNetwork);
#endif
mKeepRunning = true;
mSuppliedEntityID = channel->EntityID();
@ -2203,6 +2199,22 @@ nsresult
nsFtpState::SaveNetworkStats(bool enforce)
{
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(NS_IsMainThread());
// Obtain active network
nsresult rv;
if (!mActiveNetwork) {
nsCOMPtr<nsINetworkManager> networkManager =
do_GetService("@mozilla.org/network/manager;1", &rv);
if (NS_FAILED(rv) || !networkManager) {
mActiveNetwork = nullptr;
return rv;
}
networkManager->GetActive(getter_AddRefs(mActiveNetwork));
}
// Obtain app id
uint32_t appId;
bool isInBrowser;
@ -2225,7 +2237,6 @@ nsFtpState::SaveNetworkStats(bool enforce)
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsINetworkStatsServiceProxy> networkStatsServiceProxy =
do_GetService("@mozilla.org/networkstatsServiceProxy;1", &rv);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -262,6 +262,10 @@ private:
// These members are used for network per-app metering (bug 855948)
// Currently, they are only available on gonk.
public:
const static uint64_t NETWORK_STATS_THRESHOLD = 65536;
private:
uint64_t mCountRecv;
#ifdef MOZ_WIDGET_GONK
nsCOMPtr<nsINetworkInterface> mActiveNetwork;

Просмотреть файл

@ -230,20 +230,17 @@ nsHttpTransaction::Init(uint32_t caps,
mActivityDistributor = nullptr;
}
// obtain app info
bool isInBrowser;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(eventsink);
if (channel) {
bool isInBrowser;
NS_GetAppInfo(channel, &mAppId, &isInBrowser);
}
#ifdef MOZ_WIDGET_GONK
// obtain active connection type
if (mAppId != NECKO_NO_APP_ID) {
nsCOMPtr<nsINetworkInterface> activeNetwork;
NS_GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
GetActiveNetwork();
}
#endif
// create transport event sink proxy. it coalesces all events if and only
// if the activity observer is not active. when the observer is active
@ -710,6 +707,28 @@ nsHttpTransaction::WriteSegments(nsAHttpSegmentWriter *writer,
return rv;
}
void
nsHttpTransaction::GetActiveNetwork()
{
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(NS_IsMainThread());
nsresult rv;
nsCOMPtr<nsINetworkManager> networkManager =
do_GetService("@mozilla.org/network/manager;1", &rv);
if (NS_FAILED(rv) || !networkManager) {
mActiveNetwork = nullptr;
return;
}
nsCOMPtr<nsINetworkInterface> activeNetwork;
networkManager->GetActive(getter_AddRefs(activeNetwork));
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
#endif
}
//-----------------------------------------------------------------------------
// nsHttpTransaction save network statistics event
//-----------------------------------------------------------------------------

Просмотреть файл

@ -340,6 +340,10 @@ private:
// These members are used for network per-app metering (bug 746073)
// Currently, they are only available on gonk.
public:
const static uint64_t NETWORK_STATS_THRESHOLD = 65536;
private:
uint64_t mCountRecv;
uint64_t mCountSent;
uint32_t mAppId;
@ -347,6 +351,7 @@ private:
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
#endif
nsresult SaveNetworkStats(bool);
void GetActiveNetwork();
void CountRecvBytes(uint64_t recvBytes)
{
mCountRecv += recvBytes;

Просмотреть файл

@ -965,7 +965,8 @@ WebSocketChannel::WebSocketChannel() :
mConnectionLogService(nullptr),
mCountRecv(0),
mCountSent(0),
mAppId(NECKO_NO_APP_ID)
mAppId(0),
mIsInBrowser(false)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
@ -1074,16 +1075,15 @@ WebSocketChannel::BeginOpen()
return;
}
// obtain app info
if (localChannel) {
bool isInBrowser;
NS_GetAppInfo(localChannel, &mAppId, &isInBrowser);
NS_GetAppInfo(localChannel, &mAppId, &mIsInBrowser);
}
#ifdef MOZ_WIDGET_GONK
// obtain active network
if (mAppId != NECKO_NO_APP_ID) {
NS_GetActiveNetworkInterface(mActiveNetwork);
GetActiveNetwork();
}
#endif
rv = localChannel->AsyncOpen(this, mHttpChannel);
if (NS_FAILED(rv)) {
@ -3271,6 +3271,28 @@ WebSocketChannel::OnDataAvailable(nsIRequest *aRequest,
return NS_OK;
}
nsresult
WebSocketChannel::GetActiveNetwork()
{
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(NS_IsMainThread());
nsresult result;
nsCOMPtr<nsINetworkManager> networkManager = do_GetService("@mozilla.org/network/manager;1", &result);
if (NS_FAILED(result) || !networkManager) {
mActiveNetwork = nullptr;
return NS_ERROR_UNEXPECTED;
}
result = networkManager->GetActive(getter_AddRefs(mActiveNetwork));
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
nsresult
WebSocketChannel::SaveNetworkStats(bool enforce)
{

Просмотреть файл

@ -257,12 +257,18 @@ private:
// These members are used for network per-app metering (bug 855949)
// Currently, they are only available on gonk.
public:
const static uint64_t NETWORK_STATS_THRESHOLD = 65536;
private:
uint64_t mCountRecv;
uint64_t mCountSent;
uint32_t mAppId;
bool mIsInBrowser;
#ifdef MOZ_WIDGET_GONK
nsCOMPtr<nsINetworkInterface> mActiveNetwork;
#endif
nsresult GetActiveNetwork();
nsresult SaveNetworkStats(bool);
void CountRecvBytes(uint64_t recvBytes)
{