Merge remote-tracking branch 'origin/custom' into custom-platform

This commit is contained in:
2023-04-13 16:45:28 +08:00
7 changed files with 47 additions and 33 deletions
+12
View File
@@ -318,6 +318,8 @@ nsGlobalWindow::DOMMinTimeoutValue() const {
// nsTimerImpl.h for details.
#define DOM_MAX_TIMEOUT_VALUE DELAY_INTERVAL_LIMIT
#define MEMORY_PRESSURE_OBSERVER_TOPIC "memory-pressure"
// The interval at which we execute idle callbacks
static uint32_t gThrottledIdlePeriodLength;
@@ -1525,6 +1527,8 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
// Watch for dom-storage2-changed so we can fire storage
// events. Use a strong reference.
os->AddObserver(mObserver, "dom-storage2-changed", false);
os->AddObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC, false);
}
Preferences::AddStrongObserver(mObserver, "intl.accept_languages");
@@ -1840,6 +1844,7 @@ nsGlobalWindow::CleanUp()
if (os) {
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
os->RemoveObserver(mObserver, "dom-storage2-changed");
os->RemoveObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC);
}
if (mIdleService) {
@@ -11702,6 +11707,13 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, MEMORY_PRESSURE_OBSERVER_TOPIC)) {
if (mPerformance) {
mPerformance->MemoryPressure();
}
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
mCurrentlyIdle = true;
if (IsFrozen()) {
+7 -12
View File
@@ -262,11 +262,6 @@ already_AddRefed<PerformanceMark> Performance::Mark(
const PerformanceMarkOptions& aMarkOptions,
ErrorResult& aRv)
{
// Don't add the entry if the buffer is full. XXX should be removed by bug 1159003.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
return nullptr;
}
nsCOMPtr<nsIGlobalObject> parent = GetParentObject();
if (!parent || parent->IsDying() || !parent->GetGlobalJSObject()) {
aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT);
@@ -490,12 +485,6 @@ Performance::Measure(JSContext* aCx,
const Optional<nsAString>& aEndMark,
ErrorResult& aRv)
{
// Don't add the entry if the buffer is full. XXX should be removed by bug
// 1159003.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
return nullptr;
}
const PerformanceMeasureOptions* options = nullptr;
if (aStartOrMeasureOptions.IsPerformanceMeasureOptions()) {
options = &aStartOrMeasureOptions.GetAsPerformanceMeasureOptions();
@@ -553,7 +542,7 @@ Performance::Measure(JSContext* aCx,
}
RefPtr<PerformanceMeasure> performanceMeasure = new PerformanceMeasure(
GetAsISupports(), aName, startTime, endTime, detail);
GetParentObject(), aName, startTime, endTime, detail);
InsertUserEntry(performanceMeasure);
return performanceMeasure.forget();
@@ -753,5 +742,11 @@ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
return runnable->Dispatch() && runnable->IsEnabled();
}
void
Performance::MemoryPressure()
{
mUserEntries.Clear();
}
} // dom namespace
} // mozilla namespace
+8 -5
View File
@@ -124,6 +124,8 @@ public:
return false;
}
void MemoryPressure();
protected:
Performance();
explicit Performance(nsPIDOMWindowInner* aWindow);
@@ -136,8 +138,6 @@ protected:
void ClearUserEntries(const Optional<nsAString>& aEntryName,
const nsAString& aEntryType);
virtual nsISupports* GetAsISupports() = 0;
virtual void DispatchBufferFullEvent() = 0;
virtual TimeStamp CreationTimeStamp() const = 0;
@@ -167,11 +167,14 @@ protected:
nsTObserverArray<PerformanceObserver*> mObservers;
protected:
nsTArray<RefPtr<PerformanceEntry>> mUserEntries;
nsTArray<RefPtr<PerformanceEntry>> mResourceEntries;
static const uint64_t kDefaultResourceTimingBufferSize = 1500;
// When kDefaultResourceTimingBufferSize is increased or removed, these should
// be changed to use SegmentedVector
AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mUserEntries;
AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mResourceEntries;
uint64_t mResourceTimingBufferSize;
static const uint64_t kDefaultResourceTimingBufferSize = 1500;
bool mPendingNotificationObserversTask;
RefPtr<PerformanceService> mPerformanceService;
-5
View File
@@ -65,11 +65,6 @@ public:
protected:
~PerformanceMainThread();
nsISupports* GetAsISupports() override
{
return this;
}
void InsertUserEntry(PerformanceEntry* aEntry) override;
DOMHighResTimeStamp
-5
View File
@@ -65,11 +65,6 @@ public:
protected:
~PerformanceWorker();
nsISupports* GetAsISupports() override
{
return nullptr;
}
void InsertUserEntry(PerformanceEntry* aEntry) override;
void DispatchBufferFullEvent() override
+15 -6
View File
@@ -6441,14 +6441,23 @@ WorkerPrivate::MemoryPressureInternal()
{
AssertIsOnWorkerThread();
RefPtr<Console> console = mScope ? mScope->GetConsoleIfExists() : nullptr;
if (console) {
console->ClearStorage();
if (mScope) {
RefPtr<Console> console = mScope->GetConsoleIfExists();
if (console) {
console->ClearStorage();
}
RefPtr<Performance> performance = mScope->GetPerformanceIfExists();
if (performance) {
performance->MemoryPressure();
}
}
console = mDebuggerScope ? mDebuggerScope->GetConsoleIfExists() : nullptr;
if (console) {
console->ClearStorage();
if (mDebuggerScope) {
RefPtr<Console> console = mDebuggerScope->GetConsoleIfExists();
if (console) {
console->ClearStorage();
}
}
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
+5
View File
@@ -157,6 +157,11 @@ public:
Performance* GetPerformance();
Performance* GetPerformanceIfExists() const
{
return mPerformance;
}
already_AddRefed<Promise>
Fetch(const RequestOrUSVString& aInput, const RequestInit& aInit, ErrorResult& aRv);