forked from mirrors/gecko-dev
Bug 1842682 - Remove unused ChromeUtils.requestIOActivity and IOActivityMonitor, r=necko-reviewers,valentin.
Differential Revision: https://phabricator.services.mozilla.com/D210680
This commit is contained in:
parent
8e020b00cf
commit
f910267fcf
18 changed files with 3 additions and 772 deletions
|
|
@ -57,7 +57,6 @@
|
||||||
#include "mozilla/RemoteDecoderManagerChild.h"
|
#include "mozilla/RemoteDecoderManagerChild.h"
|
||||||
#include "mozilla/KeySystemConfig.h"
|
#include "mozilla/KeySystemConfig.h"
|
||||||
#include "mozilla/WheelHandlingHelper.h"
|
#include "mozilla/WheelHandlingHelper.h"
|
||||||
#include "IOActivityMonitor.h"
|
|
||||||
#include "nsNativeTheme.h"
|
#include "nsNativeTheme.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "mozJSModuleLoader.h"
|
#include "mozJSModuleLoader.h"
|
||||||
|
|
@ -1851,22 +1850,6 @@ void ChromeUtils::CreateError(const GlobalObject& aGlobal,
|
||||||
aRetVal.set(retVal);
|
aRetVal.set(retVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
|
||||||
already_AddRefed<Promise> ChromeUtils::RequestIOActivity(GlobalObject& aGlobal,
|
|
||||||
ErrorResult& aRv) {
|
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
|
||||||
MOZ_ASSERT(Preferences::GetBool(IO_ACTIVITY_ENABLED_PREF, false));
|
|
||||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
|
||||||
MOZ_ASSERT(global);
|
|
||||||
RefPtr<Promise> domPromise = Promise::Create(global, aRv);
|
|
||||||
if (NS_WARN_IF(aRv.Failed())) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(domPromise);
|
|
||||||
mozilla::net::IOActivityMonitor::RequestActivities(domPromise);
|
|
||||||
return domPromise.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
bool ChromeUtils::HasReportingHeaderForOrigin(GlobalObject& global,
|
bool ChromeUtils::HasReportingHeaderForOrigin(GlobalObject& global,
|
||||||
const nsAString& aOrigin,
|
const nsAString& aOrigin,
|
||||||
|
|
|
||||||
|
|
@ -240,9 +240,6 @@ class ChromeUtils {
|
||||||
JS::MutableHandle<JSObject*> aRetVal,
|
JS::MutableHandle<JSObject*> aRetVal,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
||||||
static already_AddRefed<Promise> RequestIOActivity(GlobalObject& aGlobal,
|
|
||||||
ErrorResult& aRv);
|
|
||||||
|
|
||||||
static bool HasReportingHeaderForOrigin(GlobalObject& global,
|
static bool HasReportingHeaderForOrigin(GlobalObject& global,
|
||||||
const nsAString& aOrigin,
|
const nsAString& aOrigin,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
|
||||||
|
|
@ -617,12 +617,6 @@ partial namespace ChromeUtils {
|
||||||
[NewObject]
|
[NewObject]
|
||||||
Promise<DOMString> collectPerfStats();
|
Promise<DOMString> collectPerfStats();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a Promise containing a sequence of I/O activities
|
|
||||||
*/
|
|
||||||
[NewObject]
|
|
||||||
Promise<sequence<IOActivityDataDictionary>> requestIOActivity();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Promise containing all processes info
|
* Returns a Promise containing all processes info
|
||||||
*/
|
*/
|
||||||
|
|
@ -927,18 +921,6 @@ dictionary ParentProcInfoDictionary {
|
||||||
WebIDLProcType type = "browser";
|
WebIDLProcType type = "browser";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by requestIOActivity() to return the number of bytes
|
|
||||||
* that were read (rx) and/or written (tx) for a given location.
|
|
||||||
*
|
|
||||||
* Locations can be sockets or files.
|
|
||||||
*/
|
|
||||||
dictionary IOActivityDataDictionary {
|
|
||||||
ByteString location = "";
|
|
||||||
unsigned long long rx = 0;
|
|
||||||
unsigned long long tx = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by principals and the script security manager to represent origin
|
* Used by principals and the script security manager to represent origin
|
||||||
* attributes. The first dictionary is designed to contain the full set of
|
* attributes. The first dictionary is designed to contain the full set of
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,5 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Dummy test page</p>
|
<p>Dummy test page</p>
|
||||||
<script>
|
|
||||||
localStorage.setItem("foo", "bar");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -3267,9 +3267,6 @@ pref("memory.dump_reports_on_oom", false);
|
||||||
// Number of stack frames to capture in createObjectURL for about:memory.
|
// Number of stack frames to capture in createObjectURL for about:memory.
|
||||||
pref("memory.blob_report.stack_frames", 0);
|
pref("memory.blob_report.stack_frames", 0);
|
||||||
|
|
||||||
// Activates the activity monitor
|
|
||||||
pref("io.activity.enabled", false);
|
|
||||||
|
|
||||||
// path to OSVR DLLs
|
// path to OSVR DLLs
|
||||||
pref("gfx.vr.osvr.utilLibPath", "");
|
pref("gfx.vr.osvr.utilLibPath", "");
|
||||||
pref("gfx.vr.osvr.commonLibPath", "");
|
pref("gfx.vr.osvr.commonLibPath", "");
|
||||||
|
|
|
||||||
|
|
@ -1,495 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
||||||
*
|
|
||||||
* 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 "IOActivityMonitor.h"
|
|
||||||
#include "nsPrintfCString.h"
|
|
||||||
#include "nsSocketTransport2.h"
|
|
||||||
#include "nsSocketTransportService2.h"
|
|
||||||
#include "nsThreadUtils.h"
|
|
||||||
#include "mozilla/Atomics.h"
|
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
|
||||||
#include "mozilla/dom/Promise.h"
|
|
||||||
#include "prerror.h"
|
|
||||||
#include "prio.h"
|
|
||||||
#include "prmem.h"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace mozilla;
|
|
||||||
using namespace mozilla::net;
|
|
||||||
|
|
||||||
mozilla::StaticRefPtr<IOActivityMonitor> gInstance;
|
|
||||||
static Atomic<bool> gActivated(false);
|
|
||||||
static PRDescIdentity sNetActivityMonitorLayerIdentity;
|
|
||||||
static PRIOMethods sNetActivityMonitorLayerMethods;
|
|
||||||
static PRIOMethods* sNetActivityMonitorLayerMethodsPtr = nullptr;
|
|
||||||
|
|
||||||
// Maximum number of activities entries in the monitoring class
|
|
||||||
#define MAX_ACTIVITY_ENTRIES 1000
|
|
||||||
|
|
||||||
// ActivityMonitorSecret is stored in the activity monitor layer
|
|
||||||
// and provides a method to get the location.
|
|
||||||
//
|
|
||||||
// A location can be :
|
|
||||||
// - a TCP or UDP socket. The form will be socket://ip:port
|
|
||||||
// - a File. The form will be file://path
|
|
||||||
//
|
|
||||||
// For other cases, the location will be fd://number
|
|
||||||
class ActivityMonitorSecret final {
|
|
||||||
public:
|
|
||||||
// constructor used for sockets
|
|
||||||
explicit ActivityMonitorSecret(PRFileDesc* aFd) {
|
|
||||||
mFd = aFd;
|
|
||||||
mLocationSet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor used for files
|
|
||||||
explicit ActivityMonitorSecret(PRFileDesc* aFd, const char* aLocation) {
|
|
||||||
mFd = aFd;
|
|
||||||
mLocation.AppendPrintf("file://%s", aLocation);
|
|
||||||
mLocationSet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCString getLocation() {
|
|
||||||
if (!mLocationSet) {
|
|
||||||
LazySetLocation();
|
|
||||||
}
|
|
||||||
return mLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Called to set the location using the FD on the first getLocation() usage
|
|
||||||
// which is typically when a socket is opened. If done earlier, at
|
|
||||||
// construction time, the host won't be bound yet.
|
|
||||||
//
|
|
||||||
// If the location is a file, it needs to be initialized in the
|
|
||||||
// constructor.
|
|
||||||
void LazySetLocation() {
|
|
||||||
mLocationSet = true;
|
|
||||||
PRFileDesc* extract = mFd;
|
|
||||||
while (PR_GetDescType(extract) == PR_DESC_LAYERED) {
|
|
||||||
if (!extract->lower) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
extract = extract->lower;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRDescType fdType = PR_GetDescType(extract);
|
|
||||||
// we should not use LazySetLocation for files
|
|
||||||
MOZ_ASSERT(fdType != PR_DESC_FILE);
|
|
||||||
|
|
||||||
switch (fdType) {
|
|
||||||
case PR_DESC_SOCKET_TCP:
|
|
||||||
case PR_DESC_SOCKET_UDP: {
|
|
||||||
mLocation.AppendPrintf("socket://");
|
|
||||||
PRNetAddr addr;
|
|
||||||
PRStatus status = PR_GetSockName(mFd, &addr);
|
|
||||||
if (NS_WARN_IF(status == PR_FAILURE)) {
|
|
||||||
mLocation.AppendPrintf("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// grabbing the host
|
|
||||||
char netAddr[mozilla::net::kNetAddrMaxCStrBufSize] = {0};
|
|
||||||
status = PR_NetAddrToString(&addr, netAddr, sizeof(netAddr) - 1);
|
|
||||||
if (NS_WARN_IF(status == PR_FAILURE) || netAddr[0] == 0) {
|
|
||||||
mLocation.AppendPrintf("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mLocation.Append(netAddr);
|
|
||||||
|
|
||||||
// adding the port
|
|
||||||
uint16_t port;
|
|
||||||
if (addr.raw.family == PR_AF_INET) {
|
|
||||||
port = addr.inet.port;
|
|
||||||
} else {
|
|
||||||
port = addr.ipv6.port;
|
|
||||||
}
|
|
||||||
mLocation.AppendPrintf(":%d", port);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
// for all other cases, we just send back fd://<value>
|
|
||||||
default: {
|
|
||||||
mLocation.AppendLiteral("fd://");
|
|
||||||
mLocation.AppendInt(PR_FileDesc2NativeHandle(mFd));
|
|
||||||
}
|
|
||||||
} // end switch
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsCString mLocation;
|
|
||||||
bool mLocationSet;
|
|
||||||
PRFileDesc* mFd;
|
|
||||||
};
|
|
||||||
|
|
||||||
// FileDesc2Location converts a PRFileDesc into a "location" by
|
|
||||||
// grabbing the ActivityMonitorSecret in layer->secret
|
|
||||||
static nsAutoCString FileDesc2Location(PRFileDesc* fd) {
|
|
||||||
nsAutoCString location;
|
|
||||||
PRFileDesc* monitorLayer =
|
|
||||||
PR_GetIdentitiesLayer(fd, sNetActivityMonitorLayerIdentity);
|
|
||||||
if (!monitorLayer) {
|
|
||||||
location.AppendPrintf("unknown");
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityMonitorSecret* secret = (ActivityMonitorSecret*)monitorLayer->secret;
|
|
||||||
location.AppendPrintf("%s", secret->getLocation().get());
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Wrappers around the socket APIS
|
|
||||||
//
|
|
||||||
static PRStatus nsNetMon_Connect(PRFileDesc* fd, const PRNetAddr* addr,
|
|
||||||
PRIntervalTime timeout) {
|
|
||||||
return fd->lower->methods->connect(fd->lower, addr, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PRStatus nsNetMon_Close(PRFileDesc* fd) {
|
|
||||||
if (!fd) {
|
|
||||||
return PR_FAILURE;
|
|
||||||
}
|
|
||||||
PRFileDesc* layer = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);
|
|
||||||
MOZ_RELEASE_ASSERT(
|
|
||||||
layer && layer->identity == sNetActivityMonitorLayerIdentity,
|
|
||||||
"NetActivityMonitor Layer not on top of stack");
|
|
||||||
|
|
||||||
if (layer->secret) {
|
|
||||||
delete (ActivityMonitorSecret*)layer->secret;
|
|
||||||
layer->secret = nullptr;
|
|
||||||
}
|
|
||||||
layer->dtor(layer);
|
|
||||||
return fd->methods->close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_Read(PRFileDesc* fd, void* buf, int32_t len) {
|
|
||||||
int32_t ret = fd->lower->methods->read(fd->lower, buf, len);
|
|
||||||
if (ret >= 0) {
|
|
||||||
IOActivityMonitor::Read(fd, len);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_Write(PRFileDesc* fd, const void* buf, int32_t len) {
|
|
||||||
int32_t ret = fd->lower->methods->write(fd->lower, buf, len);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Write(fd, len);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_Writev(PRFileDesc* fd, const PRIOVec* iov, int32_t size,
|
|
||||||
PRIntervalTime timeout) {
|
|
||||||
int32_t ret = fd->lower->methods->writev(fd->lower, iov, size, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Write(fd, size);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_Recv(PRFileDesc* fd, void* buf, int32_t amount,
|
|
||||||
int flags, PRIntervalTime timeout) {
|
|
||||||
int32_t ret =
|
|
||||||
fd->lower->methods->recv(fd->lower, buf, amount, flags, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Read(fd, amount);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_Send(PRFileDesc* fd, const void* buf, int32_t amount,
|
|
||||||
int flags, PRIntervalTime timeout) {
|
|
||||||
int32_t ret =
|
|
||||||
fd->lower->methods->send(fd->lower, buf, amount, flags, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Write(fd, amount);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_RecvFrom(PRFileDesc* fd, void* buf, int32_t amount,
|
|
||||||
int flags, PRNetAddr* addr,
|
|
||||||
PRIntervalTime timeout) {
|
|
||||||
int32_t ret = fd->lower->methods->recvfrom(fd->lower, buf, amount, flags,
|
|
||||||
addr, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Read(fd, amount);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_SendTo(PRFileDesc* fd, const void* buf, int32_t amount,
|
|
||||||
int flags, const PRNetAddr* addr,
|
|
||||||
PRIntervalTime timeout) {
|
|
||||||
int32_t ret =
|
|
||||||
fd->lower->methods->sendto(fd->lower, buf, amount, flags, addr, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Write(fd, amount);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t nsNetMon_AcceptRead(PRFileDesc* listenSock,
|
|
||||||
PRFileDesc** acceptedSock,
|
|
||||||
PRNetAddr** peerAddr, void* buf,
|
|
||||||
int32_t amount, PRIntervalTime timeout) {
|
|
||||||
int32_t ret = listenSock->lower->methods->acceptread(
|
|
||||||
listenSock->lower, acceptedSock, peerAddr, buf, amount, timeout);
|
|
||||||
if (ret > 0) {
|
|
||||||
IOActivityMonitor::Read(listenSock, amount);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Class IOActivityMonitor
|
|
||||||
//
|
|
||||||
NS_IMPL_ISUPPORTS(IOActivityMonitor, nsINamed)
|
|
||||||
|
|
||||||
IOActivityMonitor::IOActivityMonitor() : mLock("IOActivityMonitor::mLock") {
|
|
||||||
RefPtr<IOActivityMonitor> mon(gInstance);
|
|
||||||
MOZ_ASSERT(!mon, "multiple IOActivityMonitor instances!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void IOActivityMonitor::RequestActivities(dom::Promise* aPromise) {
|
|
||||||
MOZ_ASSERT(aPromise);
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
aPromise->MaybeReject(NS_ERROR_FAILURE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mon->RequestActivitiesInternal(aPromise);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IOActivityMonitor::RequestActivitiesInternal(dom::Promise* aPromise) {
|
|
||||||
nsresult result = NS_OK;
|
|
||||||
FallibleTArray<dom::IOActivityDataDictionary> activities;
|
|
||||||
|
|
||||||
{
|
|
||||||
mozilla::MutexAutoLock lock(mLock);
|
|
||||||
// Remove inactive activities
|
|
||||||
for (auto iter = mActivities.Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
dom::IOActivityDataDictionary* activity = &iter.Data();
|
|
||||||
if (activity->mRx == 0 && activity->mTx == 0) {
|
|
||||||
iter.Remove();
|
|
||||||
} else {
|
|
||||||
if (NS_WARN_IF(!activities.AppendElement(iter.Data(), fallible))) {
|
|
||||||
result = NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(result))) {
|
|
||||||
aPromise->MaybeReject(result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
aPromise->MaybeResolve(activities);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
IOActivityMonitor::GetName(nsACString& aName) {
|
|
||||||
aName.AssignLiteral("IOActivityMonitor");
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
bool IOActivityMonitor::IsActive() { return gActivated; }
|
|
||||||
|
|
||||||
// static
|
|
||||||
already_AddRefed<IOActivityMonitor> IOActivityMonitor::Get() {
|
|
||||||
if (!gActivated) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<IOActivityMonitor> mon = gInstance;
|
|
||||||
return mon.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Init() {
|
|
||||||
if (IsActive()) {
|
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
|
||||||
}
|
|
||||||
RefPtr<IOActivityMonitor> mon = new IOActivityMonitor();
|
|
||||||
nsresult rv = mon->InitInternal();
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
gInstance = mon;
|
|
||||||
ClearOnShutdown(&gInstance);
|
|
||||||
gActivated = true;
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::InitInternal() {
|
|
||||||
// wraps the socket APIs
|
|
||||||
if (!sNetActivityMonitorLayerMethodsPtr) {
|
|
||||||
sNetActivityMonitorLayerIdentity =
|
|
||||||
PR_GetUniqueIdentity("network activity monitor layer");
|
|
||||||
sNetActivityMonitorLayerMethods = *PR_GetDefaultIOMethods();
|
|
||||||
sNetActivityMonitorLayerMethods.connect = nsNetMon_Connect;
|
|
||||||
sNetActivityMonitorLayerMethods.read = nsNetMon_Read;
|
|
||||||
sNetActivityMonitorLayerMethods.write = nsNetMon_Write;
|
|
||||||
sNetActivityMonitorLayerMethods.writev = nsNetMon_Writev;
|
|
||||||
sNetActivityMonitorLayerMethods.recv = nsNetMon_Recv;
|
|
||||||
sNetActivityMonitorLayerMethods.send = nsNetMon_Send;
|
|
||||||
sNetActivityMonitorLayerMethods.recvfrom = nsNetMon_RecvFrom;
|
|
||||||
sNetActivityMonitorLayerMethods.sendto = nsNetMon_SendTo;
|
|
||||||
sNetActivityMonitorLayerMethods.acceptread = nsNetMon_AcceptRead;
|
|
||||||
sNetActivityMonitorLayerMethods.close = nsNetMon_Close;
|
|
||||||
sNetActivityMonitorLayerMethodsPtr = &sNetActivityMonitorLayerMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Shutdown() {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
|
||||||
}
|
|
||||||
return mon->ShutdownInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::ShutdownInternal() {
|
|
||||||
mozilla::MutexAutoLock lock(mLock);
|
|
||||||
mActivities.Clear();
|
|
||||||
gActivated = false;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::MonitorSocket(PRFileDesc* aFd) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
PRFileDesc* layer;
|
|
||||||
PRStatus status;
|
|
||||||
layer = PR_CreateIOLayerStub(sNetActivityMonitorLayerIdentity,
|
|
||||||
sNetActivityMonitorLayerMethodsPtr);
|
|
||||||
if (!layer) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityMonitorSecret* secret = new ActivityMonitorSecret(aFd);
|
|
||||||
layer->secret = reinterpret_cast<PRFilePrivate*>(secret);
|
|
||||||
status = PR_PushIOLayer(aFd, PR_NSPR_IO_LAYER, layer);
|
|
||||||
|
|
||||||
if (status == PR_FAILURE) {
|
|
||||||
delete secret;
|
|
||||||
PR_Free(layer); // PR_CreateIOLayerStub() uses PR_Malloc().
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::MonitorFile(PRFileDesc* aFd, const char* aPath) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
PRFileDesc* layer;
|
|
||||||
PRStatus status;
|
|
||||||
layer = PR_CreateIOLayerStub(sNetActivityMonitorLayerIdentity,
|
|
||||||
sNetActivityMonitorLayerMethodsPtr);
|
|
||||||
if (!layer) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityMonitorSecret* secret = new ActivityMonitorSecret(aFd, aPath);
|
|
||||||
layer->secret = reinterpret_cast<PRFilePrivate*>(secret);
|
|
||||||
|
|
||||||
status = PR_PushIOLayer(aFd, PR_NSPR_IO_LAYER, layer);
|
|
||||||
if (status == PR_FAILURE) {
|
|
||||||
delete secret;
|
|
||||||
PR_Free(layer); // PR_CreateIOLayerStub() uses PR_Malloc().
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IOActivityMonitor::IncrementActivity(const nsACString& aLocation,
|
|
||||||
uint32_t aRx, uint32_t aTx) {
|
|
||||||
mLock.AssertCurrentThreadOwns();
|
|
||||||
return mActivities.WithEntryHandle(aLocation, fallible, [&](auto&& entry) {
|
|
||||||
if (!entry) return false;
|
|
||||||
|
|
||||||
if (*entry) {
|
|
||||||
// already registered
|
|
||||||
entry->Data().mTx += aTx;
|
|
||||||
entry->Data().mRx += aRx;
|
|
||||||
} else {
|
|
||||||
// Creating a new IOActivity. Notice that mActivities
|
|
||||||
// will grow indefinitely, which is OK since we won't
|
|
||||||
// have but a few hundreds entries at the most, but we
|
|
||||||
// want to assert we have at the most 1000 entries
|
|
||||||
MOZ_ASSERT(mActivities.Count() <= MAX_ACTIVITY_ENTRIES);
|
|
||||||
|
|
||||||
dom::IOActivityDataDictionary activity;
|
|
||||||
activity.mLocation.Assign(aLocation);
|
|
||||||
activity.mTx = aTx;
|
|
||||||
activity.mRx = aRx;
|
|
||||||
|
|
||||||
entry->Insert(std::move(activity));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Write(const nsACString& aLocation,
|
|
||||||
uint32_t aAmount) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return mon->WriteInternal(aLocation, aAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Write(PRFileDesc* fd, uint32_t aAmount) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return mon->Write(FileDesc2Location(fd), aAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::WriteInternal(const nsACString& aLocation,
|
|
||||||
uint32_t aAmount) {
|
|
||||||
mozilla::MutexAutoLock lock(mLock);
|
|
||||||
if (!IncrementActivity(aLocation, aAmount, 0)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Read(PRFileDesc* fd, uint32_t aAmount) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return mon->Read(FileDesc2Location(fd), aAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::Read(const nsACString& aLocation,
|
|
||||||
uint32_t aAmount) {
|
|
||||||
RefPtr<IOActivityMonitor> mon = IOActivityMonitor::Get();
|
|
||||||
if (!mon) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return mon->ReadInternal(aLocation, aAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult IOActivityMonitor::ReadInternal(const nsACString& aLocation,
|
|
||||||
uint32_t aAmount) {
|
|
||||||
mozilla::MutexAutoLock lock(mLock);
|
|
||||||
if (!IncrementActivity(aLocation, 0, aAmount)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#ifndef IOActivityMonitor_h___
|
|
||||||
#define IOActivityMonitor_h___
|
|
||||||
|
|
||||||
#include "mozilla/dom/ChromeUtilsBinding.h"
|
|
||||||
#include "mozilla/Mutex.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nscore.h"
|
|
||||||
#include "nsClassHashtable.h"
|
|
||||||
#include "nsTHashMap.h"
|
|
||||||
#include "nsHashKeys.h"
|
|
||||||
#include "nsINamed.h"
|
|
||||||
#include "nsISupports.h"
|
|
||||||
#include "prinrval.h"
|
|
||||||
#include "prio.h"
|
|
||||||
#include "private/pprio.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
|
|
||||||
namespace dom {
|
|
||||||
class Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace net {
|
|
||||||
|
|
||||||
#define IO_ACTIVITY_ENABLED_PREF "io.activity.enabled"
|
|
||||||
|
|
||||||
using Activities = nsTHashMap<nsCStringHashKey, dom::IOActivityDataDictionary>;
|
|
||||||
|
|
||||||
// IOActivityMonitor has several roles:
|
|
||||||
// - maintains an IOActivity per resource and updates it
|
|
||||||
// - sends a dump of the activities to a promise via RequestActivities
|
|
||||||
class IOActivityMonitor final : public nsINamed {
|
|
||||||
public:
|
|
||||||
IOActivityMonitor();
|
|
||||||
|
|
||||||
NS_DECL_THREADSAFE_ISUPPORTS
|
|
||||||
NS_DECL_NSINAMED
|
|
||||||
|
|
||||||
// initializes and destroys the singleton
|
|
||||||
static nsresult Init();
|
|
||||||
static nsresult Shutdown();
|
|
||||||
|
|
||||||
// collect amounts of data that are written/read by location
|
|
||||||
static nsresult Read(const nsACString& location, uint32_t aAmount);
|
|
||||||
static nsresult Write(const nsACString& location, uint32_t aAmount);
|
|
||||||
|
|
||||||
static nsresult MonitorFile(PRFileDesc* aFd, const char* aPath);
|
|
||||||
static nsresult MonitorSocket(PRFileDesc* aFd);
|
|
||||||
static nsresult Read(PRFileDesc* fd, uint32_t aAmount);
|
|
||||||
static nsresult Write(PRFileDesc* fd, uint32_t aAmount);
|
|
||||||
|
|
||||||
static bool IsActive();
|
|
||||||
static void RequestActivities(dom::Promise* aPromise);
|
|
||||||
|
|
||||||
private:
|
|
||||||
~IOActivityMonitor() = default;
|
|
||||||
|
|
||||||
static already_AddRefed<IOActivityMonitor> Get();
|
|
||||||
|
|
||||||
nsresult InitInternal();
|
|
||||||
nsresult ShutdownInternal();
|
|
||||||
bool IncrementActivity(const nsACString& location, uint32_t aRx,
|
|
||||||
uint32_t aTx);
|
|
||||||
nsresult WriteInternal(const nsACString& location, uint32_t aAmount);
|
|
||||||
nsresult ReadInternal(const nsACString& location, uint32_t aAmount);
|
|
||||||
void RequestActivitiesInternal(dom::Promise* aPromise);
|
|
||||||
|
|
||||||
Activities mActivities;
|
|
||||||
// protects mActivities accesses
|
|
||||||
Mutex mLock MOZ_UNANNOTATED;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace net
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif /* IOActivityMonitor_h___ */
|
|
||||||
|
|
@ -163,7 +163,6 @@ EXPORTS.mozilla.net += [
|
||||||
"DashboardTypes.h",
|
"DashboardTypes.h",
|
||||||
"DefaultURI.h",
|
"DefaultURI.h",
|
||||||
"InterceptionInfo.h",
|
"InterceptionInfo.h",
|
||||||
"IOActivityMonitor.h",
|
|
||||||
"MemoryDownloader.h",
|
"MemoryDownloader.h",
|
||||||
"NetworkConnectivityService.h",
|
"NetworkConnectivityService.h",
|
||||||
"Predictor.h",
|
"Predictor.h",
|
||||||
|
|
@ -185,7 +184,6 @@ UNIFIED_SOURCES += [
|
||||||
"DefaultURI.cpp",
|
"DefaultURI.cpp",
|
||||||
"EventTokenBucket.cpp",
|
"EventTokenBucket.cpp",
|
||||||
"InterceptionInfo.cpp",
|
"InterceptionInfo.cpp",
|
||||||
"IOActivityMonitor.cpp",
|
|
||||||
"LoadContextInfo.cpp",
|
"LoadContextInfo.cpp",
|
||||||
"LoadInfo.cpp",
|
"LoadInfo.cpp",
|
||||||
"MemoryDownloader.cpp",
|
"MemoryDownloader.cpp",
|
||||||
|
|
|
||||||
|
|
@ -15,27 +15,23 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "private/pprio.h"
|
#include "private/pprio.h"
|
||||||
#include "prerror.h"
|
|
||||||
|
|
||||||
#include "IOActivityMonitor.h"
|
|
||||||
#include "nsFileStreams.h"
|
#include "nsFileStreams.h"
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsReadLine.h"
|
#include "nsReadLine.h"
|
||||||
#include "nsIClassInfoImpl.h"
|
#include "nsIClassInfoImpl.h"
|
||||||
#include "nsLiteralString.h"
|
|
||||||
#include "nsSocketTransport2.h" // for ErrorAccordingToNSPR()
|
|
||||||
#include "mozilla/ipc/InputStreamUtils.h"
|
#include "mozilla/ipc/InputStreamUtils.h"
|
||||||
#include "mozilla/ipc/RandomAccessStreamParams.h"
|
#include "mozilla/ipc/RandomAccessStreamParams.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "mozilla/FileUtils.h"
|
#include "mozilla/FileUtils.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "nsNetCID.h"
|
#include "nsNetCID.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
|
|
||||||
using FileHandleType = mozilla::ipc::FileDescriptor::PlatformHandleType;
|
using FileHandleType = mozilla::ipc::FileDescriptor::PlatformHandleType;
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
using namespace mozilla::net;
|
|
||||||
|
|
||||||
using mozilla::DebugOnly;
|
using mozilla::DebugOnly;
|
||||||
using mozilla::Maybe;
|
using mozilla::Maybe;
|
||||||
|
|
@ -359,21 +355,6 @@ nsresult nsFileStreamBase::DoOpen() {
|
||||||
mOpenParams.perm, &fd);
|
mOpenParams.perm, &fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv == NS_OK && IOActivityMonitor::IsActive()) {
|
|
||||||
auto nativePath = mOpenParams.localFile->NativePath();
|
|
||||||
if (!nativePath.IsEmpty()) {
|
|
||||||
// registering the file to the activity monitor
|
|
||||||
#ifdef XP_WIN
|
|
||||||
// 16 bits unicode
|
|
||||||
IOActivityMonitor::MonitorFile(
|
|
||||||
fd, NS_ConvertUTF16toUTF8(nativePath.get()).get());
|
|
||||||
#else
|
|
||||||
// 8 bit unicode
|
|
||||||
IOActivityMonitor::MonitorFile(fd, nativePath.get());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CleanUpOpen();
|
CleanUpOpen();
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,3 @@ interface nsPISocketTransportService : nsIRoutedSocketTransportService
|
||||||
*/
|
*/
|
||||||
readonly attribute long keepaliveProbeCount;
|
readonly attribute long keepaliveProbeCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
%{C++
|
|
||||||
/*
|
|
||||||
* I/O activity observer topic. Sends out information about the
|
|
||||||
* amount of data we're sending/receiving via sockets and disk files.
|
|
||||||
*
|
|
||||||
* Activated via the "io.activity.enabled" preference.
|
|
||||||
*/
|
|
||||||
#define NS_IO_ACTIVITY "io-activity"
|
|
||||||
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "nsSocketTransport2.h"
|
#include "nsSocketTransport2.h"
|
||||||
|
|
||||||
#include "IOActivityMonitor.h"
|
|
||||||
#include "NSSErrorsService.h"
|
#include "NSSErrorsService.h"
|
||||||
#include "NetworkDataCountLayer.h"
|
#include "NetworkDataCountLayer.h"
|
||||||
#include "QuicSocketControl.h"
|
#include "QuicSocketControl.h"
|
||||||
|
|
@ -1344,9 +1343,6 @@ nsresult nsSocketTransport::InitiateSocket() {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create proxy via IOActivityMonitor
|
|
||||||
IOActivityMonitor::MonitorSocket(fd);
|
|
||||||
|
|
||||||
#ifdef FUZZING
|
#ifdef FUZZING
|
||||||
if (StaticPrefs::fuzzing_necko_enabled()) {
|
if (StaticPrefs::fuzzing_necko_enabled()) {
|
||||||
rv = AttachFuzzyIOLayer(fd);
|
rv = AttachFuzzyIOLayer(fd);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "nsSocketTransportService2.h"
|
#include "nsSocketTransportService2.h"
|
||||||
|
|
||||||
#include "IOActivityMonitor.h"
|
|
||||||
#include "mozilla/Atomics.h"
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/ChaosMode.h"
|
#include "mozilla/ChaosMode.h"
|
||||||
#include "mozilla/IntegerPrintfMacros.h"
|
#include "mozilla/IntegerPrintfMacros.h"
|
||||||
|
|
@ -784,7 +783,6 @@ nsSocketTransportService::Init() {
|
||||||
// socket process. We have to make sure the topics registered below are also
|
// socket process. We have to make sure the topics registered below are also
|
||||||
// registered in nsIObserver::Init().
|
// registered in nsIObserver::Init().
|
||||||
if (obsSvc) {
|
if (obsSvc) {
|
||||||
obsSvc->AddObserver(this, "profile-initial-state", false);
|
|
||||||
obsSvc->AddObserver(this, "last-pb-context-exited", false);
|
obsSvc->AddObserver(this, "last-pb-context-exited", false);
|
||||||
obsSvc->AddObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC, true);
|
obsSvc->AddObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC, true);
|
||||||
obsSvc->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true);
|
obsSvc->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true);
|
||||||
|
|
@ -860,7 +858,6 @@ nsresult nsSocketTransportService::ShutdownThread() {
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
|
nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
|
||||||
if (obsSvc) {
|
if (obsSvc) {
|
||||||
obsSvc->RemoveObserver(this, "profile-initial-state");
|
|
||||||
obsSvc->RemoveObserver(this, "last-pb-context-exited");
|
obsSvc->RemoveObserver(this, "last-pb-context-exited");
|
||||||
obsSvc->RemoveObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC);
|
obsSvc->RemoveObserver(this, NS_WIDGET_SLEEP_OBSERVER_TOPIC);
|
||||||
obsSvc->RemoveObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC);
|
obsSvc->RemoveObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC);
|
||||||
|
|
@ -873,8 +870,6 @@ nsresult nsSocketTransportService::ShutdownThread() {
|
||||||
mAfterWakeUpTimer = nullptr;
|
mAfterWakeUpTimer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOActivityMonitor::Shutdown();
|
|
||||||
|
|
||||||
mInitialized = false;
|
mInitialized = false;
|
||||||
mShuttingDown = false;
|
mShuttingDown = false;
|
||||||
|
|
||||||
|
|
@ -1612,13 +1607,6 @@ nsSocketTransportService::Observe(nsISupports* subject, const char* topic,
|
||||||
const char16_t* data) {
|
const char16_t* data) {
|
||||||
SOCKET_LOG(("nsSocketTransportService::Observe topic=%s", topic));
|
SOCKET_LOG(("nsSocketTransportService::Observe topic=%s", topic));
|
||||||
|
|
||||||
if (!strcmp(topic, "profile-initial-state")) {
|
|
||||||
if (!Preferences::GetBool(IO_ACTIVITY_ENABLED_PREF, false)) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
return net::IOActivityMonitor::Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(topic, "last-pb-context-exited")) {
|
if (!strcmp(topic, "last-pb-context-exited")) {
|
||||||
nsCOMPtr<nsIRunnable> ev = NewRunnableMethod(
|
nsCOMPtr<nsIRunnable> ev = NewRunnableMethod(
|
||||||
"net::nsSocketTransportService::ClosePrivateConnections", this,
|
"net::nsSocketTransportService::ClosePrivateConnections", this,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#include "prio.h"
|
#include "prio.h"
|
||||||
#include "nsNetAddr.h"
|
#include "nsNetAddr.h"
|
||||||
#include "nsNetSegmentUtils.h"
|
#include "nsNetSegmentUtils.h"
|
||||||
#include "IOActivityMonitor.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsStreamUtils.h"
|
#include "nsStreamUtils.h"
|
||||||
#include "prerror.h"
|
#include "prerror.h"
|
||||||
|
|
@ -639,9 +638,6 @@ nsUDPSocket::InitWithAddress(const NetAddr* aAddr, nsIPrincipal* aPrincipal,
|
||||||
|
|
||||||
PRNetAddrToNetAddr(&addr, &mAddr);
|
PRNetAddrToNetAddr(&addr, &mAddr);
|
||||||
|
|
||||||
// create proxy via IOActivityMonitor
|
|
||||||
IOActivityMonitor::MonitorSocket(mFD);
|
|
||||||
|
|
||||||
// wait until AsyncListen is called before polling the socket for
|
// wait until AsyncListen is called before polling the socket for
|
||||||
// client connections.
|
// client connections.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
support-files = [
|
support-files = [
|
||||||
"dummy.html",
|
"dummy.html",
|
||||||
"ioactivity.html",
|
|
||||||
"redirect.sjs",
|
"redirect.sjs",
|
||||||
"auth_post.sjs",
|
"auth_post.sjs",
|
||||||
"early_hint_main_html.sjs",
|
"early_hint_main_html.sjs",
|
||||||
|
|
@ -189,7 +188,4 @@ support-files = [
|
||||||
"file_favicon.html",
|
"file_favicon.html",
|
||||||
]
|
]
|
||||||
|
|
||||||
["browser_test_io_activity.js"]
|
|
||||||
skip-if = ["socketprocess_networking"]
|
|
||||||
|
|
||||||
["browser_test_offline_tab.js"]
|
["browser_test_offline_tab.js"]
|
||||||
|
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
||||||
/* vim: set ts=2 et sw=2 tw=80: */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
"use strict";
|
|
||||||
const ROOT_URL = getRootDirectory(gTestPath).replace(
|
|
||||||
"chrome://mochitests/content/",
|
|
||||||
"https://example.com/"
|
|
||||||
);
|
|
||||||
const TEST_URL = "about:license";
|
|
||||||
const TEST_URL2 = ROOT_URL + "ioactivity.html";
|
|
||||||
|
|
||||||
var gotSocket = false;
|
|
||||||
var gotFile = false;
|
|
||||||
var gotSqlite = false;
|
|
||||||
var gotEmptyData = false;
|
|
||||||
|
|
||||||
function processResults(results) {
|
|
||||||
for (let data of results) {
|
|
||||||
console.log(data.location);
|
|
||||||
gotEmptyData = data.rx == 0 && data.tx == 0 && !gotEmptyData;
|
|
||||||
gotSocket = data.location.startsWith("socket://127.0.0.1:") || gotSocket;
|
|
||||||
gotFile = data.location.endsWith("aboutLicense.css") || gotFile;
|
|
||||||
gotSqlite = data.location.endsWith("places.sqlite") || gotSqlite;
|
|
||||||
// check for the write-ahead file as well
|
|
||||||
gotSqlite = data.location.endsWith("places.sqlite-wal") || gotSqlite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(async function testRequestIOActivity() {
|
|
||||||
await SpecialPowers.pushPrefEnv({
|
|
||||||
set: [["io.activity.enabled", true]],
|
|
||||||
});
|
|
||||||
waitForExplicitFinish();
|
|
||||||
Services.obs.notifyObservers(null, "profile-initial-state");
|
|
||||||
|
|
||||||
await BrowserTestUtils.withNewTab(TEST_URL, async function () {
|
|
||||||
await BrowserTestUtils.withNewTab(TEST_URL2, async function () {
|
|
||||||
let results = await ChromeUtils.requestIOActivity();
|
|
||||||
processResults(results);
|
|
||||||
|
|
||||||
ok(gotSocket, "A socket was used");
|
|
||||||
// test deactivated for now
|
|
||||||
// ok(gotFile, "A file was used");
|
|
||||||
ok(gotSqlite, "A sqlite DB was used");
|
|
||||||
ok(!gotEmptyData, "Every I/O event had data");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<p>IOActivity Test Page</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sqlite3.h"
|
#include "sqlite3.h"
|
||||||
#include "mozilla/net/IOActivityMonitor.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
@ -19,40 +18,28 @@ constexpr int kLastKnowVfsVersion = 3;
|
||||||
constexpr int kLastKnownIOMethodsVersion = 3;
|
constexpr int kLastKnownIOMethodsVersion = 3;
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::net;
|
|
||||||
|
|
||||||
struct BaseFile {
|
struct BaseFile {
|
||||||
// Base class. Must be first
|
// Base class. Must be first
|
||||||
sqlite3_file base;
|
sqlite3_file base;
|
||||||
// The filename
|
|
||||||
char* location;
|
|
||||||
// This points to the underlying sqlite3_file
|
// This points to the underlying sqlite3_file
|
||||||
sqlite3_file pReal[1];
|
sqlite3_file pReal[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
int BaseClose(sqlite3_file* pFile) {
|
int BaseClose(sqlite3_file* pFile) {
|
||||||
BaseFile* p = (BaseFile*)pFile;
|
BaseFile* p = (BaseFile*)pFile;
|
||||||
delete[] p->location;
|
|
||||||
return p->pReal->pMethods->xClose(p->pReal);
|
return p->pReal->pMethods->xClose(p->pReal);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseRead(sqlite3_file* pFile, void* zBuf, int iAmt, sqlite_int64 iOfst) {
|
int BaseRead(sqlite3_file* pFile, void* zBuf, int iAmt, sqlite_int64 iOfst) {
|
||||||
BaseFile* p = (BaseFile*)pFile;
|
BaseFile* p = (BaseFile*)pFile;
|
||||||
int rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
|
return p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
|
||||||
if (rc == SQLITE_OK && IOActivityMonitor::IsActive()) {
|
|
||||||
IOActivityMonitor::Read(nsDependentCString(p->location), iAmt);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseWrite(sqlite3_file* pFile, const void* zBuf, int iAmt,
|
int BaseWrite(sqlite3_file* pFile, const void* zBuf, int iAmt,
|
||||||
sqlite_int64 iOfst) {
|
sqlite_int64 iOfst) {
|
||||||
BaseFile* p = (BaseFile*)pFile;
|
BaseFile* p = (BaseFile*)pFile;
|
||||||
int rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
|
return p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
|
||||||
if (rc == SQLITE_OK && IOActivityMonitor::IsActive()) {
|
|
||||||
IOActivityMonitor::Write(nsDependentCString(p->location), iAmt);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseTruncate(sqlite3_file* pFile, sqlite_int64 size) {
|
int BaseTruncate(sqlite3_file* pFile, sqlite_int64 size) {
|
||||||
|
|
@ -148,15 +135,6 @@ int BaseUnfetch(sqlite3_file* pFile, sqlite3_int64 iOfst, void* pPage) {
|
||||||
int BaseOpen(sqlite3_vfs* vfs, const char* zName, sqlite3_file* pFile,
|
int BaseOpen(sqlite3_vfs* vfs, const char* zName, sqlite3_file* pFile,
|
||||||
int flags, int* pOutFlags) {
|
int flags, int* pOutFlags) {
|
||||||
BaseFile* p = (BaseFile*)pFile;
|
BaseFile* p = (BaseFile*)pFile;
|
||||||
if (zName) {
|
|
||||||
p->location = new char[7 + strlen(zName) + 1];
|
|
||||||
strcpy(p->location, "file://");
|
|
||||||
strcpy(p->location + 7, zName);
|
|
||||||
} else {
|
|
||||||
p->location = new char[8];
|
|
||||||
strcpy(p->location, "file://");
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_vfs* origVfs = (sqlite3_vfs*)(vfs->pAppData);
|
sqlite3_vfs* origVfs = (sqlite3_vfs*)(vfs->pAppData);
|
||||||
int rc = origVfs->xOpen(origVfs, zName, p->pReal, flags, pOutFlags);
|
int rc = origVfs->xOpen(origVfs, zName, p->pReal, flags, pOutFlags);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
|
|
||||||
7
tools/@types/lib.gecko.dom.d.ts
vendored
7
tools/@types/lib.gecko.dom.d.ts
vendored
|
|
@ -1250,12 +1250,6 @@ interface IIRFilterOptions extends AudioNodeOptions {
|
||||||
feedforward: number[];
|
feedforward: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IOActivityDataDictionary {
|
|
||||||
location?: string;
|
|
||||||
rx?: number;
|
|
||||||
tx?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IdentityCredentialLogoutRPsRequest {
|
interface IdentityCredentialLogoutRPsRequest {
|
||||||
accountId: UTF8String;
|
accountId: UTF8String;
|
||||||
url: UTF8String;
|
url: UTF8String;
|
||||||
|
|
@ -35509,7 +35503,6 @@ declare namespace ChromeUtils {
|
||||||
function registerProcessActor(aName: UTF8String, aOptions?: ProcessActorOptions): void;
|
function registerProcessActor(aName: UTF8String, aOptions?: ProcessActorOptions): void;
|
||||||
function registerWindowActor(aName: UTF8String, aOptions?: WindowActorOptions): void;
|
function registerWindowActor(aName: UTF8String, aOptions?: WindowActorOptions): void;
|
||||||
function releaseAssert(condition: boolean, message?: string): void;
|
function releaseAssert(condition: boolean, message?: string): void;
|
||||||
function requestIOActivity(): Promise<IOActivityDataDictionary[]>;
|
|
||||||
function requestProcInfo(): Promise<ParentProcInfoDictionary>;
|
function requestProcInfo(): Promise<ParentProcInfoDictionary>;
|
||||||
function resetLastExternalProtocolIframeAllowed(): void;
|
function resetLastExternalProtocolIframeAllowed(): void;
|
||||||
function saveHeapSnapshot(boundaries?: HeapSnapshotBoundaries): string;
|
function saveHeapSnapshot(boundaries?: HeapSnapshotBoundaries): string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue