Bug 1417976 - Part 1: Store the information of DocShells in CorePS r=mstange,bzbarsky

Added a mechanism to register and unregister the DocShells from the CorePS depending
on the state of the profiler. Registering mechanism is straightforward. During
unregistration, if profiler is not active, we remove the DocShell information
immediately. If profiler is active, we don't remove and we keep the profiler buffer
position at that moment. During another DocShell registration we Discard the
unregistered DocShells. If the profiler buffer position is greater than the position
when we captured during unregistration, we delete the DocShell since that means there
can't be any markers associated to this DocShell anymore.

MozReview-Commit-ID: IVuKQ6drvkR

Differential Revision: https://phabricator.services.mozilla.com/D4914
This commit is contained in:
Nazım Can Altınova
2018-11-06 21:45:07 +00:00
parent d2e0dfb1b9
commit 670614c344
6 changed files with 298 additions and 2 deletions

View File

@@ -424,6 +424,10 @@ nsDocShell::~nsDocShell()
// Avoid notifying observers while we're in the dtor.
mIsBeingDestroyed = true;
#ifdef MOZ_GECKO_PROFILER
profiler_unregister_pages(mHistoryID);
#endif
Destroy();
if (mSessionHistory) {
@@ -11358,6 +11362,21 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
}
}
#ifdef MOZ_GECKO_PROFILER
// We register the page load only if the load updates the history and it's not
// a refresh. This also registers the iframes in shift-reload case, but it's
// reasonable to register since we are updating the historyId in that case.
if (updateSHistory) {
uint32_t id = 0;
nsAutoCString spec;
if (mLSHE) {
mLSHE->GetID(&id);
}
aURI->GetSpec(spec);
profiler_register_page(mHistoryID, id, spec, IsFrame());
}
#endif
// If this is a POST request, we do not want to include this in global
// history.
if (updateGHistory && aAddToGlobalHistory && !ChannelIsPost(aChannel)) {
@@ -11668,6 +11687,12 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
// we'll just set mOSHE here.
mOSHE = newSHEntry;
#ifdef MOZ_GECKO_PROFILER
uint32_t id = 0;
GetOSHEId(&id);
profiler_register_page(mHistoryID, id, NS_ConvertUTF16toUTF8(aURL), IsFrame());
#endif
} else {
newSHEntry = mOSHE;
newSHEntry->SetURI(newURI);