nsrefcnt	refcnt; NS_RELEASE2(bmks, refcnt); if (0 != refcnt) { nsresult rv = NS_NewTimer(getter_AddRefs(bmks->mTimer)); if (NS_FAILED(rv)) return;   bmks->mTimer->Init(nsBookmarksService::FireTimer, bmks,  BOOKMARK_TIMEOUT);  NS_ADDREF(bmks); }
nsresult rv = NS_NewTimer(getter_AddRefs(bmks->mTimer)); if (NS_FAILED(rv)) return; bmks->mTimer->Init(nsBookmarksService::FireTimer, bmks,  BOOKMARK_TIMEOUT);
nsBookmarksService::FireTimer(nsITimer* aTimer, void* aClosure){	// XXX Any lifetime issues we need to deal with here???	nsBookmarksService *bmks = NS_STATIC_CAST(nsBookmarksService *, aClosure);	if (!bmks)	return;	bmks->mTimer = nsnull;	if ((bmks->mBookmarksAvailable == PR_TRUE) && (bmks->mDirty == PR_TRUE))	{		bmks->Flush();	}	if (bmks->busySchedule == PR_FALSE)	{		nsresult			rv;		nsCOMPtr<nsIRDFResource>	bookmark;		if (NS_SUCCEEDED(rv = bmks->GetBookmarkToPing(getter_AddRefs(bookmark))) && (bookmark))		{			bmks->busyResource = bookmark;			const char		*url = nsnull;			bookmark->GetValueConst(&url);#ifdef	DEBUG_BOOKMARK_PING_OUTPUT			printf("nsBookmarksService::FireTimer - Pinging '%s'\n", url);#endif			nsCOMPtr<nsIURI>	uri;			if (NS_SUCCEEDED(rv = NS_NewURI(getter_AddRefs(uri), url)))			{#if 0				rv = NS_OpenURI(NS_STATIC_CAST(nsIStreamListener *, bmks), nsnull, uri, nsnull);#else				nsCOMPtr<nsIChannel>	channel;				if (NS_SUCCEEDED(rv = NS_OpenURI(getter_AddRefs(channel), uri, nsnull)))				{					nsCOMPtr<nsIHTTPChannel>	httpChannel = do_QueryInterface(channel);					if (httpChannel)					{						bmks->busySchedule = PR_TRUE;						bmks->htmlSize = 0;//						httpChannel->SetRequestMethod(HM_GET);						httpChannel->SetRequestMethod(HM_HEAD);						rv = channel->AsyncRead(0, -1, nsnull, bmks);					}				}#endif			}		}	}#ifdef	DEBUG_BOOKMARK_PING_OUTPUTelse	{	printf("nsBookmarksService::FireTimer - busy pinging.\n");	}#endif	// reschedule the timer unless bookmarks service is going away	nsrefcnt	refcnt;	NS_RELEASE2(bmks, refcnt);	if (0 != refcnt)	{		nsresult rv = NS_NewTimer(getter_AddRefs(bmks->mTimer));		if (NS_FAILED(rv)) return;		// by default, fire the timer once a minute (unit is milliseconds)		bmks->mTimer->Init(nsBookmarksService::FireTimer, bmks, /* repeat, */ BOOKMARK_TIMEOUT);		// the timer will hold a reference to the bookmark service, so AddRef		NS_ADDREF(bmks);	}}