mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 14:28:39 +09:00
Remove base conditional code for crash reporter and injector.
This commit is contained in:
parent
87fa26d31e
commit
434f3590e3
131 changed files with 39 additions and 4139 deletions
|
|
@ -39,12 +39,6 @@
|
|||
#include "nsThreadSyncDispatch.h"
|
||||
#include "LeakRefPtr.h"
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsICrashReporter.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_LINUX
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
|
@ -520,73 +514,6 @@ nsThread::ThreadFunc(void* aArg)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
// Tell the crash reporter to save a memory report if our heuristics determine
|
||||
// that an OOM failure is likely to occur soon.
|
||||
// Memory usage will not be checked more than every 30 seconds or saved more
|
||||
// than every 3 minutes
|
||||
// If |aShouldSave == kForceReport|, a report will be saved regardless of
|
||||
// whether the process is low on memory or not. However, it will still not be
|
||||
// saved if a report was saved less than 3 minutes ago.
|
||||
bool
|
||||
nsThread::SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave)
|
||||
{
|
||||
// Keep an eye on memory usage (cheap, ~7ms) somewhat frequently,
|
||||
// but save memory reports (expensive, ~75ms) less frequently.
|
||||
const size_t kLowMemoryCheckSeconds = 30;
|
||||
const size_t kLowMemorySaveSeconds = 3 * 60;
|
||||
|
||||
static TimeStamp nextCheck = TimeStamp::NowLoRes()
|
||||
+ TimeDuration::FromSeconds(kLowMemoryCheckSeconds);
|
||||
static bool recentlySavedReport = false; // Keeps track of whether a report
|
||||
// was saved last time we checked
|
||||
|
||||
// Are we checking again too soon?
|
||||
TimeStamp now = TimeStamp::NowLoRes();
|
||||
if ((aShouldSave == ShouldSaveMemoryReport::kMaybeReport ||
|
||||
recentlySavedReport) && now < nextCheck) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needMemoryReport = (aShouldSave == ShouldSaveMemoryReport::kForceReport);
|
||||
#ifdef XP_WIN // XXX implement on other platforms as needed
|
||||
// If the report is forced there is no need to check whether it is necessary
|
||||
if (aShouldSave != ShouldSaveMemoryReport::kForceReport) {
|
||||
const size_t LOWMEM_THRESHOLD_VIRTUAL = 200 * 1024 * 1024;
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof(statex);
|
||||
if (GlobalMemoryStatusEx(&statex)) {
|
||||
if (statex.ullAvailVirtual < LOWMEM_THRESHOLD_VIRTUAL) {
|
||||
needMemoryReport = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (needMemoryReport) {
|
||||
if (XRE_IsContentProcess()) {
|
||||
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
|
||||
if (cc) {
|
||||
cc->SendNotifyLowMemory();
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsICrashReporter> cr =
|
||||
do_GetService("@mozilla.org/toolkit/crash-reporter;1");
|
||||
if (cr) {
|
||||
cr->SaveMemoryReport();
|
||||
}
|
||||
}
|
||||
recentlySavedReport = true;
|
||||
nextCheck = now + TimeDuration::FromSeconds(kLowMemorySaveSeconds);
|
||||
} else {
|
||||
recentlySavedReport = false;
|
||||
nextCheck = now + TimeDuration::FromSeconds(kLowMemoryCheckSeconds);
|
||||
}
|
||||
|
||||
return recentlySavedReport;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_CANARY
|
||||
int sCanaryOutputFD = -1;
|
||||
#endif
|
||||
|
|
@ -1459,12 +1386,6 @@ nsThread::DoMainThreadSpecificProcessing(bool aReallyWait)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
if (!ShuttingDown()) {
|
||||
SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue