Fix crashes when adding livemarks due to the stream listener referencing freed memory. This changes the LivemarkInfo objects to be refcounted and heap-allocated, and also adds a loadgroup for each channel so that we can reliably cancel the loads. Also, null check the site URI since this field is optional. Bug 323472, r=annie sr=darin

Original committer: bryner%brianryner.com
Original revision: 1.2
Original date: 2006/01/25 22:59:55
This commit is contained in:
benjamin%smedbergs.us 2006-07-18 18:03:30 +00:00
Родитель 90cead737a
Коммит 7a444f0c80
1 изменённых файлов: 16 добавлений и 7 удалений

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

@ -41,6 +41,7 @@
#include "nsIAnnotationService.h"
#include "nsNavHistory.h"
#include "nsBrowserCompsCID.h"
#include "nsILoadGroup.h"
// Constants for livemark annotations
#define LMANNO_FEEDURI "livemark/feedURI"
@ -71,13 +72,21 @@ public:
nsCOMPtr<nsIURI> folderURI;
nsCOMPtr<nsIURI> feedURI;
PRBool locked;
// Keep track of the load group that contains the channel we're using
// to load this livemark. This allows the load to be cancelled if
// necessary. The load group automatically adds redirect channels, so
// cancelling the load group cancels everything.
nsCOMPtr<nsILoadGroup> loadGroup;
LivemarkInfo(PRInt64 aFolderId, nsCOMPtr<nsIURI> aFolderURI, nsCOMPtr<nsIURI> aFeedURI) {
folderId = aFolderId;
folderURI = aFolderURI;
feedURI = aFeedURI;
locked = false;
}
LivemarkInfo(PRInt64 aFolderId, nsIURI *aFolderURI, nsIURI *aFeedURI)
: folderId(aFolderId), folderURI(aFolderURI), feedURI(aFeedURI),
locked(PR_FALSE) { }
void AddRef() { ++mRefCnt; }
void Release() { if (--mRefCnt == 0) delete this; }
private:
nsAutoRefCnt mRefCnt;
};
private:
@ -98,7 +107,7 @@ private:
nsCOMPtr<nsINavBookmarksService> mBookmarksService;
// The list of livemarks is stored in this array
nsTArray<LivemarkInfo> mLivemarks;
nsTArray< nsRefPtr<LivemarkInfo> > mLivemarks;
// Livemarks are updated on a timer.
nsCOMPtr<nsITimer> mTimer;