diff --git a/docshell/base/IHistory.h b/docshell/base/IHistory.h index 04777ed9497..b03c718508a 100644 --- a/docshell/base/IHistory.h +++ b/docshell/base/IHistory.h @@ -52,7 +52,7 @@ namespace mozilla { } #define IHISTORY_IID \ - {0x6f736049, 0x6370, 0x4376, {0xb7, 0x17, 0xfa, 0xfc, 0x0b, 0x4f, 0xd0, 0xf1}} + {0x6f733924, 0x6321, 0x4384, {0x01, 0xee, 0x8e, 0x7d, 0xfb, 0xde, 0xe7, 0xa8}} class IHistory : public nsISupports { @@ -71,7 +71,7 @@ public: * UnregisterVisitedCallback. * * @pre aURI must not be null. - * @pre aLink must not be null. + * @pre aLink may be null only in the MOZ_IPC parent process. * * @param aURI * The URI to check. diff --git a/dom/ipc/ContentProcessChild.cpp b/dom/ipc/ContentProcessChild.cpp index ed9f2c56e41..513f865b24b 100644 --- a/dom/ipc/ContentProcessChild.cpp +++ b/dom/ipc/ContentProcessChild.cpp @@ -45,8 +45,11 @@ #include "mozilla/ipc/XPCShellEnvironment.h" #include "mozilla/jsipc/PContextWrapperChild.h" +#include "History.h" #include "nsXULAppAPI.h" +#include "nsDocShellCID.h" +#include "nsNetUtil.h" #include "base/message_loop.h" #include "base/task.h" @@ -55,6 +58,7 @@ using namespace mozilla::ipc; using namespace mozilla::net; +using namespace mozilla::places; namespace mozilla { namespace dom { @@ -219,5 +223,13 @@ ContentProcessChild::RecvNotifyRemotePrefObserver(const nsCString& aDomain) return true; } +bool +ContentProcessChild::RecvNotifyVisited(const IPC::URI& aURI) +{ + nsCOMPtr newURI = aURI; + History::GetSingleton()->NotifyVisited(newURI); + return true; +} + } // namespace dom } // namespace mozilla diff --git a/dom/ipc/ContentProcessChild.h b/dom/ipc/ContentProcessChild.h index 3d6c590fe9c..d47be3ebfbb 100644 --- a/dom/ipc/ContentProcessChild.h +++ b/dom/ipc/ContentProcessChild.h @@ -149,6 +149,8 @@ public: virtual bool RecvSetOffline(const PRBool& offline); + virtual bool RecvNotifyVisited(const IPC::URI& aURI); + nsresult AddRemotePrefObserver(const nsCString &aDomain, const nsCString &aPrefRoot, nsIObserver *aObserver, PRBool aHoldWeak); diff --git a/dom/ipc/ContentProcessParent.cpp b/dom/ipc/ContentProcessParent.cpp index d713552bc74..d13492e7968 100644 --- a/dom/ipc/ContentProcessParent.cpp +++ b/dom/ipc/ContentProcessParent.cpp @@ -40,6 +40,7 @@ #include "ContentProcessParent.h" #include "TabParent.h" +#include "History.h" #include "mozilla/ipc/TestShellParent.h" #include "mozilla/net/NeckoParent.h" #include "nsIPrefBranch.h" @@ -55,6 +56,7 @@ using namespace mozilla::ipc; using namespace mozilla::net; +using namespace mozilla::places; using mozilla::MonitorAutoEnter; namespace mozilla { @@ -398,6 +400,15 @@ ContentProcessParent::RequestRunToCompletion() } +bool +ContentProcessParent::RecvStartVisitedQuery(const IPC::URI& aURI) +{ + nsCOMPtr newURI = aURI; + IHistory *history = nsContentUtils::GetHistory(); + history->RegisterVisitedCallback(newURI, nsnull); + return true; +} + bool ContentProcessParent::RecvVisitURI(const IPC::URI& uri, const IPC::URI& referrer, diff --git a/dom/ipc/ContentProcessParent.h b/dom/ipc/ContentProcessParent.h index baec3e3a652..f2a933fb73d 100644 --- a/dom/ipc/ContentProcessParent.h +++ b/dom/ipc/ContentProcessParent.h @@ -143,6 +143,8 @@ private: const IPC::URI& referrer, const PRUint32& flags); + virtual bool RecvStartVisitedQuery(const IPC::URI& uri); + mozilla::Monitor mMonitor; GeckoChildProcessHost* mSubprocess; diff --git a/dom/ipc/Makefile.in b/dom/ipc/Makefile.in index ab9f80237d9..1cac27734b8 100644 --- a/dom/ipc/Makefile.in +++ b/dom/ipc/Makefile.in @@ -78,6 +78,7 @@ include $(topsrcdir)/config/rules.mk LOCAL_INCLUDES += \ -I$(srcdir)/../../content/base/src \ + -I$(srcdir)/../../toolkit/components/places/src \ -I$(srcdir)/../../content/events/src \ -I$(srcdir)/../src/geolocation \ -I$(topsrcdir)/chrome/src \ diff --git a/dom/ipc/PContentProcess.ipdl b/dom/ipc/PContentProcess.ipdl index 934ff267d63..a846924be0b 100644 --- a/dom/ipc/PContentProcess.ipdl +++ b/dom/ipc/PContentProcess.ipdl @@ -68,12 +68,15 @@ child: async SetOffline(PRBool offline); + async NotifyVisited(URI uri); + NotifyRemotePrefObserver(nsCString aDomain); parent: PNecko(); async VisitURI(URI uri, URI referrer, PRUint32 flags); + async StartVisitedQuery(URI uri); // prefs-related messages ... sync GetPrefType(nsCString prefName) returns (PRInt32 retValue, nsresult rv); diff --git a/toolkit/components/places/src/History.cpp b/toolkit/components/places/src/History.cpp index 5bffa764718..dc6ad760b4d 100644 --- a/toolkit/components/places/src/History.cpp +++ b/toolkit/components/places/src/History.cpp @@ -39,6 +39,7 @@ #ifdef MOZ_IPC #include "mozilla/dom/ContentProcessChild.h" +#include "mozilla/dom/ContentProcessParent.h" #include "nsXULAppAPI.h" #endif @@ -160,6 +161,18 @@ public: { NS_PRECONDITION(aURI, "Null URI"); +#ifdef MOZ_IPC + // If we are a content process, always remote the request to the + // parent process. + if (XRE_GetProcessType() == GeckoProcessType_Content) { + mozilla::dom::ContentProcessChild * cpc = + mozilla::dom::ContentProcessChild::GetSingleton(); + NS_ASSERTION(cpc, "Content Protocol is NULL!"); + cpc->SendStartVisitedQuery(IPC::URI(aURI)); + return NS_OK; + } +#endif + nsNavHistory* navHist = nsNavHistory::GetHistoryService(); NS_ENSURE_TRUE(navHist, NS_ERROR_FAILURE); mozIStorageStatement* stmt = navHist->GetStatementById(DB_IS_PAGE_VISITED); @@ -911,6 +924,15 @@ History::NotifyVisited(nsIURI* aURI) { NS_ASSERTION(aURI, "Ruh-roh! A NULL URI was passed to us!"); +#ifdef MOZ_IPC + if (XRE_GetProcessType() == GeckoProcessType_Default) { + mozilla::dom::ContentProcessParent* cpp = + mozilla::dom::ContentProcessParent::GetSingleton(); + NS_ASSERTION(cpp, "Content Protocol is NULL!"); + (void)cpp->SendNotifyVisited(IPC::URI(aURI)); + } +#endif + // If the hash table has not been initialized, then we have nothing to notify // about. if (!mObservers.IsInitialized()) { @@ -1082,7 +1104,14 @@ History::RegisterVisitedCallback(nsIURI* aURI, Link* aLink) { NS_ASSERTION(aURI, "Must pass a non-null URI!"); - NS_ASSERTION(aLink, "Must pass a non-null Link object!"); +#ifdef MOZ_IPC + if (XRE_GetProcessType() == GeckoProcessType_Content) { + NS_PRECONDITION(aLink, "Must pass a non-null URI!"); + } +#else + NS_PRECONDITION(aLink, "Must pass a non-null URI!"); +#endif + // First, ensure that our hash table is setup. if (!mObservers.IsInitialized()) { @@ -1105,7 +1134,7 @@ History::RegisterVisitedCallback(nsIURI* aURI, // Links wanting to know about this URI. Therefore, we should query the // database now. nsresult rv = VisitedQuery::Start(aURI); - if (NS_FAILED(rv)) { + if (NS_FAILED(rv) || !aLink) { // Remove our array from the hashtable so we don't keep it around. mObservers.RemoveEntry(aURI); return rv; diff --git a/toolkit/components/places/src/Makefile.in b/toolkit/components/places/src/Makefile.in index 8054770519d..e35a9d7418c 100644 --- a/toolkit/components/places/src/Makefile.in +++ b/toolkit/components/places/src/Makefile.in @@ -50,6 +50,11 @@ EXPORT_LIBRARY = 1 MODULE_NAME = nsPlacesModule IS_COMPONENT = 1 +EXPORTS_NAMESPACES = mozilla/places + +EXPORTS_mozilla/places = \ + History.h \ + $(NULL) CPPSRCS = \ nsAnnoProtocolHandler.cpp \