var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);  var db = gDownloadManager.datasource;  rdfc.Init(db, rdf.GetResource("NC:DownloadsRoot"));  var id = aDownload.targetFile.path;  
function downloadCompleted(aDownload) {  // Wrap this in try...catch since this can be called while shutting down...   // it doesn't really matter if it fails then since well.. we're shutting down  // and there's no UI to update!  try {    var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);    var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);    var db = gDownloadManager.datasource;        rdfc.Init(db, rdf.GetResource("NC:DownloadsRoot"));    var id = aDownload.targetFile.path;        // getTypeFromFile fails if it can't find a type for this file. Handle this gracefully.    try {      // Refresh the icon, so that executable icons are shown.      var mimeService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIMIMEService);      var contentType = mimeService.getTypeFromFile(aDownload.targetFile);      var listItem = document.getElementById(id);      var oldImage = listItem.getAttribute("image");      // I tack on the content-type here as a hack to bypass the cache which seems      // to be interfering despite the fact the image has 'validate="always"' set      // on it.       listItem.setAttribute("image", oldImage + "&contentType=" + contentType);    } catch (e) {    }        var dlRes = rdf.GetUnicodeResource(id);      var insertIndex = gDownloadManager.activeDownloadCount + 1;    // Don't bother inserting the item into the same place!    if (insertIndex != rdfc.IndexOf(dlRes)) {      rdfc.RemoveElement(dlRes, true);      if (insertIndex == rdfc.GetCount() || insertIndex < 1)         rdfc.AppendElement(dlRes);      else        rdfc.InsertElementAt(dlRes, insertIndex, true);          }            // Remove the download from our book-keeping list and if the count    // falls to zero, update the title here, since we won't be getting    // any more progress notifications in which to do it.     for (var i = 0; i < gActiveDownloads.length; ++i) {      if (gActiveDownloads[i] == aDownload) {        gActiveDownloads.splice(i, 1);        break;      }    }    gDownloadViewController.onCommandUpdate();    if (gActiveDownloads.length == 0)      document.title = document.documentElement.getAttribute("statictitle");  }  catch (e) {  }}
5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5459/5089b2dda415f7e24f05d326fd9f480edfca8ee5/downloads.js/clean/toolkit/mozapps/downloads/content/downloads.js