Пример #1
0
 public void NotifyDownloadProgress(string aUrl, int aBytes, int aTotalBytes)
 {
     if (!iDownloads.ContainsKey(aUrl))
     {
         return;
     }
     lock (iPublicDownloadsLock)
     {
         iPublicDownloadInfo[aUrl] = new DownloadProgress(aUrl, aBytes, aTotalBytes, false);
     }
 }
Пример #2
0
 XElement DownloadProgressToXElement(DownloadProgress aDownload)
 {
     XElement appHandleElement = null;
     XElement appIdElement = null;
     string appName;
     if (iUpgradeAppNamesToUrls.Backward.TryGetValue(aDownload.Uri, out appName))
     {
         uint appHandle = iApps.GetIdForKey(appName);
         appHandleElement = new XElement("appHandle", appHandle);
         appIdElement = new XElement("appId", appName);
     }
     XElement element = new XElement("download",
         new XElement("status", aDownload.HasFailed ? "failed" : "downloading"),
         appHandleElement,
         appIdElement,
         new XElement("url", aDownload.Uri),
         new XElement("progressBytes", aDownload.DownloadedBytes));
     if (aDownload.HasTotalBytes)
     {
         element.Add(
             new XElement("totalBytes", aDownload.TotalBytes),
             new XElement("progressPercent", (int)Math.Round(100.0 * aDownload.DownloadedBytes / aDownload.TotalBytes)));
     }
     return element;
 }