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 | // LockedStream.h |
michael@0 | 2 | |
michael@0 | 3 | #ifndef __LOCKEDSTREAM_H |
michael@0 | 4 | #define __LOCKEDSTREAM_H |
michael@0 | 5 | |
michael@0 | 6 | #include "../../Windows/Synchronization.h" |
michael@0 | 7 | #include "../../Common/MyCom.h" |
michael@0 | 8 | #include "../IStream.h" |
michael@0 | 9 | |
michael@0 | 10 | class CLockedInStream |
michael@0 | 11 | { |
michael@0 | 12 | CMyComPtr<IInStream> _stream; |
michael@0 | 13 | NWindows::NSynchronization::CCriticalSection _criticalSection; |
michael@0 | 14 | public: |
michael@0 | 15 | void Init(IInStream *stream) |
michael@0 | 16 | { _stream = stream; } |
michael@0 | 17 | HRESULT Read(UInt64 startPos, void *data, UInt32 size, UInt32 *processedSize); |
michael@0 | 18 | }; |
michael@0 | 19 | |
michael@0 | 20 | class CLockedSequentialInStreamImp: |
michael@0 | 21 | public ISequentialInStream, |
michael@0 | 22 | public CMyUnknownImp |
michael@0 | 23 | { |
michael@0 | 24 | CLockedInStream *_lockedInStream; |
michael@0 | 25 | UInt64 _pos; |
michael@0 | 26 | public: |
michael@0 | 27 | void Init(CLockedInStream *lockedInStream, UInt64 startPos) |
michael@0 | 28 | { |
michael@0 | 29 | _lockedInStream = lockedInStream; |
michael@0 | 30 | _pos = startPos; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | MY_UNKNOWN_IMP |
michael@0 | 34 | |
michael@0 | 35 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | #endif |