Bug 565163 - e10s: nsHTMLDNSPrefetch needs to be forwarded to chrome. r=dougt

--HG--
extra : rebase_source : bb91a8287ad6484846c89f57d916c97f3c05fb70
This commit is contained in:
Steffen Imhof 2010-07-26 11:49:09 -07:00
Родитель 33af957293
Коммит af9b6e4d68
8 изменённых файлов: 72 добавлений и 0 удалений

Просмотреть файл

@ -52,6 +52,12 @@ EXPORTS = \
nsClientRect.h \
$(NULL)
ifdef MOZ_IPC
EXPORTS += \
nsHTMLDNSPrefetch.h \
$(NULL)
endif
CPPSRCS = \
nsClientRect.cpp \
nsHTMLDNSPrefetch.cpp \
@ -121,6 +127,8 @@ endif
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
INCLUDES += \
-I$(srcdir)/../../../base/src \

Просмотреть файл

@ -36,6 +36,12 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_IPC
#include "base/basictypes.h"
#include "mozilla/net/NeckoCommon.h"
#include "mozilla/net/NeckoChild.h"
#endif
#include "nsHTMLDNSPrefetch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -129,6 +135,19 @@ nsHTMLDNSPrefetch::IsAllowed (nsIDocument *aDocument)
nsresult
nsHTMLDNSPrefetch::Prefetch(Link *aElement, PRUint16 flags)
{
#ifdef MOZ_IPC
if (mozilla::net::IsNeckoChild()) {
// Instead of transporting the Link object to the other process
// we are using the hostname based function here, too. Compared to the
// IPC the performance hit should be negligible.
nsAutoString hostname;
nsresult rv = aElement->GetHostname(hostname);
NS_ENSURE_SUCCESS(rv,rv);
return Prefetch(hostname, flags);
}
#endif
if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
return NS_ERROR_NOT_AVAILABLE;
@ -156,6 +175,13 @@ nsHTMLDNSPrefetch::PrefetchHigh(Link *aElement)
nsresult
nsHTMLDNSPrefetch::Prefetch(nsAString &hostname, PRUint16 flags)
{
#ifdef MOZ_IPC
if (mozilla::net::IsNeckoChild()) {
mozilla::net::gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
return NS_OK;
}
#endif
if (!(sInitialized && sDNSService && sPrefetches && sDNSListener))
return NS_ERROR_NOT_AVAILABLE;

Просмотреть файл

@ -56,6 +56,12 @@ class Link;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace net {
class NeckoParent;
} // namespace net
} // namespace mozilla
class nsHTMLDNSPrefetch
{
public:
@ -136,6 +142,10 @@ public:
nsWeakPtr mElement;
} mEntries[sMaxDeferred];
};
#ifdef MOZ_IPC
friend class mozilla::net::NeckoParent;
#endif
};
#endif

Просмотреть файл

@ -41,6 +41,7 @@
#include "mozilla/dom/PContentDialogChild.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserSetup.h"
#include "nsEmbedCID.h"
#include "nsComponentManagerUtils.h"
#include "nsIBaseWindow.h"
@ -453,6 +454,17 @@ TabChild::RecvCreateWidget(const MagicWindowHandle& parentWidget)
baseWindow->SetVisibility(PR_TRUE);
#endif
// IPC uses a WebBrowser object for which DNS prefetching is turned off
// by default. But here we really want it, so enable it explicitly
nsCOMPtr<nsIWebBrowserSetup> webBrowserSetup = do_QueryInterface(baseWindow);
if (webBrowserSetup) {
webBrowserSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_DNS_PREFETCH,
PR_TRUE);
} else {
NS_WARNING("baseWindow doesn't QI to nsIWebBrowserSetup, skipping "
"DNS prefetching enable step.");
}
return InitTabChildGlobal();
}

Просмотреть файл

@ -42,6 +42,7 @@
#define mozilla_net_NeckoCommon_h
#include "nsXULAppAPI.h"
#include "prenv.h"
#if defined(DEBUG) || defined(ENABLE_TESTS)
# define NECKO_ERRORS_ARE_FATAL_DEFAULT true

Просмотреть файл

@ -43,6 +43,8 @@
#include "mozilla/net/HttpChannelParent.h"
#include "mozilla/net/CookieServiceParent.h"
#include "nsHTMLDNSPrefetch.h"
namespace mozilla {
namespace net {
@ -84,5 +86,14 @@ NeckoParent::DeallocPCookieService(PCookieServiceParent* cs)
return true;
}
bool
NeckoParent::RecvHTMLDNSPrefetch(const nsString& hostname,
const PRUint16& flags)
{
nsAutoString h(hostname);
nsHTMLDNSPrefetch::Prefetch(h, flags);
return true;
}
}} // mozilla::net

Просмотреть файл

@ -60,6 +60,8 @@ protected:
virtual bool DeallocPHttpChannel(PHttpChannelParent*);
virtual PCookieServiceParent* AllocPCookieService();
virtual bool DeallocPCookieService(PCookieServiceParent*);
virtual bool RecvHTMLDNSPrefetch(const nsString& hostname,
const PRUint16& flags);
};
} // namespace net

Просмотреть файл

@ -59,6 +59,8 @@ parent:
PHttpChannel(nullable PBrowser iframeEmbedding);
PCookieService();
HTMLDNSPrefetch(nsString hostname, PRUint16 flags);
};