Bug 1510569 - Use Maybe<T> directly in TabChild::PrepareProgressListenerData r=nika,Alex_Gaynor

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Barret Rennie 2019-04-03 17:29:28 +00:00
parent 27a7e12ecc
commit 08dfb4b9c8
3 changed files with 15 additions and 20 deletions

View File

@ -3310,47 +3310,43 @@ NS_IMETHODIMP TabChild::OnSecurityChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP TabChild::OnContentBlockingEvent(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aEvent) {
WebProgressData webProgressData;
Maybe<WebProgressData> webProgressData;
RequestData requestData;
nsresult rv = PrepareProgressListenerData(aWebProgress, aRequest,
webProgressData, requestData);
NS_ENSURE_SUCCESS(rv, rv);
Maybe<WebProgressData> maybeWebProgressData;
if (aWebProgress) {
maybeWebProgressData.emplace(webProgressData);
}
Unused << SendOnContentBlockingEvent(maybeWebProgressData, requestData,
aEvent);
Unused << SendOnContentBlockingEvent(webProgressData, requestData, aEvent);
return NS_OK;
}
nsresult TabChild::PrepareProgressListenerData(
nsIWebProgress* aWebProgress, nsIRequest* aRequest,
WebProgressData& aWebProgressData, RequestData& aRequestData) {
Maybe<WebProgressData>& aWebProgressData, RequestData& aRequestData) {
if (aWebProgress) {
aWebProgressData.emplace();
bool isTopLevel = false;
nsresult rv = aWebProgress->GetIsTopLevel(&isTopLevel);
NS_ENSURE_SUCCESS(rv, rv);
aWebProgressData.isTopLevel() = isTopLevel;
aWebProgressData->isTopLevel() = isTopLevel;
bool isLoadingDocument = false;
rv = aWebProgress->GetIsLoadingDocument(&isLoadingDocument);
NS_ENSURE_SUCCESS(rv, rv);
aWebProgressData.isLoadingDocument() = isLoadingDocument;
aWebProgressData->isLoadingDocument() = isLoadingDocument;
uint32_t loadType = 0;
rv = aWebProgress->GetLoadType(&loadType);
NS_ENSURE_SUCCESS(rv, rv);
aWebProgressData.loadType() = loadType;
aWebProgressData->loadType() = loadType;
uint64_t DOMWindowID = 0;
// The DOM Window ID getter here may throw if the inner or outer windows
// aren't created yet or are destroyed at the time we're making this call
// but that isn't fatal so ignore the exceptions here.
Unused << aWebProgress->GetDOMWindowID(&DOMWindowID);
aWebProgressData.DOMWindowID() = DOMWindowID;
aWebProgressData->DOMWindowID() = DOMWindowID;
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);

View File

@ -792,7 +792,7 @@ class TabChild final : public TabChildBase,
nsresult PrepareProgressListenerData(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
WebProgressData& aWebProgressData,
Maybe<WebProgressData>& aWebProgressData,
RequestData& aRequestData);
class DelayedDeleteRunnable;

View File

@ -2215,17 +2215,16 @@ mozilla::ipc::IPCResult TabParent::RecvOnContentBlockingEvent(
nsCOMPtr<nsIBrowser> browser =
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
if (browser) {
if (aWebProgressData.isNothing()) {
if (aWebProgressData) {
Unused << browser->CallWebProgressContentBlockingEventListeners(
false, false, false, 0, 0, aRequestData.requestURI(),
true, aWebProgressData->isTopLevel(),
aWebProgressData->isLoadingDocument(), aWebProgressData->loadType(),
aWebProgressData->DOMWindowID(), aRequestData.requestURI(),
aRequestData.originalRequestURI(), aRequestData.matchedList(),
aEvent);
} else {
Unused << browser->CallWebProgressContentBlockingEventListeners(
true, aWebProgressData.ref().isTopLevel(),
aWebProgressData.ref().isLoadingDocument(),
aWebProgressData.ref().loadType(),
aWebProgressData.ref().DOMWindowID(), aRequestData.requestURI(),
false, false, false, 0, 0, aRequestData.requestURI(),
aRequestData.originalRequestURI(), aRequestData.matchedList(),
aEvent);
}