Bug 1184701 - Make the moz-page-thumb protocol work in the privileged about content process. r=haik,valentin

Differential Revision: https://phabricator.services.mozilla.com/D68281
This commit is contained in:
Mike Conley
2020-04-06 17:46:52 +00:00
parent 74bf7bc8ac
commit 94fc4edf41
17 changed files with 723 additions and 212 deletions

View File

@@ -148,6 +148,9 @@ class ExtensionStreamGetter : public RefCounted<ExtensionStreamGetter> {
// Handle file descriptor being returned from the parent
void OnFD(const FileDescriptor& aFD);
static void CancelRequest(nsIStreamListener* aListener, nsIChannel* aChannel,
nsresult aResult);
MOZ_DECLARE_REFCOUNTED_TYPENAME(ExtensionStreamGetter)
private:
@@ -257,8 +260,10 @@ Result<Ok, nsresult> ExtensionStreamGetter::GetAsync(
return Ok();
}
static void CancelRequest(nsIStreamListener* aListener, nsIChannel* aChannel,
nsresult aResult) {
// static
void ExtensionStreamGetter::CancelRequest(nsIStreamListener* aListener,
nsIChannel* aChannel,
nsresult aResult) {
MOZ_ASSERT(aListener);
MOZ_ASSERT(aChannel);
@@ -464,7 +469,7 @@ void OpenWhenReady(
nsIStreamListener* aListener) -> already_AddRefed<Promise> {
nsresult rv = aCallback(aListener, channel);
if (NS_FAILED(rv)) {
CancelRequest(aListener, channel, rv);
ExtensionStreamGetter::CancelRequest(aListener, channel, rv);
}
return nullptr;
},
@@ -840,7 +845,10 @@ Result<Ok, nsresult> ExtensionProtocolHandler::NewFD(
}
// Set the channel's content type using the provided URI's type
void SetContentType(nsIURI* aURI, nsIChannel* aChannel) {
// static
void ExtensionProtocolHandler::SetContentType(nsIURI* aURI,
nsIChannel* aChannel) {
nsresult rv;
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
if (NS_SUCCEEDED(rv)) {
@@ -853,9 +861,11 @@ void SetContentType(nsIURI* aURI, nsIChannel* aChannel) {
}
// Gets a SimpleChannel that wraps the provided ExtensionStreamGetter
static void NewSimpleChannel(nsIURI* aURI, nsILoadInfo* aLoadinfo,
ExtensionStreamGetter* aStreamGetter,
nsIChannel** aRetVal) {
// static
void ExtensionProtocolHandler::NewSimpleChannel(
nsIURI* aURI, nsILoadInfo* aLoadinfo, ExtensionStreamGetter* aStreamGetter,
nsIChannel** aRetVal) {
nsCOMPtr<nsIChannel> channel = NS_NewSimpleChannel(
aURI, aLoadinfo, aStreamGetter,
[](nsIStreamListener* listener, nsIChannel* simpleChannel,
@@ -869,8 +879,12 @@ static void NewSimpleChannel(nsIURI* aURI, nsILoadInfo* aLoadinfo,
}
// Gets a SimpleChannel that wraps the provided channel
static void NewSimpleChannel(nsIURI* aURI, nsILoadInfo* aLoadinfo,
nsIChannel* aChannel, nsIChannel** aRetVal) {
// static
void ExtensionProtocolHandler::NewSimpleChannel(nsIURI* aURI,
nsILoadInfo* aLoadinfo,
nsIChannel* aChannel,
nsIChannel** aRetVal) {
nsCOMPtr<nsIChannel> channel = NS_NewSimpleChannel(
aURI, aLoadinfo, aChannel,
[](nsIStreamListener* listener, nsIChannel* simpleChannel,