/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=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/. */
// aTimeout is the timeout that we're about to start running. This function // returns the current timeout.
mozilla::dom::Timeout* BeginRunningTimeout(mozilla::dom::Timeout* aTimeout); // aTimeout is the last running timeout. void EndRunningTimeout(mozilla::dom::Timeout* aTimeout);
void UnmarkGrayTimers();
// These four methods are intended to be called from the corresponding methods // on nsGlobalWindow. void Suspend(); void Resume(); void Freeze(); void Thaw();
// This should be called by nsGlobalWindow when the window might have moved // to the background or foreground. void UpdateBackgroundState();
// The document finished loading void OnDocumentLoaded(); void StartThrottlingTimeouts();
// Run some code for each Timeout in our list. Note that this function // doesn't guarantee that Timeouts are iterated in any particular order. template <class Callable> void ForEachUnorderedTimeout(Callable c) {
mIdleTimeouts.ForEach(c);
mTimeouts.ForEach(c);
}
// get nsGlobalWindowInner // if the method returns nullptr, then we have a worker, // which should be handled differently according to TimeoutManager logic
nsGlobalWindowInner* GetInnerWindow() const { return nsGlobalWindowInner::Cast(mGlobalObject.GetAsInnerWindow());
}
// Return true if |aTimeout| needs to be reinserted into the timeout list. bool RescheduleTimeout(mozilla::dom::Timeout* aTimeout, const TimeStamp& aLastCallbackTime, const TimeStamp& aCurrentNow);
// Insert aTimeout into the list, before all timeouts that would // fire after it, but no earlier than the last Timeout with a // valid FiringId. enumclass SortBy { TimeRemaining, TimeWhen }; void Insert(mozilla::dom::Timeout* aTimeout, SortBy aSortBy);
private: // The TimeoutManager that owns this Timeouts structure. This is // mainly used to call state inspecting methods like IsValidFiringId(). const TimeoutManager& mManager;
using TimeoutList = mozilla::LinkedList<RefPtr<Timeout>>;
// mTimeoutList is generally sorted by mWhen, but new values are always // inserted after any Timeouts with a valid FiringId.
TimeoutList mTimeoutList;
// mTimeouts is a set of all the timeouts in the mTimeoutList. // It let's one to have O(1) check whether a timeout id/reason is in the // list.
RefPtr<Timeout::TimeoutSet> mTimeouts;
};
// Each nsIGlobalObject object has a TimeoutManager member. This // reference points to that holder object.
nsIGlobalObject& mGlobalObject; // The executor is specific to the nsGlobalWindow/TimeoutManager, but it // can live past the destruction of the window if its scheduled. Therefore // it must be a separate ref-counted object.
RefPtr<TimeoutExecutor> mExecutor; // For timeouts run off the idle queue
RefPtr<TimeoutExecutor> mIdleExecutor; // The list of timeouts coming from non-tracking scripts.
Timeouts mTimeouts;
int32_t mTimeoutIdCounter;
uint32_t mNextFiringId; #ifdef DEBUG
int64_t mFiringIndex;
int64_t mLastFiringIndex; #endif
AutoTArray<uint32_t, 2> mFiringIdStack;
mozilla::dom::Timeout* mRunningTimeout;
// Timeouts that would have fired but are being deferred until MainThread // is idle (because we're loading)
Timeouts mIdleTimeouts;
// The current idle request callback timeout handle
int32_t mIdleCallbackTimeoutCounter;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.