Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | // ProgressUtils.h |
michael@0 | 2 | |
michael@0 | 3 | #include "StdAfx.h" |
michael@0 | 4 | |
michael@0 | 5 | #include "ProgressUtils.h" |
michael@0 | 6 | |
michael@0 | 7 | void CLocalCompressProgressInfo::Init(ICompressProgressInfo *progress, |
michael@0 | 8 | const UInt64 *inStartValue, const UInt64 *outStartValue) |
michael@0 | 9 | { |
michael@0 | 10 | _progress = progress; |
michael@0 | 11 | _inStartValueIsAssigned = (inStartValue != NULL); |
michael@0 | 12 | if (_inStartValueIsAssigned) |
michael@0 | 13 | _inStartValue = *inStartValue; |
michael@0 | 14 | _outStartValueIsAssigned = (outStartValue != NULL); |
michael@0 | 15 | if (_outStartValueIsAssigned) |
michael@0 | 16 | _outStartValue = *outStartValue; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | STDMETHODIMP CLocalCompressProgressInfo::SetRatioInfo( |
michael@0 | 20 | const UInt64 *inSize, const UInt64 *outSize) |
michael@0 | 21 | { |
michael@0 | 22 | UInt64 inSizeNew, outSizeNew; |
michael@0 | 23 | const UInt64 *inSizeNewPointer; |
michael@0 | 24 | const UInt64 *outSizeNewPointer; |
michael@0 | 25 | if (_inStartValueIsAssigned && inSize != NULL) |
michael@0 | 26 | { |
michael@0 | 27 | inSizeNew = _inStartValue + (*inSize); |
michael@0 | 28 | inSizeNewPointer = &inSizeNew; |
michael@0 | 29 | } |
michael@0 | 30 | else |
michael@0 | 31 | inSizeNewPointer = NULL; |
michael@0 | 32 | |
michael@0 | 33 | if (_outStartValueIsAssigned && outSize != NULL) |
michael@0 | 34 | { |
michael@0 | 35 | outSizeNew = _outStartValue + (*outSize); |
michael@0 | 36 | outSizeNewPointer = &outSizeNew; |
michael@0 | 37 | } |
michael@0 | 38 | else |
michael@0 | 39 | outSizeNewPointer = NULL; |
michael@0 | 40 | return _progress->SetRatioInfo(inSizeNewPointer, outSizeNewPointer); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | |
michael@0 | 44 | /////////////////////////////////// |
michael@0 | 45 | // |
michael@0 | 46 | |
michael@0 | 47 | void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain) |
michael@0 | 48 | { |
michael@0 | 49 | _progress = progress; |
michael@0 | 50 | _inSizeIsMain = inSizeIsMain; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | STDMETHODIMP CLocalProgress::SetRatioInfo( |
michael@0 | 54 | const UInt64 *inSize, const UInt64 *outSize) |
michael@0 | 55 | { |
michael@0 | 56 | return _progress->SetCompleted(_inSizeIsMain ? inSize : outSize); |
michael@0 | 57 | } |
michael@0 | 58 |