Bug 1821303 - Add hasPostData bool to nsISHEntry r=smaug

To avoid unnecessary cloning of nsIInputStream, add a hasPostData
boolean attribute to tell whether a nsISHEntry has populated postData.

Differential Revision: https://phabricator.services.mozilla.com/D173237
This commit is contained in:
Rob Wu 2023-03-29 15:50:45 +00:00
Родитель dbf7c989d2
Коммит e505210f70
4 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -715,6 +715,12 @@ SessionHistoryEntry::SetPostData(nsIInputStream* aPostData) {
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::GetHasPostData(bool* aResult) {
*aResult = mInfo->HasPostData();
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::GetLayoutHistoryState(
nsILayoutHistoryState** aLayoutHistoryState) {

Просмотреть файл

@ -128,6 +128,7 @@ interface nsISHEntry : nsISupports
/** Post Data for the document */
[infallible] attribute nsIInputStream postData;
[infallible] readonly attribute boolean hasPostData;
/** LayoutHistoryState for scroll position and form values */
[infallible] attribute nsILayoutHistoryState layoutHistoryState;

Просмотреть файл

@ -244,6 +244,12 @@ nsSHEntry::SetPostData(nsIInputStream* aPostData) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetHasPostData(bool* aResult) {
*aResult = !!mPostData;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult) {
*aResult = mShared->mLayoutHistoryState;

Просмотреть файл

@ -1368,7 +1368,7 @@ class RequestDetails {
// See the above comment for more info.
initiatorURI: parentPrin?.isContentPrincipal ? parentPrin.URI : null,
type: isTop ? "main_frame" : "sub_frame",
method: bc.activeSessionHistoryEntry?.postData ? "post" : "get",
method: bc.activeSessionHistoryEntry?.hasPostData ? "post" : "get",
tabId: this.tabId,
// In this loop we are already explicitly accounting for ancestors, so
// we intentionally omit browsingContext even though we have |bc|. If