Bug 1602318 - Add load identifier and copy-ctor to nsDocShellLoadState. r=nika
authorMatt Woodrow <mwoodrow@mozilla.com>
Sun, 26 Apr 2020 00:53:19 +0000
changeset 526110 cf6bf750f7aabce2f23a4cd895489807471ee904
parent 526109 cc172a5fcbc9ee106d3d75e13f68b63798b72af1
child 526111 6d02fda2ffc553839d5132bc5390b7bfd3480d2d
push id37350
push usernbeleuzu@mozilla.com
push dateSun, 26 Apr 2020 09:43:12 +0000
treeherdermozilla-central@21659f178a12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1602318
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1602318 - Add load identifier and copy-ctor to nsDocShellLoadState. r=nika Differential Revision: https://phabricator.services.mozilla.com/D72110
docshell/base/nsDocShellLoadState.cpp
docshell/base/nsDocShellLoadState.h
dom/ipc/DOMTypes.ipdlh
--- a/docshell/base/nsDocShellLoadState.cpp
+++ b/docshell/base/nsDocShellLoadState.cpp
@@ -80,17 +80,18 @@ nsDocShellLoadState::nsDocShellLoadState
       mLoadType(LOAD_NORMAL),
       mTarget(),
       mSrcdocData(VoidString()),
       mLoadFlags(0),
       mFirstParty(false),
       mHasValidUserGestureActivation(false),
       mTypeHint(VoidCString()),
       mFileName(VoidString()),
-      mIsFromProcessingFrameAttributes(false) {
+      mIsFromProcessingFrameAttributes(false),
+      mLoadIdentifier(0) {
   MOZ_ASSERT(aURI, "Cannot create a LoadState with a null URI!");
 }
 
 nsDocShellLoadState::nsDocShellLoadState(
     const DocShellLoadStateInit& aLoadState) {
   MOZ_ASSERT(aLoadState.URI(), "Cannot create a LoadState with a null URI!");
   mResultPrincipalURI = aLoadState.ResultPrincipalURI();
   mResultPrincipalURIIsSome = aLoadState.ResultPrincipalURIIsSome();
@@ -119,27 +120,63 @@ nsDocShellLoadState::nsDocShellLoadState
   mPrincipalToInherit = aLoadState.PrincipalToInherit();
   mStoragePrincipalToInherit = aLoadState.StoragePrincipalToInherit();
   mCsp = aLoadState.Csp();
   mOriginalURIString = aLoadState.OriginalURIString();
   mCancelContentJSEpoch = aLoadState.CancelContentJSEpoch();
   mPostDataStream = aLoadState.PostDataStream();
   mHeadersStream = aLoadState.HeadersStream();
   mSrcdocData = aLoadState.SrcdocData();
-  mResultPrincipalURI = aLoadState.ResultPrincipalURI();
+  mLoadIdentifier = aLoadState.LoadIdentifier();
   if (!aLoadState.SHEntry() || !StaticPrefs::fission_sessionHistoryInParent()) {
     return;
   }
   if (XRE_IsParentProcess()) {
     mSHEntry = static_cast<LegacySHEntry*>(aLoadState.SHEntry());
   } else {
     mSHEntry = static_cast<SHEntryChild*>(aLoadState.SHEntry());
   }
 }
 
+nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
+    : mReferrerInfo(aOther.mReferrerInfo),
+      mURI(aOther.mURI),
+      mOriginalURI(aOther.mOriginalURI),
+      mResultPrincipalURI(aOther.mResultPrincipalURI),
+      mResultPrincipalURIIsSome(aOther.mResultPrincipalURIIsSome),
+      mTriggeringPrincipal(aOther.mTriggeringPrincipal),
+      mCsp(aOther.mCsp),
+      mKeepResultPrincipalURIIfSet(aOther.mKeepResultPrincipalURIIfSet),
+      mLoadReplace(aOther.mLoadReplace),
+      mInheritPrincipal(aOther.mInheritPrincipal),
+      mPrincipalIsExplicit(aOther.mPrincipalIsExplicit),
+      mPrincipalToInherit(aOther.mPrincipalToInherit),
+      mStoragePrincipalToInherit(aOther.mStoragePrincipalToInherit),
+      mForceAllowDataURI(aOther.mForceAllowDataURI),
+      mOriginalFrameSrc(aOther.mOriginalFrameSrc),
+      mIsFormSubmission(aOther.mIsFormSubmission),
+      mLoadType(aOther.mLoadType),
+      mSHEntry(aOther.mSHEntry),
+      mTarget(aOther.mTarget),
+      mPostDataStream(aOther.mPostDataStream),
+      mHeadersStream(aOther.mHeadersStream),
+      mSrcdocData(aOther.mSrcdocData),
+      mSourceBrowsingContext(aOther.mSourceBrowsingContext),
+      mBaseURI(aOther.mBaseURI),
+      mLoadFlags(aOther.mLoadFlags),
+      mFirstParty(aOther.mFirstParty),
+      mHasValidUserGestureActivation(aOther.mHasValidUserGestureActivation),
+      mTypeHint(aOther.mTypeHint),
+      mFileName(aOther.mFileName),
+      mIsFromProcessingFrameAttributes(aOther.mIsFromProcessingFrameAttributes),
+      mPendingRedirectedChannel(aOther.mPendingRedirectedChannel),
+      mOriginalURIString(aOther.mOriginalURIString),
+      mCancelContentJSEpoch(aOther.mCancelContentJSEpoch),
+      mLoadIdentifier(aOther.mLoadIdentifier) {}
+
 nsDocShellLoadState::~nsDocShellLoadState() {}
 
 nsresult nsDocShellLoadState::CreateFromPendingChannel(
     nsIChannel* aPendingChannel, nsDocShellLoadState** aResult) {
   // Create the nsDocShellLoadState object with default state pulled from the
   // passed-in channel.
   nsCOMPtr<nsIURI> uri;
   nsresult rv = aPendingChannel->GetURI(getter_AddRefs(uri));
@@ -732,16 +769,17 @@ DocShellLoadStateInit nsDocShellLoadStat
   loadState.Csp() = mCsp;
   loadState.OriginalURIString() = mOriginalURIString;
   loadState.CancelContentJSEpoch() = mCancelContentJSEpoch;
   loadState.ReferrerInfo() = mReferrerInfo;
   loadState.PostDataStream() = mPostDataStream;
   loadState.HeadersStream() = mHeadersStream;
   loadState.SrcdocData() = mSrcdocData;
   loadState.ResultPrincipalURI() = mResultPrincipalURI;
+  loadState.LoadIdentifier() = mLoadIdentifier;
   if (!mSHEntry || !StaticPrefs::fission_sessionHistoryInParent()) {
     // Without the pref, we don't have an actor for shentry and thus
     // we can't serialize it. We could write custom (de)serializers,
     // but a session history rewrite is on the way anyway.
     return loadState;
   }
   if (XRE_IsParentProcess()) {
     loadState.SHEntry() = static_cast<CrossProcessSHEntry*>(
--- a/docshell/base/nsDocShellLoadState.h
+++ b/docshell/base/nsDocShellLoadState.h
@@ -38,16 +38,17 @@ class nsDocShellLoadState final {
   using MaybeDiscarded = mozilla::dom::MaybeDiscarded<T>;
 
  public:
   NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
 
   explicit nsDocShellLoadState(nsIURI* aURI);
   explicit nsDocShellLoadState(
       const mozilla::dom::DocShellLoadStateInit& aLoadState);
+  explicit nsDocShellLoadState(const nsDocShellLoadState& aOther);
 
   static nsresult CreateFromPendingChannel(nsIChannel* aPendingChannel,
                                            nsDocShellLoadState** aResult);
 
   static nsresult CreateFromLoadURIOptions(
       nsISupports* aConsumer, const nsAString& aURI,
       const mozilla::dom::LoadURIOptions& aLoadURIOptions,
       nsDocShellLoadState** aResult);
@@ -223,16 +224,19 @@ class nsDocShellLoadState final {
 
   void SetCancelContentJSEpoch(int32_t aCancelEpoch) {
     mCancelContentJSEpoch.emplace(aCancelEpoch);
   }
   const mozilla::Maybe<int32_t>& GetCancelContentJSEpoch() const {
     return mCancelContentJSEpoch;
   }
 
+  void SetLoadIdentifier(uint32_t aIdent) { mLoadIdentifier = aIdent; }
+  uint32_t GetLoadIdentifier() const { return mLoadIdentifier; }
+
   // When loading a document through nsDocShell::LoadURI(), a special set of
   // flags needs to be set based on other values in nsDocShellLoadState. This
   // function calculates those flags, before the LoadState is passed to
   // nsDocShell::InternalLoad.
   void CalculateLoadURIFlags();
 
   mozilla::dom::DocShellLoadStateInit Serialize();
 
@@ -383,11 +387,17 @@ class nsDocShellLoadState final {
   // An optional string representation of mURI, before any
   // fixups were applied, so that we can send it to a search
   // engine service if needed.
   mozilla::Maybe<nsCString> mOriginalURIString;
 
   // An optional value to pass to nsIDocShell::setCancelJSEpoch
   // when initiating the load.
   mozilla::Maybe<int32_t> mCancelContentJSEpoch;
+
+  // An optional identifier that refers to a DocumentLoadListener
+  // created in the parent process for this loads. DocumentChannels
+  // created in the content process can use this to find and attach
+  // to the in progress load.
+  uint32_t mLoadIdentifier;
 };
 
 #endif /* nsDocShellLoadState_h__ */
--- a/dom/ipc/DOMTypes.ipdlh
+++ b/dom/ipc/DOMTypes.ipdlh
@@ -280,16 +280,18 @@ struct DocShellLoadStateInit
   // not supported. This is the case when 'fission.sessionHistoryInParent'
   // pref is off.
   CrossProcessSHEntry SHEntry;
 
   // Fields missing due to lack of need or serialization
   // nsCOMPtr<nsIDocShell> mSourceDocShell;
   // bool mIsSrcDocLoad; // useless without sourcedocshell
   // nsIChannel pendingRedirectedChannel; // sent through other mechanism
+
+  uint32_t LoadIdentifier;
 };
 
 struct TimedChannelInfo
 {
   bool timingEnabled;
   int8_t redirectCount;
   int8_t internalRedirectCount;
   TimeStamp asyncOpen;