From 97a3c4a767de7bb61e1c3737cb3c51e87b7fde65 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Sat, 5 Feb 2011 13:22:10 +0100 Subject: [PATCH] Bug 629285 - Crash at AsyncGetBookmarksForURI. r=sdwilsh a=blocker --- .../components/places/src/nsNavBookmarks.cpp | 17 ++++++++++++----- toolkit/components/places/src/nsNavBookmarks.h | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/toolkit/components/places/src/nsNavBookmarks.cpp b/toolkit/components/places/src/nsNavBookmarks.cpp index 145e625f05a1..54a0ed70025f 100644 --- a/toolkit/components/places/src/nsNavBookmarks.cpp +++ b/toolkit/components/places/src/nsNavBookmarks.cpp @@ -124,15 +124,19 @@ class AsyncGetBookmarksForURI : public AsyncStatementCallback public: AsyncGetBookmarksForURI(nsNavBookmarks* aBookmarksSvc, Method aCallback, - DataType aData) + const DataType& aData) : mBookmarksSvc(aBookmarksSvc) , mCallback(aCallback) , mData(aData) + { + } + + void Init() { nsCOMPtr stmt = - aBookmarksSvc->GetStatementById(DB_GET_BOOKMARKS_FOR_URI); + mBookmarksSvc->GetStatementById(DB_GET_BOOKMARKS_FOR_URI); if (stmt) { - (void)URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), aData.uri); + (void)URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), mData.uri); nsCOMPtr pendingStmt; (void)stmt->ExecuteAsync(this, getter_AddRefs(pendingStmt)); } @@ -2916,14 +2920,14 @@ nsNavBookmarks::RemoveObserver(nsINavBookmarkObserver* aObserver) } void -nsNavBookmarks::NotifyItemVisited(ItemVisitData aData) +nsNavBookmarks::NotifyItemVisited(const ItemVisitData& aData) { NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver, OnItemVisited(aData.itemId, aData.visitId, aData.time)); } void -nsNavBookmarks::NotifyItemChanged(ItemChangeData aData) +nsNavBookmarks::NotifyItemChanged(const ItemChangeData& aData) { NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver, OnItemChanged(aData.itemId, aData.property, @@ -2970,6 +2974,7 @@ nsNavBookmarks::OnVisit(nsIURI* aURI, PRInt64 aVisitId, PRTime aTime, nsRefPtr< AsyncGetBookmarksForURI > notifier = new AsyncGetBookmarksForURI(this, &nsNavBookmarks::NotifyItemVisited, visitData); + notifier->Init(); return NS_OK; } @@ -2994,6 +2999,7 @@ nsNavBookmarks::OnDeleteURI(nsIURI* aURI) nsRefPtr< AsyncGetBookmarksForURI > notifier = new AsyncGetBookmarksForURI(this, &nsNavBookmarks::NotifyItemChanged, changeData); + notifier->Init(); return NS_OK; } @@ -3054,6 +3060,7 @@ nsNavBookmarks::OnPageChanged(nsIURI* aURI, PRUint32 aWhat, else { nsRefPtr< AsyncGetBookmarksForURI > notifier = new AsyncGetBookmarksForURI(this, &nsNavBookmarks::NotifyItemChanged, changeData); + notifier->Init(); } } return NS_OK; diff --git a/toolkit/components/places/src/nsNavBookmarks.h b/toolkit/components/places/src/nsNavBookmarks.h index 3616a7f480a3..9bfb200827de 100644 --- a/toolkit/components/places/src/nsNavBookmarks.h +++ b/toolkit/components/places/src/nsNavBookmarks.h @@ -74,8 +74,8 @@ namespace places { PRUint16 itemType; }; - typedef void (nsNavBookmarks::*ItemVisitMethod)(ItemVisitData); - typedef void (nsNavBookmarks::*ItemChangeMethod)(ItemChangeData); + typedef void (nsNavBookmarks::*ItemVisitMethod)(const ItemVisitData&); + typedef void (nsNavBookmarks::*ItemChangeMethod)(const ItemChangeData&); } // namespace places } // namespace mozilla @@ -211,7 +211,7 @@ public: * @param aData * Details about the new visit. */ - void NotifyItemVisited(mozilla::places::ItemVisitData aData); + void NotifyItemVisited(const mozilla::places::ItemVisitData& aData); /** * Notifies that a bookmark has changed. @@ -221,7 +221,7 @@ public: * @param aData * Details about the change. */ - void NotifyItemChanged(mozilla::places::ItemChangeData aData); + void NotifyItemChanged(const mozilla::places::ItemChangeData& aData); private: static nsNavBookmarks* gBookmarksService;