зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1339289 - Give names to a lot of common timers (r=ehsan)
MozReview-Commit-ID: IMsv5bkyjBL
This commit is contained in:
Родитель
194043ae97
Коммит
0cda76d680
|
@ -65,6 +65,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsContentSink)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINamed)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocumentObserver)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -1627,3 +1628,16 @@ nsContentSink::NotifyDocElementCreated(nsIDocument* aDoc)
|
|||
NS_LITERAL_STRING("DOMDocElementInserted"),
|
||||
true, false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::GetName(nsACString& aName)
|
||||
{
|
||||
aName.AssignASCII("nsContentSink_timer");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::SetName(const char* aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ extern mozilla::LazyLogModule gContentSinkLogModuleInfo;
|
|||
class nsContentSink : public nsICSSLoaderObserver,
|
||||
public nsSupportsWeakReference,
|
||||
public nsStubDocumentObserver,
|
||||
public nsITimerCallback
|
||||
public nsITimerCallback,
|
||||
public nsINamed
|
||||
{
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsContentSink,
|
||||
|
@ -84,6 +85,8 @@ class nsContentSink : public nsICSSLoaderObserver,
|
|||
// nsITimerCallback
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
NS_DECL_NSINAMED
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheet* aSheet,
|
||||
bool aWasAlternate,
|
||||
|
|
|
@ -656,8 +656,9 @@ nsWindowMemoryReporter::AsyncCheckForGhostWindows()
|
|||
mCheckTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
|
||||
if (mCheckTimer) {
|
||||
mCheckTimer->InitWithFuncCallback(CheckTimerFired, nullptr,
|
||||
timerDelay, nsITimer::TYPE_ONE_SHOT);
|
||||
mCheckTimer->InitWithNamedFuncCallback(CheckTimerFired, nullptr,
|
||||
timerDelay, nsITimer::TYPE_ONE_SHOT,
|
||||
"nsWindowMemoryReporter::AsyncCheckForGhostWindows_timer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -196,18 +196,21 @@ PrintDocTreeAll(nsIDocShellTreeItem* aItem)
|
|||
/* mozilla::UITimerCallback */
|
||||
/******************************************************************/
|
||||
|
||||
class UITimerCallback final : public nsITimerCallback
|
||||
class UITimerCallback final :
|
||||
public nsITimerCallback,
|
||||
public nsINamed
|
||||
{
|
||||
public:
|
||||
UITimerCallback() : mPreviousCount(0) {}
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
NS_DECL_NSINAMED
|
||||
private:
|
||||
~UITimerCallback() = default;
|
||||
uint32_t mPreviousCount;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(UITimerCallback, nsITimerCallback)
|
||||
NS_IMPL_ISUPPORTS(UITimerCallback, nsITimerCallback, nsINamed)
|
||||
|
||||
// If aTimer is nullptr, this method always sends "user-interaction-inactive"
|
||||
// notification.
|
||||
|
@ -233,6 +236,19 @@ UITimerCallback::Notify(nsITimer* aTimer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UITimerCallback::GetName(nsACString& aName)
|
||||
{
|
||||
aName.AssignASCII("UITimerCallback_timer");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UITimerCallback::SetName(const char* aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* mozilla::OverOutElementsWrapper */
|
||||
/******************************************************************/
|
||||
|
|
|
@ -295,7 +295,8 @@ nsHTMLDNSPrefetch::nsDeferrals::Add(uint16_t flags, Link *aElement)
|
|||
|
||||
if (!mActiveLoaderCount && !mTimerArmed && mTimer) {
|
||||
mTimerArmed = true;
|
||||
mTimer->InitWithFuncCallback(Tick, this, 2000, nsITimer::TYPE_ONE_SHOT);
|
||||
mTimer->InitWithNamedFuncCallback(Tick, this, 2000, nsITimer::TYPE_ONE_SHOT,
|
||||
"nsHTMLDNSPrefetch::nsDeferrals::Tick");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -49,7 +49,7 @@ struct NotificationAndReportStringId
|
|||
// nothing new happened, StopWatching() will remove the document property and
|
||||
// timer (if present), so no more work will happen and the watcher will be
|
||||
// destroyed once all references are gone.
|
||||
class DecoderDoctorDocumentWatcher : public nsITimerCallback
|
||||
class DecoderDoctorDocumentWatcher : public nsITimerCallback, public nsINamed
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<DecoderDoctorDocumentWatcher>
|
||||
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
NS_DECL_NSINAMED
|
||||
|
||||
void AddDiagnostics(DecoderDoctorDiagnostics&& aDiagnostics,
|
||||
const char* aCallSite);
|
||||
|
@ -118,7 +119,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(DecoderDoctorDocumentWatcher, nsITimerCallback)
|
||||
NS_IMPL_ISUPPORTS(DecoderDoctorDocumentWatcher, nsITimerCallback, nsINamed)
|
||||
|
||||
// static
|
||||
already_AddRefed<DecoderDoctorDocumentWatcher>
|
||||
|
@ -644,6 +645,18 @@ DecoderDoctorDocumentWatcher::Notify(nsITimer* timer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DecoderDoctorDocumentWatcher::GetName(nsACString& aName)
|
||||
{
|
||||
aName.AssignASCII("DecoderDoctorDocumentWatcher_timer");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DecoderDoctorDocumentWatcher::SetName(const char* aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
DecoderDoctorDiagnostics::StoreFormatDiagnostics(nsIDocument* aDocument,
|
||||
|
|
|
@ -248,7 +248,7 @@ namespace {
|
|||
|
||||
// This class is passed to timer as a tick observer. It refers the cache
|
||||
// and keeps it alive for a time.
|
||||
class StorageCacheHolder : public nsITimerCallback
|
||||
class StorageCacheHolder : public nsITimerCallback, public nsINamed
|
||||
{
|
||||
virtual ~StorageCacheHolder() {}
|
||||
|
||||
|
@ -261,13 +261,26 @@ class StorageCacheHolder : public nsITimerCallback
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
GetName(nsACString& aName) override
|
||||
{
|
||||
aName.AssignASCII("StorageCacheHolder_timer");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
SetName(const char* aName) override
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
RefPtr<StorageCache> mCache;
|
||||
|
||||
public:
|
||||
explicit StorageCacheHolder(StorageCache* aCache) : mCache(aCache) {}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(StorageCacheHolder, nsITimerCallback)
|
||||
NS_IMPL_ISUPPORTS(StorageCacheHolder, nsITimerCallback, nsINamed)
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -381,6 +381,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequestMainThread)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINamed)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISizeOfEventTarget)
|
||||
NS_INTERFACE_MAP_END_INHERITING(XMLHttpRequestEventTarget)
|
||||
|
||||
|
@ -3779,14 +3780,14 @@ XMLHttpRequestMainThread::BlobStoreCompleted(MutableBlobStorage* aBlobStorage,
|
|||
ChangeStateToDone();
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
XMLHttpRequestMainThread::GetName(nsACString& aName)
|
||||
{
|
||||
aName.AssignLiteral("XMLHttpRequest");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
XMLHttpRequestMainThread::SetName(const char* aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -615,8 +615,9 @@ void nsCaret::ResetBlinking()
|
|||
LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime, 500));
|
||||
if (blinkRate > 0) {
|
||||
mBlinkCount = Preferences::GetInt("ui.caretBlinkCount", -1);
|
||||
mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, blinkRate,
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
mBlinkTimer->InitWithNamedFuncCallback(CaretBlinkCallback, this, blinkRate,
|
||||
nsITimer::TYPE_REPEATING_SLACK,
|
||||
"nsCaret::CaretBlinkCallback_timer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -762,7 +762,8 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
|
|||
// The first pres context that has its mPrefChangedTimer called will
|
||||
// be the one to cause the reconstruction of the pref style sheet.
|
||||
nsLayoutStylesheetCache::InvalidatePreferenceSheets();
|
||||
mPrefChangedTimer = CreateTimer(PrefChangedUpdateTimerCallback, 0);
|
||||
mPrefChangedTimer = CreateTimer(PrefChangedUpdateTimerCallback,
|
||||
"PrefChangedUpdateTimerCallback", 0);
|
||||
if (!mPrefChangedTimer) {
|
||||
return;
|
||||
}
|
||||
|
@ -1521,7 +1522,8 @@ nsPresContext::SetContainer(nsIDocShell* aDocShell)
|
|||
mContainer = static_cast<nsDocShell*>(aDocShell);
|
||||
if (mNeedsPrefUpdate) {
|
||||
if (!mPrefChangedTimer) {
|
||||
mPrefChangedTimer = CreateTimer(PrefChangedUpdateTimerCallback, 0);
|
||||
mPrefChangedTimer = CreateTimer(PrefChangedUpdateTimerCallback,
|
||||
"PrefChangedUpdateTimerCallback", 0);
|
||||
}
|
||||
mNeedsPrefUpdate = false;
|
||||
}
|
||||
|
@ -2676,12 +2678,14 @@ nsPresContext::HasCachedStyleData()
|
|||
|
||||
already_AddRefed<nsITimer>
|
||||
nsPresContext::CreateTimer(nsTimerCallbackFunc aCallback,
|
||||
const char* aName,
|
||||
uint32_t aDelay)
|
||||
{
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (timer) {
|
||||
nsresult rv = timer->InitWithFuncCallback(aCallback, this, aDelay,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
nsresult rv = timer->InitWithNamedFuncCallback(aCallback, this, aDelay,
|
||||
nsITimer::TYPE_ONE_SHOT,
|
||||
aName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return timer.forget();
|
||||
}
|
||||
|
@ -3097,6 +3101,7 @@ nsRootPresContext::InitApplyPluginGeometryTimer()
|
|||
// won't fire before our normal paint notifications, if those would
|
||||
// update the geometry, so set it for double the refresh driver interval.
|
||||
mApplyPluginGeometryTimer = CreateTimer(ApplyPluginGeometryUpdatesCallback,
|
||||
"ApplyPluginGeometryUpdatesCallback",
|
||||
nsRefreshDriver::DefaultInterval() * 2);
|
||||
}
|
||||
|
||||
|
@ -3276,7 +3281,9 @@ nsRootPresContext::EnsureEventualDidPaintEvent()
|
|||
if (mNotifyDidPaintTimer)
|
||||
return;
|
||||
|
||||
mNotifyDidPaintTimer = CreateTimer(NotifyDidPaintForSubtreeCallback, 100);
|
||||
mNotifyDidPaintTimer = CreateTimer(NotifyDidPaintForSubtreeCallback,
|
||||
"NotifyDidPaintForSubtreeCallback",
|
||||
100);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1242,6 +1242,7 @@ protected:
|
|||
// Creates a one-shot timer with the given aCallback & aDelay.
|
||||
// Returns a refcounted pointer to the timer (or nullptr on failure).
|
||||
already_AddRefed<nsITimer> CreateTimer(nsTimerCallbackFunc aCallback,
|
||||
const char* aName,
|
||||
uint32_t aDelay);
|
||||
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
|
|
|
@ -589,8 +589,9 @@ StartupCache::ResetStartupWriteTimer()
|
|||
rv = mTimer->Cancel();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Wait for 10 seconds, then write out the cache.
|
||||
mTimer->InitWithFuncCallback(StartupCache::WriteTimeout, this, 60000,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
mTimer->InitWithNamedFuncCallback(StartupCache::WriteTimeout, this, 60000,
|
||||
nsITimer::TYPE_ONE_SHOT,
|
||||
"StartupCache::WriteTimeout");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -565,10 +565,14 @@ PerformanceAlert::GetReason(uint32_t* result) {
|
|||
* A timer callback in charge of collecting the groups in
|
||||
* `mPendingAlerts` and triggering dispatch of performance alerts.
|
||||
*/
|
||||
class PendingAlertsCollector final: public nsITimerCallback {
|
||||
class PendingAlertsCollector final :
|
||||
public nsITimerCallback,
|
||||
public nsINamed
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
NS_DECL_NSINAMED
|
||||
|
||||
explicit PendingAlertsCollector(nsPerformanceStatsService* service)
|
||||
: mService(service)
|
||||
|
@ -589,7 +593,7 @@ private:
|
|||
mozilla::Vector<uint64_t> mJankLevels;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(PendingAlertsCollector, nsITimerCallback);
|
||||
NS_IMPL_ISUPPORTS(PendingAlertsCollector, nsITimerCallback, nsINamed);
|
||||
|
||||
NS_IMETHODIMP
|
||||
PendingAlertsCollector::Notify(nsITimer*) {
|
||||
|
@ -598,6 +602,19 @@ PendingAlertsCollector::Notify(nsITimer*) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PendingAlertsCollector::GetName(nsACString& aName)
|
||||
{
|
||||
aName.AssignASCII("PendingAlertsCollector_timer");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PendingAlertsCollector::SetName(const char* aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PendingAlertsCollector::Start(uint32_t timerDelayMS) {
|
||||
if (mPending) {
|
||||
|
|
|
@ -71,9 +71,10 @@ void DoArmIPCTimerMainThread(const StaticMutexAutoLock& lock)
|
|||
CallCreateInstance(NS_TIMER_CONTRACTID, &gIPCTimer);
|
||||
}
|
||||
if (gIPCTimer) {
|
||||
gIPCTimer->InitWithFuncCallback(TelemetryIPCAccumulator::IPCTimerFired,
|
||||
nullptr, kBatchTimeoutMs,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
gIPCTimer->InitWithNamedFuncCallback(TelemetryIPCAccumulator::IPCTimerFired,
|
||||
nullptr, kBatchTimeoutMs,
|
||||
nsITimer::TYPE_ONE_SHOT,
|
||||
"TelemetryIPCAccumulator::IPCTimerFired");
|
||||
gIPCTimerArmed = true;
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +88,9 @@ void ArmIPCTimer(const StaticMutexAutoLock& lock)
|
|||
if (NS_IsMainThread()) {
|
||||
DoArmIPCTimerMainThread(lock);
|
||||
} else {
|
||||
TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
|
||||
TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction(
|
||||
"TelemetryIPCAccumulator::ArmIPCTimer",
|
||||
[]() -> void {
|
||||
StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
|
||||
DoArmIPCTimerMainThread(locker);
|
||||
}));
|
||||
|
|
|
@ -645,7 +645,7 @@ nsTimerImpl::GetName(nsACString& aName)
|
|||
aName.Assign(buf);
|
||||
} else {
|
||||
MOZ_ASSERT(cb.mName.is<Callback::NameNothing>());
|
||||
aName.AssignLiteral("Anonymous callback timer");
|
||||
aName.AssignLiteral("Anonymous_callback_timer");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -653,7 +653,7 @@ nsTimerImpl::GetName(nsACString& aName)
|
|||
if (nsCOMPtr<nsINamed> named = do_QueryInterface(cb.mCallback.i)) {
|
||||
named->GetName(aName);
|
||||
} else {
|
||||
aName.AssignLiteral("Anonymous interface timer");
|
||||
aName.AssignLiteral("Anonymous_interface_timer");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -661,12 +661,12 @@ nsTimerImpl::GetName(nsACString& aName)
|
|||
if (nsCOMPtr<nsINamed> named = do_QueryInterface(cb.mCallback.o)) {
|
||||
named->GetName(aName);
|
||||
} else {
|
||||
aName.AssignLiteral("Anonymous observer timer");
|
||||
aName.AssignLiteral("Anonymous_observer_timer");
|
||||
}
|
||||
break;
|
||||
|
||||
case Callback::Type::Unknown:
|
||||
aName.AssignLiteral("Anonymous timer");
|
||||
aName.AssignLiteral("Canceled_timer");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче