PRBool isVisited; NS_ENSURE_SUCCESS(mGlobalHistory->IsVisited(aLinkURI, &isVisited), NS_ERROR_FAILURE); if (isVisited) aState = eLinkState_Visited;
if ((nsnull == mHistoryService) && !mFailedToLoadHistoryService) { rv = nsServiceManager::GetService(kGlobalHistoryCID, NS_GET_IID(nsIGlobalHistory), (nsISupports**) &mHistoryService);  if (NS_FAILED(rv)) { mFailedToLoadHistoryService = PR_TRUE; } }  if (mHistoryService) {  nsAutoString urlStr(aURLSpec);  char buf[256]; char* url = buf;  if (urlStr.Length() >= PRInt32(sizeof buf)) { url = new char[urlStr.Length() + 1]; }  PRInt64 lastVisitDate;  if (url) { urlStr.ToCString(url, urlStr.Length() + 1);  rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);  if (url != buf) delete[] url; } else { rv = NS_ERROR_OUT_OF_MEMORY; }    if (NS_FAILED(rv)) return rv;    if (! LL_IS_ZERO(lastVisitDate)) aState = eLinkState_Visited;   }
nsWebShell::GetLinkState(nsIURI* aLinkURI, nsLinkState& aState){  if (!aLinkURI) {    // No uri means not a link    aState = eLinkState_NotLink;    return NS_OK;  }      aState = eLinkState_Unvisited;  // no history, leave state unchanged  if (!mGlobalHistory)    return NS_OK;  PRBool isVisited;  NS_ENSURE_SUCCESS(mGlobalHistory->IsVisited(aLinkURI, &isVisited),                    NS_ERROR_FAILURE);  if (isVisited)    aState = eLinkState_Visited;    return NS_OK;}