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 "nsIAnnotationService.h"
#include "nsNavHistory.h" #include "nsNavHistory.h"
#include "nsBrowserCompsCID.h" #include "nsBrowserCompsCID.h"
#include "nsILoadGroup.h"
// Constants for livemark annotations // Constants for livemark annotations
#define LMANNO_FEEDURI "livemark/feedURI" #define LMANNO_FEEDURI "livemark/feedURI"
@ -71,13 +72,21 @@ public:
nsCOMPtr<nsIURI> folderURI; nsCOMPtr<nsIURI> folderURI;
nsCOMPtr<nsIURI> feedURI; nsCOMPtr<nsIURI> feedURI;
PRBool locked; 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) { LivemarkInfo(PRInt64 aFolderId, nsIURI *aFolderURI, nsIURI *aFeedURI)
folderId = aFolderId; : folderId(aFolderId), folderURI(aFolderURI), feedURI(aFeedURI),
folderURI = aFolderURI; locked(PR_FALSE) { }
feedURI = aFeedURI;
locked = false; void AddRef() { ++mRefCnt; }
} void Release() { if (--mRefCnt == 0) delete this; }
private:
nsAutoRefCnt mRefCnt;
}; };
private: private:
@ -98,7 +107,7 @@ private:
nsCOMPtr<nsINavBookmarksService> mBookmarksService; nsCOMPtr<nsINavBookmarksService> mBookmarksService;
// The list of livemarks is stored in this array // The list of livemarks is stored in this array
nsTArray<LivemarkInfo> mLivemarks; nsTArray< nsRefPtr<LivemarkInfo> > mLivemarks;
// Livemarks are updated on a timer. // Livemarks are updated on a timer.
nsCOMPtr<nsITimer> mTimer; nsCOMPtr<nsITimer> mTimer;