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 | // ExtractCallback.h |
michael@0 | 2 | |
michael@0 | 3 | #ifndef __EXTRACTCALLBACK_H |
michael@0 | 4 | #define __EXTRACTCALLBACK_H |
michael@0 | 5 | |
michael@0 | 6 | #include "resource.h" |
michael@0 | 7 | |
michael@0 | 8 | #include "Common/String.h" |
michael@0 | 9 | #include "Windows/ResourceString.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "../../Archive/IArchive.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "../../Common/FileStreams.h" |
michael@0 | 14 | #include "../../ICoder.h" |
michael@0 | 15 | |
michael@0 | 16 | #ifndef _NO_PROGRESS |
michael@0 | 17 | #include "../../FileManager/Resource/ProgressDialog/ProgressDialog.h" |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | class CExtractCallbackImp: |
michael@0 | 21 | public IArchiveExtractCallback, |
michael@0 | 22 | public CMyUnknownImp |
michael@0 | 23 | { |
michael@0 | 24 | public: |
michael@0 | 25 | |
michael@0 | 26 | MY_UNKNOWN_IMP |
michael@0 | 27 | |
michael@0 | 28 | // IProgress |
michael@0 | 29 | STDMETHOD(SetTotal)(UInt64 size); |
michael@0 | 30 | STDMETHOD(SetCompleted)(const UInt64 *completeValue); |
michael@0 | 31 | |
michael@0 | 32 | // IExtractCallback |
michael@0 | 33 | STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, |
michael@0 | 34 | Int32 askExtractMode); |
michael@0 | 35 | STDMETHOD(PrepareOperation)(Int32 askExtractMode); |
michael@0 | 36 | STDMETHOD(SetOperationResult)(Int32 resultEOperationResult); |
michael@0 | 37 | |
michael@0 | 38 | private: |
michael@0 | 39 | CMyComPtr<IInArchive> _archiveHandler; |
michael@0 | 40 | UString _directoryPath; |
michael@0 | 41 | |
michael@0 | 42 | UString _filePath; |
michael@0 | 43 | |
michael@0 | 44 | UString _diskFilePath; |
michael@0 | 45 | |
michael@0 | 46 | bool _extractMode; |
michael@0 | 47 | struct CProcessedFileInfo |
michael@0 | 48 | { |
michael@0 | 49 | FILETIME UTCLastWriteTime; |
michael@0 | 50 | bool IsDirectory; |
michael@0 | 51 | UInt32 Attributes; |
michael@0 | 52 | } _processedFileInfo; |
michael@0 | 53 | |
michael@0 | 54 | COutFileStream *_outFileStreamSpec; |
michael@0 | 55 | CMyComPtr<ISequentialOutStream> _outFileStream; |
michael@0 | 56 | |
michael@0 | 57 | UString _itemDefaultName; |
michael@0 | 58 | FILETIME _utcLastWriteTimeDefault; |
michael@0 | 59 | UInt32 _attributesDefault; |
michael@0 | 60 | |
michael@0 | 61 | void CreateComplexDirectory(const UStringVector &dirPathParts); |
michael@0 | 62 | public: |
michael@0 | 63 | #ifndef _NO_PROGRESS |
michael@0 | 64 | CProgressDialog ProgressDialog; |
michael@0 | 65 | #endif |
michael@0 | 66 | |
michael@0 | 67 | bool _isCorrupt; |
michael@0 | 68 | UString _message; |
michael@0 | 69 | |
michael@0 | 70 | void Init(IInArchive *archiveHandler, |
michael@0 | 71 | const UString &directoryPath, |
michael@0 | 72 | const UString &itemDefaultName, |
michael@0 | 73 | const FILETIME &utcLastWriteTimeDefault, |
michael@0 | 74 | UInt32 attributesDefault); |
michael@0 | 75 | |
michael@0 | 76 | #ifndef _NO_PROGRESS |
michael@0 | 77 | HRESULT StartProgressDialog(const UString &title) |
michael@0 | 78 | { |
michael@0 | 79 | ProgressDialog.Create(title, 0); |
michael@0 | 80 | { |
michael@0 | 81 | #ifdef LANG |
michael@0 | 82 | ProgressDialog.SetText(LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890)); |
michael@0 | 83 | #else |
michael@0 | 84 | ProgressDialog.SetText(NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING)); |
michael@0 | 85 | #endif |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | ProgressDialog.Show(SW_SHOWNORMAL); |
michael@0 | 89 | return S_OK; |
michael@0 | 90 | } |
michael@0 | 91 | virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); } |
michael@0 | 92 | #endif |
michael@0 | 93 | |
michael@0 | 94 | }; |
michael@0 | 95 | |
michael@0 | 96 | #endif |