зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1183229 - Add a way to count the number of timeline-observed docshells outside of nsDocShell, r=smaug
This commit is contained in:
Родитель
6c5bb0422e
Коммит
58593a8714
|
@ -2929,8 +2929,6 @@ nsDocShell::HistoryTransactionRemoved(int32_t aIndex)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long nsDocShell::gProfileTimelineRecordingsCount = 0;
|
|
||||||
|
|
||||||
mozilla::LinkedList<nsDocShell::ObservedDocShell>* nsDocShell::gObservedDocShells = nullptr;
|
mozilla::LinkedList<nsDocShell::ObservedDocShell>* nsDocShell::gObservedDocShells = nullptr;
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -2939,14 +2937,14 @@ nsDocShell::SetRecordProfileTimelineMarkers(bool aValue)
|
||||||
bool currentValue = nsIDocShell::GetRecordProfileTimelineMarkers();
|
bool currentValue = nsIDocShell::GetRecordProfileTimelineMarkers();
|
||||||
if (currentValue != aValue) {
|
if (currentValue != aValue) {
|
||||||
if (aValue) {
|
if (aValue) {
|
||||||
++gProfileTimelineRecordingsCount;
|
TimelineConsumers::AddConsumer();
|
||||||
UseEntryScriptProfiling();
|
UseEntryScriptProfiling();
|
||||||
|
|
||||||
MOZ_ASSERT(!mObserved);
|
MOZ_ASSERT(!mObserved);
|
||||||
mObserved.reset(new ObservedDocShell(this));
|
mObserved.reset(new ObservedDocShell(this));
|
||||||
GetOrCreateObservedDocShells().insertFront(mObserved.get());
|
GetOrCreateObservedDocShells().insertFront(mObserved.get());
|
||||||
} else {
|
} else {
|
||||||
--gProfileTimelineRecordingsCount;
|
TimelineConsumers::RemoveConsumer();
|
||||||
UnuseEntryScriptProfiling();
|
UnuseEntryScriptProfiling();
|
||||||
|
|
||||||
mObserved.reset(nullptr);
|
mObserved.reset(nullptr);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "timeline/TimelineMarker.h"
|
#include "timeline/TimelineMarker.h"
|
||||||
|
#include "timeline/TimelineConsumers.h"
|
||||||
|
|
||||||
// Threshold value in ms for META refresh based redirects
|
// Threshold value in ms for META refresh based redirects
|
||||||
#define REFRESH_REDIRECT_TIMER 15000
|
#define REFRESH_REDIRECT_TIMER 15000
|
||||||
|
@ -262,10 +263,6 @@ public:
|
||||||
void AddProfileTimelineMarker(const char* aName, TracingMetadata aMetaData);
|
void AddProfileTimelineMarker(const char* aName, TracingMetadata aMetaData);
|
||||||
void AddProfileTimelineMarker(mozilla::UniquePtr<TimelineMarker>&& aMarker);
|
void AddProfileTimelineMarker(mozilla::UniquePtr<TimelineMarker>&& aMarker);
|
||||||
|
|
||||||
// Global counter for how many docShells are currently recording profile
|
|
||||||
// timeline markers
|
|
||||||
static unsigned long gProfileTimelineRecordingsCount;
|
|
||||||
|
|
||||||
class ObservedDocShell : public mozilla::LinkedListElement<ObservedDocShell>
|
class ObservedDocShell : public mozilla::LinkedListElement<ObservedDocShell>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "mozilla/AutoGlobalTimelineMarker.h"
|
#include "mozilla/AutoGlobalTimelineMarker.h"
|
||||||
|
|
||||||
|
#include "mozilla/TimelineConsumers.h"
|
||||||
#include "MainThreadUtils.h"
|
#include "MainThreadUtils.h"
|
||||||
#include "nsDocShell.h"
|
#include "nsDocShell.h"
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(const char* aName
|
||||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (nsDocShell::gProfileTimelineRecordingsCount == 0) {
|
if (TimelineConsumers::IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ bool
|
||||||
AutoTimelineMarker::DocShellIsRecording(nsDocShell& aDocShell)
|
AutoTimelineMarker::DocShellIsRecording(nsDocShell& aDocShell)
|
||||||
{
|
{
|
||||||
bool isRecording = false;
|
bool isRecording = false;
|
||||||
if (nsDocShell::gProfileTimelineRecordingsCount > 0) {
|
if (!TimelineConsumers::IsEmpty()) {
|
||||||
aDocShell.GetRecordProfileTimelineMarkers(&isRecording);
|
aDocShell.GetRecordProfileTimelineMarkers(&isRecording);
|
||||||
}
|
}
|
||||||
return isRecording;
|
return isRecording;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* -*- 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/. */
|
||||||
|
|
||||||
|
#include "mozilla/TimelineConsumers.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
unsigned long TimelineConsumers::sActiveConsumers = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineConsumers::AddConsumer()
|
||||||
|
{
|
||||||
|
sActiveConsumers++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineConsumers::RemoveConsumer()
|
||||||
|
{
|
||||||
|
sActiveConsumers--;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TimelineConsumers::IsEmpty()
|
||||||
|
{
|
||||||
|
return sActiveConsumers == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mozilla
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* -*- 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/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_TimelineConsumers_h_
|
||||||
|
#define mozilla_TimelineConsumers_h_
|
||||||
|
|
||||||
|
class nsDocShell;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
// # TimelineConsumers
|
||||||
|
//
|
||||||
|
// A class to trace how many frontends are interested in markers. Whenever
|
||||||
|
// interest is expressed in markers, these fields will keep track of that.
|
||||||
|
class TimelineConsumers
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Counter for how many timelines are currently interested in markers.
|
||||||
|
static unsigned long sActiveConsumers;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void AddConsumer();
|
||||||
|
static void RemoveConsumer();
|
||||||
|
static bool IsEmpty();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif /* mozilla_TimelineConsumers_h_ */
|
|
@ -7,11 +7,13 @@
|
||||||
EXPORTS.mozilla += [
|
EXPORTS.mozilla += [
|
||||||
'AutoGlobalTimelineMarker.h',
|
'AutoGlobalTimelineMarker.h',
|
||||||
'AutoTimelineMarker.h',
|
'AutoTimelineMarker.h',
|
||||||
|
'TimelineConsumers.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'AutoGlobalTimelineMarker.cpp',
|
'AutoGlobalTimelineMarker.cpp',
|
||||||
'AutoTimelineMarker.cpp',
|
'AutoTimelineMarker.cpp',
|
||||||
|
'TimelineConsumers.cpp',
|
||||||
'TimelineMarker.cpp',
|
'TimelineMarker.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "mozilla/dom/BindingUtils.h"
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/Event.h"
|
#include "mozilla/dom/Event.h"
|
||||||
|
#include "mozilla/TimelineConsumers.h"
|
||||||
|
|
||||||
#include "EventListenerService.h"
|
#include "EventListenerService.h"
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
|
@ -1122,7 +1123,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
||||||
nsCOMPtr<nsIDocShell> docShell;
|
nsCOMPtr<nsIDocShell> docShell;
|
||||||
bool isTimelineRecording = false;
|
bool isTimelineRecording = false;
|
||||||
if (mIsMainThreadELM &&
|
if (mIsMainThreadELM &&
|
||||||
nsDocShell::gProfileTimelineRecordingsCount > 0 &&
|
!TimelineConsumers::IsEmpty() &&
|
||||||
listener->mListenerType != Listener::eNativeListener) {
|
listener->mListenerType != Listener::eNativeListener) {
|
||||||
docShell = GetDocShellForTarget();
|
docShell = GetDocShellForTarget();
|
||||||
if (docShell) {
|
if (docShell) {
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "mozilla/VsyncDispatcher.h"
|
#include "mozilla/VsyncDispatcher.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
|
#include "mozilla/TimelineConsumers.h"
|
||||||
|
|
||||||
#ifdef MOZ_NUWA_PROCESS
|
#ifdef MOZ_NUWA_PROCESS
|
||||||
#include "ipc/Nuwa.h"
|
#include "ipc/Nuwa.h"
|
||||||
|
@ -993,7 +994,7 @@ RefreshDriverTimer*
|
||||||
nsRefreshDriver::ChooseTimer() const
|
nsRefreshDriver::ChooseTimer() const
|
||||||
{
|
{
|
||||||
if (mThrottled) {
|
if (mThrottled) {
|
||||||
if (!sThrottledRateTimer)
|
if (!sThrottledRateTimer)
|
||||||
sThrottledRateTimer = new InactiveRefreshDriverTimer(GetThrottledTimerInterval(),
|
sThrottledRateTimer = new InactiveRefreshDriverTimer(GetThrottledTimerInterval(),
|
||||||
DEFAULT_INACTIVE_TIMER_DISABLE_SECONDS * 1000.0);
|
DEFAULT_INACTIVE_TIMER_DISABLE_SECONDS * 1000.0);
|
||||||
return sThrottledRateTimer;
|
return sThrottledRateTimer;
|
||||||
|
@ -1051,7 +1052,7 @@ nsRefreshDriver::~nsRefreshDriver()
|
||||||
MOZ_ASSERT(ObserverCount() == 0,
|
MOZ_ASSERT(ObserverCount() == 0,
|
||||||
"observers should have unregistered");
|
"observers should have unregistered");
|
||||||
MOZ_ASSERT(!mActiveTimer, "timer should be gone");
|
MOZ_ASSERT(!mActiveTimer, "timer should be gone");
|
||||||
|
|
||||||
if (mRootRefresh) {
|
if (mRootRefresh) {
|
||||||
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
||||||
mRootRefresh = nullptr;
|
mRootRefresh = nullptr;
|
||||||
|
@ -1436,7 +1437,7 @@ HasPendingAnimations(nsIPresShell* aShell)
|
||||||
static void GetProfileTimelineSubDocShells(nsDocShell* aRootDocShell,
|
static void GetProfileTimelineSubDocShells(nsDocShell* aRootDocShell,
|
||||||
nsTArray<nsDocShell*>& aShells)
|
nsTArray<nsDocShell*>& aShells)
|
||||||
{
|
{
|
||||||
if (!aRootDocShell || nsDocShell::gProfileTimelineRecordingsCount == 0) {
|
if (!aRootDocShell || TimelineConsumers::IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче