зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1510569 - Refactor BrowserParent nsIWebProgress handlers r=kmag
The BrowserParent's IPC receive methods for nsIWebProgress events in the BrowserChild were all doing the same set up to ensure they had the correct state to process them. This has now been refactored out into a single method. Differential Revision: https://phabricator.services.mozilla.com/D30730 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cf23208d84
Коммит
bda47d9434
|
@ -2379,22 +2379,11 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnProgressChange(
|
|||
const RequestData& aRequestData, const int32_t aCurSelfProgress,
|
||||
const int32_t aMaxSelfProgress, const int32_t aCurTotalProgress,
|
||||
const int32_t aMaxTotalProgress) {
|
||||
nsCOMPtr<nsIBrowser> browser =
|
||||
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
|
||||
|
||||
if (!browser) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener =
|
||||
do_QueryInterface(manager);
|
||||
|
||||
if (!managerAsListener) {
|
||||
// We are no longer remote, so we cannot propagate this message.
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -2414,22 +2403,11 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnStatusChange(
|
|||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, const nsresult aStatus,
|
||||
const nsString& aMessage) {
|
||||
nsCOMPtr<nsIBrowser> browser =
|
||||
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
|
||||
|
||||
if (!browser) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener =
|
||||
do_QueryInterface(manager);
|
||||
|
||||
if (!managerAsListener) {
|
||||
// We are no longer remote, so we cannot propagate this message.
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -2447,17 +2425,11 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnStatusChange(
|
|||
mozilla::ipc::IPCResult BrowserParent::RecvOnContentBlockingEvent(
|
||||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, const uint32_t& aEvent) {
|
||||
nsCOMPtr<nsIBrowser> browser =
|
||||
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
|
||||
if (browser) {
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener =
|
||||
do_QueryInterface(manager);
|
||||
if (!managerAsListener) {
|
||||
// We are no longer remote, so we cannot propagate this message.
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -2468,11 +2440,42 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnContentBlockingEvent(
|
|||
|
||||
Unused << managerAsListener->OnContentBlockingEvent(webProgress, request,
|
||||
aEvent);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
bool BrowserParent::GetWebProgressListener(
|
||||
nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
|
||||
nsIWebProgressListener** aOutListener) {
|
||||
MOZ_ASSERT(aOutBrowser);
|
||||
MOZ_ASSERT(aOutManager);
|
||||
MOZ_ASSERT(aOutListener);
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser =
|
||||
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
|
||||
if (!browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(manager);
|
||||
if (!listener) {
|
||||
// We are no longer remote so we cannot forward this event.
|
||||
return false;
|
||||
}
|
||||
|
||||
browser.forget(aOutBrowser);
|
||||
manager.forget(aOutManager);
|
||||
listener.forget(aOutListener);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BrowserParent::ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, nsCOMPtr<nsIWebProgress>& aOutWebProgress,
|
||||
|
|
|
@ -284,6 +284,10 @@ class BrowserParent final : public PBrowserParent,
|
|||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, const uint32_t& aEvent);
|
||||
|
||||
bool GetWebProgressListener(nsIBrowser** aOutBrowser,
|
||||
nsIWebProgress** aOutManager,
|
||||
nsIWebProgressListener** aOutListener);
|
||||
|
||||
void ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData,
|
||||
|
|
Загрузка…
Ссылка в новой задаче