Commit 8123ec04 authored by Anny Gakhokidze's avatar Anny Gakhokidze
Browse files

Bug 1536468 - Make retrieval of WebBrowserPersistDocumentAttrs.cacheKey async...

Bug 1536468 - Make retrieval of WebBrowserPersistDocumentAttrs.cacheKey async in SessionHistory, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D24472

--HG--
extra : rebase_source : bf5ac32a5e89ec16c07d55d631e40014f729e75f
extra : source : b1bb781543ed7c2ad8dcc3e3146d7e3f4973195d
parent aa3c9302
......@@ -82,6 +82,8 @@ class SHEntryParent final : public PSHEntryParent {
static void GetOrCreate(PContentParent* aManager, nsISHEntry* aSHEntry,
MaybeNewPSHEntry& aResult);
LegacySHEntry* GetSHEntry() { return mEntry; }
protected:
void ActorDestroy(ActorDestroyReason aWhy) override;
......
......@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PSHEntry;
include protocol PWebBrowserPersistResources;
include protocol PWebBrowserPersistSerialize;
include protocol PFileDescriptorSet;
......@@ -30,7 +31,7 @@ struct WebBrowserPersistDocumentAttrs {
nsString title;
nsIReferrerInfo referrerInfo;
nsString contentDisposition;
uint32_t cacheKey;
nullable PSHEntry sessionHistoryEntry;
uint32_t persistFlags;
PrincipalInfo principal;
};
......
......@@ -13,6 +13,7 @@
#include "WebBrowserPersistLocalDocument.h"
#include "WebBrowserPersistResourcesChild.h"
#include "WebBrowserPersistSerializeChild.h"
#include "SHEntryChild.h"
namespace mozilla {
......@@ -55,7 +56,13 @@ void WebBrowserPersistDocumentChild::Start(
ENSURE(aDocument->GetCharacterSet(attrs.characterSet()));
ENSURE(aDocument->GetTitle(attrs.title()));
ENSURE(aDocument->GetContentDisposition(attrs.contentDisposition()));
ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey())));
RefPtr<dom::SHEntryChild> shEntryChild =
aDocument->GetHistory().downcast<dom::SHEntryChild>();
if (shEntryChild) {
attrs.sessionHistoryEntryChild() = shEntryChild.get();
}
ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags())));
ENSURE(aDocument->GetPrincipal(getter_AddRefs(principal)));
......
......@@ -39,7 +39,6 @@ class WebBrowserPersistLocalDocument final
void DecideContentType(nsACString& aContentType);
nsresult GetDocEncoder(const nsACString& aContentType, uint32_t aEncoderFlags,
nsIDocumentEncoder** aEncoder);
already_AddRefed<nsISHEntry> GetHistory();
virtual ~WebBrowserPersistLocalDocument();
};
......
......@@ -8,6 +8,7 @@
#include "WebBrowserPersistDocumentParent.h"
#include "WebBrowserPersistResourcesParent.h"
#include "WebBrowserPersistSerializeParent.h"
#include "SHEntryParent.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/BackgroundUtils.h"
......@@ -23,6 +24,9 @@ WebBrowserPersistRemoteDocument ::WebBrowserPersistRemoteDocument(
: mActor(aActor), mAttrs(aAttrs), mPostData(aPostData) {
nsresult rv;
mPrincipal = ipc::PrincipalInfoToPrincipal(mAttrs.principal(), &rv);
mSHEntry =
static_cast<dom::SHEntryParent*>(mAttrs.sessionHistoryEntryParent())
->GetSHEntry();
}
WebBrowserPersistRemoteDocument::~WebBrowserPersistRemoteDocument() {
......@@ -88,7 +92,10 @@ WebBrowserPersistRemoteDocument::GetContentDisposition(nsAString& aDisp) {
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetCacheKey(uint32_t* aCacheKey) {
*aCacheKey = mAttrs.cacheKey();
*aCacheKey = 0;
if (mSHEntry) {
*aCacheKey = mSHEntry->GetCacheKey();
}
return NS_OK;
}
......@@ -172,4 +179,12 @@ WebBrowserPersistRemoteDocument::WriteContent(
: NS_ERROR_FAILURE;
}
// Forcing WebBrowserPersistRemoteDocument to implement GetHistory is the
// easiest way to ensure that we can call GetHistory in
// WebBrowserPersistDocumentChild::Start
already_AddRefed<nsISHEntry> WebBrowserPersistRemoteDocument::GetHistory() {
MOZ_CRASH("We should not call GetHistory on WebBrowserPersistRemoteDocument");
return nullptr;
}
} // namespace mozilla
......@@ -40,6 +40,7 @@ class WebBrowserPersistRemoteDocument final
using Attrs = WebBrowserPersistDocumentAttrs;
WebBrowserPersistDocumentParent* mActor;
Attrs mAttrs;
nsCOMPtr<nsISHEntry> mSHEntry;
nsCOMPtr<nsIInputStream> mPostData;
nsCOMPtr<nsIPrincipal> mPrincipal;
......
......@@ -43,6 +43,7 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/docshell/shistory',
'/dom/base',
'/dom/html',
]
......
......@@ -14,6 +14,9 @@ interface nsIRemoteTab;
interface nsIWebBrowserPersistResourceVisitor;
interface nsIWebBrowserPersistWriteCompletion;
interface nsIReferrerInfo;
interface nsISHEntry;
native SHEntryRef(already_AddRefed<nsISHEntry>);
/**
* Interface for the URI-mapping information that can be supplied when
......@@ -120,6 +123,8 @@ interface nsIWebBrowserPersistDocument : nsISupports
in unsigned long aEncoderFlags,
in unsigned long aWrapColumn,
in nsIWebBrowserPersistWriteCompletion aCompletion);
[notxpcom, nostdcall] SHEntryRef GetHistory();
};
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment