progdown.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:21k
源码类别:

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: progdown.cpp,v 1.1.4.4 2004/07/09 02:04:08 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #include "hxtypes.h"
  50. #include "hxcom.h"
  51. #include "ihxpckts.h"
  52. #include "hlxclib/sys/stat.h"
  53. #include "hxdataf.h"
  54. #include "hxprefs.h"
  55. #include "hxmon.h"
  56. #include "hxcomm.h"
  57. #include "hxcbobj.h"
  58. #include "hxprefutil.h"
  59. #include "pckunpck.h"
  60. #include "baseobj.h"
  61. #include "hxtick.h"
  62. #include "smplmlog.h"
  63. #include "progdown.h"
  64. CProgressiveDownloadMonitor::CProgressiveDownloadMonitor()
  65. {
  66.     MLOG_PD(NULL, "CON CProgressiveDownloadMonitor 0x%08xn", this);
  67.     m_pContext               = NULL;
  68.     m_pDataFile              = NULL;
  69.     m_pResponse              = NULL;
  70.     m_pScheduler             = NULL;
  71.     m_pRegistry              = NULL;
  72.     m_pStatCallback          = NULL;
  73.     m_pProgCallback          = NULL;
  74.     m_ulStatCallbackInterval = PROGDOWN_STAT_INTERVAL_DEFAULT;
  75.     m_ulCurStatInterval      = PROGDOWN_STAT_INTERVAL_INITIAL;
  76.     m_ulProgCallbackInterval = PROGDOWN_FAIL_INTERVAL_DEFAULT;
  77.     m_ulFinishedTime         = PROGDOWN_FINISHED_TIME_DEFAULT;
  78.     m_ulLastFileSize         = 0;
  79.     m_ulTickAtLastFileSize   = 0;
  80.     m_ulURLRegistryID        = 0;
  81.     m_ulIsProgRegistryID     = 0;
  82.     m_ulFormerProgRetryCount = 0;
  83.     m_ulFormerProgRetryInit  = PROGDOWN_FORMER_PROG_RETRY_INIT;
  84.     m_ulNotProgRetryCount    = 0;
  85.     m_ulNotProgRetryInit     = PROGDOWN_NOT_PROG_RETRY_INIT;
  86.     m_bIsProgressive         = FALSE;
  87.     m_bMonitorEnabled        = TRUE;
  88.     m_bHasBeenProgressive    = FALSE;
  89. }
  90. CProgressiveDownloadMonitor::~CProgressiveDownloadMonitor()
  91. {
  92.     MLOG_PD(NULL, "DES CProgressiveDownloadMonitor 0x%08xn", this);
  93.     Close();
  94. }
  95. HX_RESULT CProgressiveDownloadMonitor::Init(IUnknown* pContext, IHXDataFile* pFile,
  96.                                             CProgressiveDownloadMonitorResponse* pResponse)
  97. {
  98.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::Init() this=0x%08xn", this);
  99.     HX_RESULT retVal = HXR_FAIL;
  100.     if (pContext && pFile && pResponse)
  101.     {
  102.         // Clear out any current state
  103.         Close();
  104.         // Save the context
  105.         m_pContext = pContext;
  106.         m_pContext->AddRef();
  107.         // Save the file
  108.         m_pDataFile = pFile;
  109.         // XXXMEH - We will not AddRef the IHXDataFile for now, because
  110.         // some users of the IHXFileObject do not call IHXFileObject::Close()
  111.         // before releasing the file object. If that is the case, then 
  112.         // the IHXDataFile never destructs. If we ever exhaustively go through
  113.         // and verify that all users of smplfsys correctly call ::Close(),
  114.         // then we can remove the commented-out AddRef().
  115. //        m_pDataFile->AddRef();
  116.         // Save the response pointer
  117.         m_pResponse = pResponse;
  118.         m_pResponse->AddRef();
  119.         // Get the schedule interface
  120.         retVal = m_pContext->QueryInterface(IID_IHXScheduler, (void**) &m_pScheduler);
  121.         if (SUCCEEDED(retVal))
  122.         {
  123.             // Get the IHXRegistry interface
  124.             m_pContext->QueryInterface(IID_IHXRegistry, (void**) &m_pRegistry);
  125.             // Check preferences to see if alternate values
  126.             // for stat callback interval, fail callback interval
  127.             // and finished duration are specified
  128.             CheckPreferenceValues(m_bMonitorEnabled,
  129.                                   m_ulStatCallbackInterval,
  130.                                   m_ulProgCallbackInterval,
  131.                                   m_ulFinishedTime,
  132.                                   m_ulFormerProgRetryInit,
  133.                                   m_ulNotProgRetryInit);
  134.             // Initialize the progressive state variables
  135.             m_ulLastFileSize       = GetFileSizeNow();
  136.             m_ulTickAtLastFileSize = HX_GET_BETTERTICKCOUNT();
  137.             // Initialize the number of times to retry
  138.             // if the file has not been progressive
  139.             m_ulNotProgRetryCount = m_ulNotProgRetryInit;
  140.             // Init the registry stats
  141.             InitRegistryStats();
  142.         }
  143.     }
  144.     return retVal;
  145. }
  146. HX_RESULT CProgressiveDownloadMonitor::Close()
  147. {
  148.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::Close() this=0x%08xn", this);
  149.     HX_RESULT retVal = HXR_OK;
  150.     // Clear any stat callback
  151.     if (m_pStatCallback) m_pStatCallback->Cancel(m_pScheduler);
  152.     HX_RELEASE(m_pStatCallback);
  153.     // Clear any fail callback
  154.     CancelCallback();
  155.     HX_RELEASE(m_pProgCallback);
  156.     // Release member variables
  157.     HX_RELEASE(m_pContext);
  158.         // XXXMEH - We will not AddRef the IHXDataFile for now, because
  159.         // some users of the IHXFileObject do not call IHXFileObject::Close()
  160.         // before releasing the file object. If that is the case, then 
  161.         // the IHXDataFile never destructs. If we ever exhaustively go through
  162.         // and verify that all users of smplfsys correctly call ::Close(),
  163.         // then we can remove the commented-out HX_RELEASE()
  164. //    HX_RELEASE(m_pDataFile);
  165.     m_pDataFile = NULL;
  166.     HX_RELEASE(m_pResponse);
  167.     HX_RELEASE(m_pScheduler);
  168.     HX_RELEASE(m_pRegistry);
  169.     // Reset state variables to defaults
  170.     m_ulStatCallbackInterval = PROGDOWN_STAT_INTERVAL_DEFAULT;
  171.     m_ulCurStatInterval      = PROGDOWN_STAT_INTERVAL_INITIAL;
  172.     m_ulProgCallbackInterval = PROGDOWN_FAIL_INTERVAL_DEFAULT;
  173.     m_ulFinishedTime         = PROGDOWN_FINISHED_TIME_DEFAULT;
  174.     m_ulLastFileSize         = 0;
  175.     m_ulTickAtLastFileSize   = 0;
  176.     m_ulURLRegistryID        = 0;
  177.     m_ulIsProgRegistryID     = 0;
  178.     m_ulFormerProgRetryCount = 0;
  179.     m_ulFormerProgRetryInit  = PROGDOWN_FORMER_PROG_RETRY_INIT;
  180.     m_ulNotProgRetryCount    = 0;
  181.     m_ulNotProgRetryInit     = PROGDOWN_NOT_PROG_RETRY_INIT;
  182.     m_bIsProgressive         = FALSE;
  183.     m_bMonitorEnabled        = TRUE;
  184.     m_bHasBeenProgressive    = FALSE;
  185.     return retVal;
  186. }
  187. HX_RESULT CProgressiveDownloadMonitor::ScheduleCallback()
  188. {
  189.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::ScheduleCallback() this=0x%08x tick=%lun",
  190.             this, HX_GET_BETTERTICKCOUNT());
  191.     HX_RESULT retVal = HXR_FAIL;
  192.     if (m_pScheduler)
  193.     {
  194.         if (!m_pProgCallback)
  195.         {
  196.             m_pProgCallback = new CHXGenericCallback(this, CProgressiveDownloadMonitor::ProgCallback);
  197.             if (m_pProgCallback)
  198.             {
  199.                 m_pProgCallback->AddRef();
  200.             }
  201.         }
  202.         if (m_pProgCallback)
  203.         {
  204.             // Clear the return value
  205.             retVal = HXR_OK;
  206.             // Do we already have a callback pending?
  207.             if (!m_pProgCallback->IsCallbackPending())
  208.             {
  209.                 // No callback pending, schedule one
  210.                 m_pProgCallback->ScheduleRelative(m_pScheduler, m_ulProgCallbackInterval);
  211.             }
  212.         }
  213.     }
  214.     return retVal;
  215. }
  216. BOOL CProgressiveDownloadMonitor::IsCallbackPending()
  217. {
  218.     BOOL bRet = FALSE;
  219.     if (m_pProgCallback)
  220.     {
  221.         bRet = m_pProgCallback->IsCallbackPending();
  222.     }
  223.     return bRet;
  224. }
  225. void CProgressiveDownloadMonitor::CancelCallback()
  226. {
  227.     if (m_pProgCallback && m_pProgCallback->IsCallbackPending())
  228.     {
  229.         m_pProgCallback->Cancel(m_pScheduler);
  230.     }
  231. }
  232. HX_RESULT CProgressiveDownloadMonitor::BeginSizeMonitoring()
  233. {
  234.     HX_RESULT retVal = HXR_FAIL;
  235.     // Create the stat callback if it doesn't
  236.     // already exist
  237.     if (!m_pStatCallback)
  238.     {
  239.         m_pStatCallback = new CHXGenericCallback(this, CProgressiveDownloadMonitor::StatCallback);
  240.         if (m_pStatCallback)
  241.         {
  242.             m_pStatCallback->AddRef();
  243.         }
  244.     }
  245.     if (m_pStatCallback)
  246.     {
  247.         // Clear the return value
  248.         retVal = HXR_OK;
  249.         // Do we already have a callback scheduled? If so,
  250.         // then we have already begun size monitoring.
  251.         if (!m_pStatCallback->IsCallbackPending())
  252.         {
  253.             // Initialize the progressive state variables
  254.             m_ulLastFileSize       = GetFileSizeNow();
  255.             m_ulTickAtLastFileSize = HX_GET_BETTERTICKCOUNT();
  256.             m_ulCurStatInterval    = PROGDOWN_STAT_INTERVAL_INITIAL;
  257.             // Kick off the callbacks, if monitoring is enabled
  258.             ScheduleStatCallback();
  259.         }
  260.     }
  261.     return retVal;
  262. }
  263. void CProgressiveDownloadMonitor::EndSizeMonitoring()
  264. {
  265.     // If there was a size monitoring callback
  266.     // scheduled, then cancel it
  267.     if (m_pStatCallback)
  268.     {
  269.         m_pStatCallback->Cancel(m_pScheduler);
  270.     }
  271. }
  272. UINT32 CProgressiveDownloadMonitor::GetFileSizeNow()
  273. {
  274.     UINT32 ulRet = 0;
  275.     if (m_pDataFile)
  276.     {
  277.         // Stat the file
  278.         struct stat sStat;
  279.         if (SUCCEEDED(m_pDataFile->Stat(&sStat)))
  280.         {
  281.             // Set the return value
  282.             ulRet = (UINT32) sStat.st_size;
  283.         }
  284.     }
  285.     return ulRet;
  286. }
  287. void CProgressiveDownloadMonitor::MonitorFileSize()
  288. {
  289.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::MonitorFileSize() this=0x%08x tick=%lun",
  290.             this, HX_GET_BETTERTICKCOUNT());
  291.     // Save the current m_bIsProgressive value
  292.     BOOL bTmp = m_bIsProgressive;
  293.     // Get the file size and tick count
  294.     UINT32 ulFileSize = GetFileSizeNow();
  295.     UINT32 ulTick     = HX_GET_BETTERTICKCOUNT();
  296.     // Is the file size the same as m_ulLastFileSize?
  297.     if (ulFileSize != m_ulLastFileSize)
  298.     {
  299.         MLOG_PD(NULL, "tNewFileSize=%lun", ulFileSize);
  300.         // The filesize has changed, so we know
  301.         // this file is progressive
  302.         m_bIsProgressive = TRUE;
  303.         // Reset the former progressive retry count to
  304.         // its initial value
  305.         m_ulFormerProgRetryCount = m_ulFormerProgRetryInit;
  306.         // Reset the not progressive retry count to
  307.         // its initial value
  308.         m_ulNotProgRetryCount = m_ulNotProgRetryInit;
  309.         // If the file size is different even once,
  310.         // then this file has a history of being progressive.
  311.         // We keep this variable around in addition to
  312.         // m_bIsProgressive since m_bIsProgressive can change
  313.         // when the file finishes downloading or when the
  314.         // download agent pauses. Since we want to treat files
  315.         // which have a history of being progressive differently
  316.         // than files which don't, we need to keep m_bHasBeenProgressive.
  317.         m_bHasBeenProgressive = TRUE;
  318.         // Update the last file size
  319.         m_ulLastFileSize = ulFileSize;
  320.         // Update the tick count
  321.         m_ulTickAtLastFileSize = ulTick;
  322.     }
  323.     else
  324.     {
  325.         // The filesize is the same. How
  326.         // long has it been the same?
  327.         UINT32 ulDiff = CALCULATE_ELAPSED_TICKS(m_ulTickAtLastFileSize, ulTick);
  328.         // If the file size has been the
  329.         // same for at last m_ulFinishedTime
  330.         // milliseconds, then we assume it has
  331.         // finished downloading
  332.         if (ulDiff > m_ulFinishedTime && m_bIsProgressive)
  333.         {
  334.             MLOG_PD(NULL, "tFile has been %lu bytes for %lu ms. DECLARING FINISHED.n",
  335.                     ulFileSize, ulDiff);
  336.             m_bIsProgressive = FALSE;
  337.         }
  338.     }
  339.     // Did the value of m_bIsProgressive change?
  340.     if (bTmp != m_bIsProgressive)
  341.     {
  342.         // Update the registry statistics
  343.         UpdateRegistryStats();
  344.     }
  345. }
  346. void CProgressiveDownloadMonitor::StatCallback(void* pArg)
  347. {
  348.     if (pArg)
  349.     {
  350.         CProgressiveDownloadMonitor* pObj = (CProgressiveDownloadMonitor*) pArg;
  351.         pObj->MonitorFileSize();
  352.         pObj->ScheduleStatCallback();
  353.     }
  354. }
  355. void CProgressiveDownloadMonitor::ProgCallback(void* pArg)
  356. {
  357.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::ProgCallback(0x%08x) tick=%lun",
  358.             pArg, HX_GET_BETTERTICKCOUNT());
  359.     if (pArg)
  360.     {
  361.         CProgressiveDownloadMonitor* pObj = (CProgressiveDownloadMonitor*) pArg;
  362.         if (pObj->m_pResponse)
  363.         {
  364.             pObj->m_pResponse->ProgressiveCallback();
  365.         }
  366.     }
  367. }
  368. void CProgressiveDownloadMonitor::CheckPreferenceValues(REF(BOOL)   rbMonitorEnabled,
  369.                                                         REF(UINT32) rulStatCallbackInterval,
  370.                                                         REF(UINT32) rulProgCallbackInterval,
  371.                                                         REF(UINT32) rulFinishedTime,
  372.                                                         REF(UINT32) rulFormerProgRetryCount,
  373.                                                         REF(UINT32) rulNotProgRetryCount)
  374. {
  375.     if (m_pContext)
  376.     {
  377.         IHXPreferences* pPrefs = NULL;
  378.         m_pContext->QueryInterface(IID_IHXPreferences, (void**) &pPrefs);
  379.         if (pPrefs)
  380.         {
  381.             ReadPrefBOOL(pPrefs,  "ProgressiveDownload\FileSizeMonitorEnabled",      rbMonitorEnabled);
  382.             ReadPrefINT32(pPrefs, "ProgressiveDownload\FileSizeCheckInterval",       rulStatCallbackInterval);
  383.             ReadPrefINT32(pPrefs, "ProgressiveDownload\FailureRetryInterval",        rulProgCallbackInterval);
  384.             ReadPrefINT32(pPrefs, "ProgressiveDownload\DeclareFinishedDuration",     rulFinishedTime);
  385.             ReadPrefINT32(pPrefs, "ProgressiveDownload\FormerProgressiveRetryCount", rulFormerProgRetryCount);
  386.             ReadPrefINT32(pPrefs, "ProgressiveDownload\NotProgressiveRetryCount",    rulNotProgRetryCount);
  387.             MLOG_PD(NULL,
  388.                     "tFileSizeMonitorEnabled      = %lun"
  389.                     "tFileSizeCheckInterval       = %lun"
  390.                     "tFailureRetryInterval        = %lun"
  391.                     "tDeclareFinishedDuration     = %lun"
  392.                     "tFormerProgressiveRetryCount = %lun"
  393.                     "tNotProgressiveRetryCount    = %lun",
  394.                     rbMonitorEnabled, rulStatCallbackInterval,
  395.                     rulProgCallbackInterval, rulFinishedTime,
  396.                     rulFormerProgRetryCount, rulNotProgRetryCount);
  397.         }
  398.         HX_RELEASE(pPrefs);
  399.     }
  400. }
  401. HX_RESULT CProgressiveDownloadMonitor::InitRegistryStats()
  402. {
  403.     HX_RESULT retVal = HXR_FAIL;
  404.     if (m_pContext && m_pRegistry && m_pDataFile)
  405.     {
  406.         // Get the source registry ID
  407.         IHXRegistryID* pRegistryID = NULL;
  408.         retVal = m_pContext->QueryInterface(IID_IHXRegistryID, (void**) &pRegistryID);
  409.         if (SUCCEEDED(retVal))
  410.         {
  411.             UINT32 ulSourceRegistryID = 0;
  412.             retVal = pRegistryID->GetID(ulSourceRegistryID);
  413.             if (SUCCEEDED(retVal))
  414.             {
  415.                 // Get the source property name - this will
  416.                 // be something like "Statistics.Player0.Source0"
  417.                 IHXBuffer* pSourceName = NULL;
  418.                 retVal = m_pRegistry->GetPropName(ulSourceRegistryID, pSourceName);
  419.                 if (SUCCEEDED(retVal))
  420.                 {
  421.                     // Construct the URL property name
  422.                     CHXString cPropName((const char*) pSourceName->GetBuffer());
  423.                     cPropName += ".URL";
  424.                     // Construct the URL property value
  425.                     CHXString cPropVal("file://");
  426.                     IHXBuffer* pNameBuf = NULL;
  427.                     if (m_pDataFile->Name(pNameBuf))
  428.                     {
  429.                         cPropVal += (const char*) pNameBuf->GetBuffer();
  430.                     }
  431.                     HX_RELEASE(pNameBuf);
  432.                     // Put the URL property value into an IHXBuffer
  433.                     IHXBuffer* pPropVal = NULL;
  434.                     CreateStringBuffer(pPropVal, (const char*) cPropVal, m_pContext);
  435.                     if (pPropVal)
  436.                     {
  437.                         // Does this property already exist?
  438.                         IHXBuffer* pTmp = NULL;
  439.                         if (SUCCEEDED(m_pRegistry->GetStrByName((const char*) cPropName, pTmp)))
  440.                         {
  441.                             // It does already exist
  442.                             //
  443.                             // Set the new value
  444.                             m_pRegistry->SetStrByName((const char*) cPropName, pPropVal);
  445.                             // Get the registry ID
  446.                             m_ulURLRegistryID = m_pRegistry->GetId((const char*) cPropName);
  447.                         }
  448.                         else
  449.                         {
  450.                             // It does not already exist, so create it
  451.                             // and get the registry id at the same time
  452.                             m_ulURLRegistryID = m_pRegistry->AddStr((const char*) cPropName, pPropVal);
  453.                         }
  454.                         HX_RELEASE(pTmp);
  455.                     }
  456.                     HX_RELEASE(pPropVal);
  457.                     // Construct the IsProgressive property name
  458.                     cPropName  = (const char*) pSourceName->GetBuffer();
  459.                     cPropName += ".IsProgressive";
  460.                     // Does this property already exist?
  461.                     INT32 lTmp = 0;
  462.                     if (SUCCEEDED(m_pRegistry->GetIntByName((const char*) cPropName, lTmp)))
  463.                     {
  464.                         // It DOES already exist
  465.                         //
  466.                         // Set the new value
  467.                         m_pRegistry->SetIntByName((const char*) cPropName, (m_bIsProgressive ? 1 : 0));
  468.                         // Get the registry id
  469.                         m_ulIsProgRegistryID = m_pRegistry->GetId((const char*) cPropName);
  470.                     }
  471.                     else
  472.                     {
  473.                         // It does NOT already exist
  474.                         //
  475.                         // Create the IsProgressive property and get
  476.                         // the registry id at the same time
  477.                         m_ulIsProgRegistryID = m_pRegistry->AddInt((const char*) cPropName,
  478.                                                                    (m_bIsProgressive ? 1 : 0));
  479.                     }
  480.                 }
  481.                 HX_RELEASE(pSourceName);
  482.             }
  483.         }
  484.         HX_RELEASE(pRegistryID);
  485.     }
  486.     return retVal;
  487. }
  488. void CProgressiveDownloadMonitor::UpdateRegistryStats()
  489. {
  490.     MLOG_PD(NULL, "CProgressiveDownloadMonitor::UpdateRegistryStats() this=0x%08xn", this);
  491.     // Right now the only thing we are updating
  492.     // is the IsProgressive property. We assume
  493.     // that the URL property will never need to
  494.     // change during playback.
  495.     if (m_pRegistry && m_ulIsProgRegistryID)
  496.     {
  497.         m_pRegistry->SetIntById(m_ulIsProgRegistryID, (m_bIsProgressive ? 1 : 0));
  498.     }
  499. }
  500. void CProgressiveDownloadMonitor::ScheduleStatCallback()
  501. {
  502.     if (m_pStatCallback && m_bMonitorEnabled)
  503.     {
  504.         MLOG_PD(NULL, "CProgressiveDownloadMonitor::ScheduleStatCallback() this=0x%08x m_ulCurStatInterval=%lun",
  505.                 this, m_ulCurStatInterval);
  506.         m_pStatCallback->ScheduleRelative(m_pScheduler, m_ulCurStatInterval);
  507.         // We start off with a small stat interval
  508.         // and double the interval every time until
  509.         // we reach m_ulStatCallbackInterval
  510.         if (m_ulCurStatInterval < m_ulStatCallbackInterval)
  511.         {
  512.             m_ulCurStatInterval *= 2;
  513.             if (m_ulCurStatInterval > m_ulStatCallbackInterval)
  514.             {
  515.                 m_ulCurStatInterval = m_ulStatCallbackInterval;
  516.             }
  517.         }
  518.     }
  519. }