Bug 516728 - Remote link-visited information. r=sdwilsh, sr=bz

--HG--
extra : rebase_source : bb818d7c563451232e7729f49c4fd2276dd47dd0
This commit is contained in:
Doug Turner 2010-07-02 08:50:41 -07:00
Родитель 8800a96ec4
Коммит 223acf49ec
9 изменённых файлов: 76 добавлений и 4 удалений

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

@ -52,7 +52,7 @@ namespace mozilla {
} }
#define IHISTORY_IID \ #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 class IHistory : public nsISupports
{ {
@ -71,7 +71,7 @@ public:
* UnregisterVisitedCallback. * UnregisterVisitedCallback.
* *
* @pre aURI must not be null. * @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 * @param aURI
* The URI to check. * The URI to check.

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

@ -54,6 +54,10 @@
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "History.h"
#include "nsDocShellCID.h"
#include "nsNetUtil.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/task.h" #include "base/task.h"
@ -62,6 +66,7 @@
using namespace mozilla::ipc; using namespace mozilla::ipc;
using namespace mozilla::net; using namespace mozilla::net;
using namespace mozilla::places;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -343,5 +348,13 @@ ContentChild::RecvNotifyRemotePrefObserver(const nsCString& aPref)
return true; return true;
} }
bool
ContentChild::RecvNotifyVisited(const IPC::URI& aURI)
{
nsCOMPtr<nsIURI> newURI = aURI;
History::GetService()->NotifyVisited(newURI);
return true;
}
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

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

@ -88,6 +88,8 @@ public:
virtual bool RecvSetOffline(const PRBool& offline); virtual bool RecvSetOffline(const PRBool& offline);
virtual bool RecvNotifyVisited(const IPC::URI& aURI);
/** /**
* Notify |aObserver| of changes to |aPrefRoot|.|aDomain|. If * Notify |aObserver| of changes to |aPrefRoot|.|aDomain|. If
* |aHoldWeak|, only a weak reference to |aObserver| is held. * |aHoldWeak|, only a weak reference to |aObserver| is held.

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

@ -40,6 +40,7 @@
#include "ContentParent.h" #include "ContentParent.h"
#include "TabParent.h" #include "TabParent.h"
#include "History.h"
#include "mozilla/ipc/TestShellParent.h" #include "mozilla/ipc/TestShellParent.h"
#include "mozilla/net/NeckoParent.h" #include "mozilla/net/NeckoParent.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
@ -55,6 +56,7 @@
using namespace mozilla::ipc; using namespace mozilla::ipc;
using namespace mozilla::net; using namespace mozilla::net;
using namespace mozilla::places;
using mozilla::MonitorAutoEnter; using mozilla::MonitorAutoEnter;
namespace mozilla { namespace mozilla {
@ -430,6 +432,15 @@ ContentParent::RequestRunToCompletion()
return !!mRunToCompletionDepth; return !!mRunToCompletionDepth;
} }
bool
ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
{
nsCOMPtr<nsIURI> newURI = aURI;
IHistory *history = nsContentUtils::GetHistory();
history->RegisterVisitedCallback(newURI, nsnull);
return true;
}
/* void onDispatchedEvent (in nsIThreadInternal thread); */ /* void onDispatchedEvent (in nsIThreadInternal thread); */
NS_IMETHODIMP NS_IMETHODIMP
ContentParent::OnDispatchedEvent(nsIThreadInternal *thread) ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)

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

@ -145,6 +145,8 @@ private:
void EnsurePrefService(); void EnsurePrefService();
void EnsurePermissionService(); void EnsurePermissionService();
virtual bool RecvStartVisitedQuery(const IPC::URI& uri);
mozilla::Monitor mMonitor; mozilla::Monitor mMonitor;
GeckoChildProcessHost* mSubprocess; GeckoChildProcessHost* mSubprocess;

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

@ -79,6 +79,7 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \ LOCAL_INCLUDES += \
-I$(srcdir)/../../content/base/src \ -I$(srcdir)/../../content/base/src \
-I$(srcdir)/../../content/events/src \ -I$(srcdir)/../../content/events/src \
-I$(srcdir)/../../toolkit/components/places/src \
-I$(srcdir)/../src/geolocation \ -I$(srcdir)/../src/geolocation \
-I$(topsrcdir)/chrome/src \ -I$(topsrcdir)/chrome/src \
$(NULL) $(NULL)

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

@ -68,6 +68,8 @@ child:
async SetOffline(PRBool offline); async SetOffline(PRBool offline);
async NotifyVisited(URI uri);
NotifyRemotePrefObserver(nsCString aDomain); NotifyRemotePrefObserver(nsCString aDomain);
parent: parent:
@ -75,6 +77,8 @@ parent:
// Services remoting // Services remoting
async StartVisitedQuery(URI uri);
// PrefService messages // PrefService messages
sync GetPrefType(nsCString prefName) returns (PRInt32 retValue, nsresult rv); sync GetPrefType(nsCString prefName) returns (PRInt32 retValue, nsresult rv);
sync GetBoolPref(nsCString prefName) returns (PRBool retValue, nsresult rv); sync GetBoolPref(nsCString prefName) returns (PRBool retValue, nsresult rv);

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

@ -37,6 +37,12 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifdef MOZ_IPC
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentParent.h"
#include "nsXULAppAPI.h"
#endif
#include "History.h" #include "History.h"
#include "nsNavHistory.h" #include "nsNavHistory.h"
#include "nsNavBookmarks.h" #include "nsNavBookmarks.h"
@ -155,6 +161,18 @@ public:
{ {
NS_PRECONDITION(aURI, "Null URI"); 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::ContentChild * cpc =
mozilla::dom::ContentChild::GetSingleton();
NS_ASSERTION(cpc, "Content Protocol is NULL!");
(void)cpc->SendStartVisitedQuery(IPC::URI(aURI));
return NS_OK;
}
#endif
nsNavHistory* navHist = nsNavHistory::GetHistoryService(); nsNavHistory* navHist = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHist, NS_ERROR_FAILURE); NS_ENSURE_TRUE(navHist, NS_ERROR_FAILURE);
mozIStorageStatement* stmt = navHist->GetStatementById(DB_IS_PAGE_VISITED); mozIStorageStatement* stmt = navHist->GetStatementById(DB_IS_PAGE_VISITED);
@ -956,6 +974,15 @@ History::NotifyVisited(nsIURI* aURI)
{ {
NS_ASSERTION(aURI, "Ruh-roh! A NULL URI was passed to us!"); NS_ASSERTION(aURI, "Ruh-roh! A NULL URI was passed to us!");
#ifdef MOZ_IPC
if (XRE_GetProcessType() == GeckoProcessType_Default) {
mozilla::dom::ContentParent* cpp =
mozilla::dom::ContentParent::GetSingleton(PR_FALSE);
if (cpp)
(void)cpp->SendNotifyVisited(IPC::URI(aURI));
}
#endif
// If the hash table has not been initialized, then we have nothing to notify // If the hash table has not been initialized, then we have nothing to notify
// about. // about.
if (!mObservers.IsInitialized()) { if (!mObservers.IsInitialized()) {
@ -1135,7 +1162,14 @@ History::RegisterVisitedCallback(nsIURI* aURI,
Link* aLink) Link* aLink)
{ {
NS_ASSERTION(aURI, "Must pass a non-null URI!"); 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. // First, ensure that our hash table is setup.
if (!mObservers.IsInitialized()) { if (!mObservers.IsInitialized()) {
@ -1158,7 +1192,7 @@ History::RegisterVisitedCallback(nsIURI* aURI,
// Links wanting to know about this URI. Therefore, we should query the // Links wanting to know about this URI. Therefore, we should query the
// database now. // database now.
nsresult rv = VisitedQuery::Start(aURI); 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. // Remove our array from the hashtable so we don't keep it around.
mObservers.RemoveEntry(aURI); mObservers.RemoveEntry(aURI);
return rv; return rv;

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

@ -50,6 +50,11 @@ EXPORT_LIBRARY = 1
MODULE_NAME = nsPlacesModule MODULE_NAME = nsPlacesModule
IS_COMPONENT = 1 IS_COMPONENT = 1
EXPORTS_NAMESPACES = mozilla/places
EXPORTS_mozilla/places = \
History.h \
$(NULL)
CPPSRCS = \ CPPSRCS = \
nsAnnoProtocolHandler.cpp \ nsAnnoProtocolHandler.cpp \