tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ProgressUtils.cpp (1087B)


      1 // ProgressUtils.cpp
      2 
      3 #include "StdAfx.h"
      4 
      5 #include "ProgressUtils.h"
      6 
      7 CLocalProgress::CLocalProgress():
      8    ProgressOffset(0),
      9    InSize(0),
     10    OutSize(0),
     11    SendRatio(true),
     12    SendProgress(true)
     13  {}
     14 
     15 void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
     16 {
     17  _ratioProgress.Release();
     18  _progress = progress;
     19  _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
     20  _inSizeIsMain = inSizeIsMain;
     21 }
     22 
     23 STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
     24 {
     25  UInt64 inSize2 = InSize;
     26  UInt64 outSize2 = OutSize;
     27  
     28  if (inSize)
     29    inSize2 += (*inSize);
     30  if (outSize)
     31    outSize2 += (*outSize);
     32  
     33  if (SendRatio && _ratioProgress)
     34  {
     35    RINOK(_ratioProgress->SetRatioInfo(&inSize2, &outSize2));
     36  }
     37  
     38  if (SendProgress)
     39  {
     40    inSize2 += ProgressOffset;
     41    outSize2 += ProgressOffset;
     42    return _progress->SetCompleted(_inSizeIsMain ? &inSize2 : &outSize2);
     43  }
     44  
     45  return S_OK;
     46 }
     47 
     48 HRESULT CLocalProgress::SetCur()
     49 {
     50  return SetRatioInfo(NULL, NULL);
     51 }