Skip to content

Instantly share code, notes, and snippets.

@canova
Last active January 17, 2019 15:15
Show Gist options
  • Save canova/a4808916910da7699cbad8e57bcf7e8e to your computer and use it in GitHub Desktop.
Save canova/a4808916910da7699cbad8e57bcf7e8e to your computer and use it in GitHub Desktop.
changeset: 453041:d2a66d8bb96a
tag: tip
parent: 453038:26808f3dc0fe
user: Nazım Can Altınova <canaltinova@gmail.com>
date: Wed Dec 12 14:48:13 2018 +0100
summary: test
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10781,18 +10781,31 @@ bool nsDocShell::OnNewURI(nsIURI* aURI,
}
#ifdef MOZ_GECKO_PROFILER
+ nsAutoCString spec;
+ aURI->GetSpec(spec);
+ uint32_t id = mLSHE ? mLSHE->GetID() : 0;
+ printf("CANOVA: OnNewURI, aURI: %s Docshell ID: %s, History ID: %d\n",
+ spec.get(), nsIDToCString(mHistoryID).get(), id);
// 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;
+ uint32_t id = mLSHE ? mLSHE->GetID() : 0;
nsAutoCString spec;
- if (mLSHE) {
- mLSHE->GetID(&id);
- }
aURI->GetSpec(spec);
- profiler_register_page(mHistoryID, id, spec, IsFrame());
+ nsCOMPtr<nsIDocShellTreeItem> parent;
+ GetSameTypeParent(getter_AddRefs(parent));
+ Maybe<Pair<nsID, uint32_t>> parentDocShell;
+ if (parent) {
+ nsCOMPtr<nsIDocShell> parentShell = do_QueryInterface(parent);
+ uint32_t parentId = 0;
+ parentShell->GetLSHEId(&parentId); // todo: check if we need osheid here
+ parentDocShell = Some(MakePair(parentShell->HistoryID(), parentId));
+ } else {
+ parentDocShell = Nothing();
+ }
+ profiler_register_page(mHistoryID, id, spec, std::move(parentDocShell));
}
#endif
@@ -11094,8 +11107,21 @@ nsDocShell::AddState(JS::Handle<JS::Valu
#ifdef MOZ_GECKO_PROFILER
uint32_t id = 0;
GetOSHEId(&id);
+ printf("CANOVA: AddState, aURI: %s Docshell ID: %s, History ID: %d\n",
+ NS_ConvertUTF16toUTF8(aURL).get(), nsIDToCString(mHistoryID).get(), id);
+ nsCOMPtr<nsIDocShellTreeItem> parent;
+ GetSameTypeParent(getter_AddRefs(parent));
+ Maybe<Pair<nsID, uint32_t>> parentDocShell;
+ if (parent) {
+ nsCOMPtr<nsIDocShell> parentShell = do_QueryInterface(parent);
+ uint32_t parentId = 0;
+ parentShell->GetLSHEId(&parentId);
+ parentDocShell = Some(MakePair(parentShell->HistoryID(), parentId));
+ } else {
+ parentDocShell = Nothing();
+ }
profiler_register_page(mHistoryID, id, NS_ConvertUTF16toUTF8(aURL),
- IsFrame());
+ std::move(parentDocShell));
#endif
} else {
@@ -13076,6 +13102,16 @@ nsDocShell::GetOSHEId(uint32_t* aSHEntry
}
NS_IMETHODIMP
+nsDocShell::GetLSHEId(uint32_t* aSHEntryId) {
+ if (mLSHE) {
+ mLSHE->GetID(aSHEntryId);
+ return NS_OK;
+ } else {
+ return NS_ERROR_FAILURE;
+ }
+}
+
+NS_IMETHODIMP
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) {
if (nsIPresShell* presShell = GetPresShell()) {
*aOut = presShell->AsyncPanZoomEnabled();
diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -937,6 +937,8 @@ interface nsIDocShell : nsIDocShellTreeI
[noscript] void GetOSHEId(out uint32_t aSHEntryId);
+ [noscript] void GetLSHEId(out uint32_t aSHEntryId);
+
/**
* This attribute determines whether a document which is not about:blank has
* already be loaded by this docShell.
diff --git a/tools/profiler/core/PageInformation.cpp b/tools/profiler/core/PageInformation.cpp
--- a/tools/profiler/core/PageInformation.cpp
+++ b/tools/profiler/core/PageInformation.cpp
@@ -6,18 +6,22 @@
#include "PageInformation.h"
-PageInformation::PageInformation(const nsID& aDocShellId,
- uint32_t aDocShellHistoryId,
- const nsCString& aUrl, bool aIsSubFrame)
+PageInformation::PageInformation(
+ const nsID& aDocShellId, uint32_t aDocShellHistoryId, const nsCString& aUrl,
+ mozilla::Maybe<mozilla::Pair<nsID, uint32_t>>&& aParentDocShell)
: mDocShellId(aDocShellId),
mDocShellHistoryId(aDocShellHistoryId),
mUrl(aUrl),
- mIsSubFrame(aIsSubFrame) {}
+ mParentDocshell(aParentDocShell) {}
bool PageInformation::Equals(PageInformation* aOtherPageInfo) {
return DocShellHistoryId() == aOtherPageInfo->DocShellHistoryId() &&
DocShellId().Equals(aOtherPageInfo->DocShellId()) &&
- IsSubFrame() == aOtherPageInfo->IsSubFrame();
+ (!ParentDocShell() ||
+ (ParentDocShell()->first() ==
+ aOtherPageInfo->ParentDocShell()->first() &&
+ ParentDocShell()->second() ==
+ aOtherPageInfo->ParentDocShell()->second()));
}
void PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) {
@@ -25,7 +29,12 @@ void PageInformation::StreamJSON(Splicea
aWriter.StringProperty("docshellId", nsIDToCString(DocShellId()).get());
aWriter.DoubleProperty("historyId", DocShellHistoryId());
aWriter.StringProperty("url", Url().get());
- aWriter.BoolProperty("isSubFrame", IsSubFrame());
+ if (mParentDocshell) {
+ aWriter.StringProperty("parentDocShellId",
+ nsIDToCString(ParentDocShell()->first()).get());
+ aWriter.DoubleProperty("parentDocShellHistoryId",
+ ParentDocShell()->second());
+ }
aWriter.EndObject();
}
diff --git a/tools/profiler/core/PageInformation.h b/tools/profiler/core/PageInformation.h
--- a/tools/profiler/core/PageInformation.h
+++ b/tools/profiler/core/PageInformation.h
@@ -22,8 +22,10 @@
class PageInformation final {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PageInformation)
- PageInformation(const nsID& aDocShellId, uint32_t aDocShellHistoryId,
- const nsCString& aUrl, bool aIsSubFrame);
+ PageInformation(
+ const nsID& aDocShellId, uint32_t aDocShellHistoryId,
+ const nsCString& aUrl,
+ mozilla::Maybe<mozilla::Pair<nsID, uint32_t>>&& aParentDocShell);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool Equals(PageInformation* aOtherDocShellInfo);
@@ -32,7 +34,9 @@ class PageInformation final {
uint32_t DocShellHistoryId() { return mDocShellHistoryId; }
const nsID& DocShellId() { return mDocShellId; }
const nsCString& Url() { return mUrl; }
- bool IsSubFrame() { return mIsSubFrame; }
+ const mozilla::Maybe<mozilla::Pair<nsID, uint32_t>>& ParentDocShell() {
+ return mParentDocshell;
+ }
mozilla::Maybe<uint64_t> BufferPositionWhenUnregistered() {
return mBufferPositionWhenUnregistered;
@@ -46,7 +50,7 @@ class PageInformation final {
const nsID mDocShellId;
const uint32_t mDocShellHistoryId;
const nsCString mUrl;
- const bool mIsSubFrame;
+ const mozilla::Maybe<mozilla::Pair<nsID, uint32_t>> mParentDocshell;
// Holds the buffer position when DocShell is unregistered.
// It's used to determine if we still use this DocShell in the profiler or
diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3501,10 +3501,13 @@ void profiler_unregister_thread() {
}
}
-void profiler_register_page(const nsID& aDocShellId, uint32_t aHistoryId,
- const nsCString& aUrl, bool aIsSubFrame) {
- DEBUG_LOG("profiler_register_page(%s, %u, %s, %d)", aDocShellId.ToString(),
- aHistoryId, aUrl.get(), aIsSubFrame);
+void profiler_register_page(
+ const nsID& aDocShellId, uint32_t aHistoryId, const nsCString& aUrl,
+ mozilla::Maybe<mozilla::Pair<nsID, uint32_t>>&& aParentDocShell) {
+ DEBUG_LOG("profiler_register_page(%s, %u, %s, %s, %d)",
+ aDocShellId.ToString(), aHistoryId, aUrl.get(),
+ aParentDocShell ? aParentDocShell->first().ToString() : "Nothing",
+ aParentDocShell ? aParentDocShell->second() : 0);
MOZ_RELEASE_ASSERT(CorePS::Exists());
@@ -3516,8 +3519,8 @@ void profiler_register_page(const nsID&
CorePS::RemoveRegisteredPages(lock, aDocShellId);
}
- RefPtr<PageInformation> pageInfo =
- new PageInformation(aDocShellId, aHistoryId, aUrl, aIsSubFrame);
+ RefPtr<PageInformation> pageInfo = new PageInformation(
+ aDocShellId, aHistoryId, aUrl, std::move(aParentDocShell));
CorePS::AppendRegisteredPage(lock, std::move(pageInfo));
// After appending the given page to CorePS, look for the expired
diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -328,9 +328,10 @@ void profiler_unregister_thread();
// "aDocShellId" is the ID of the docShell that page belongs to.
// "aHistoryId" is the ID of the history entry on the given docShell.
// "aUrl" is the URL of the page.
-// "aIsSubFrame" is true if the page is a sub frame.
-void profiler_register_page(const nsID& aDocShellId, uint32_t aHistoryId,
- const nsCString& aUrl, bool aIsSubFrame);
+// "aParentDocShell" is // TODO: Update here...
+void profiler_register_page(
+ const nsID& aDocShellId, uint32_t aHistoryId, const nsCString& aUrl,
+ mozilla::Maybe<mozilla::Pair<nsID, uint32_t> >&& aParentDocShell);
// Unregister pages with the profiler.
//
// Take a docShellId and unregister all the page entries that have the given ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment