toolkit/components/downloads/nsDownloadScanner.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* vim: se cin sw=2 ts=2 et : */
michael@0 7
michael@0 8 #ifndef nsDownloadScanner_h_
michael@0 9 #define nsDownloadScanner_h_
michael@0 10
michael@0 11 #ifdef WIN32_LEAN_AND_MEAN
michael@0 12 #undef WIN32_LEAN_AND_MEAN
michael@0 13 #endif
michael@0 14 #include <windows.h>
michael@0 15 #define AVVENDOR
michael@0 16 #include <objidl.h>
michael@0 17 #include <msoav.h>
michael@0 18 #include <shlobj.h>
michael@0 19
michael@0 20 #include "nsAutoPtr.h"
michael@0 21 #include "nsThreadUtils.h"
michael@0 22 #include "nsTArray.h"
michael@0 23 #include "nsIObserver.h"
michael@0 24 #include "nsIURI.h"
michael@0 25
michael@0 26 enum AVScanState
michael@0 27 {
michael@0 28 AVSCAN_NOTSTARTED = 0,
michael@0 29 AVSCAN_SCANNING,
michael@0 30 AVSCAN_GOOD,
michael@0 31 AVSCAN_BAD,
michael@0 32 AVSCAN_UGLY,
michael@0 33 AVSCAN_FAILED,
michael@0 34 AVSCAN_TIMEDOUT
michael@0 35 };
michael@0 36
michael@0 37 enum AVCheckPolicyState
michael@0 38 {
michael@0 39 AVPOLICY_DOWNLOAD,
michael@0 40 AVPOLICY_PROMPT,
michael@0 41 AVPOLICY_BLOCKED
michael@0 42 };
michael@0 43
michael@0 44 // See nsDownloadScanner.cpp for declaration and definition
michael@0 45 class nsDownloadScannerWatchdog;
michael@0 46 class nsDownload;
michael@0 47
michael@0 48 class nsDownloadScanner
michael@0 49 {
michael@0 50 public:
michael@0 51 nsDownloadScanner();
michael@0 52 ~nsDownloadScanner();
michael@0 53 nsresult Init();
michael@0 54 nsresult ScanDownload(nsDownload *download);
michael@0 55 AVCheckPolicyState CheckPolicy(nsIURI *aSource, nsIURI *aTarget);
michael@0 56
michael@0 57 private:
michael@0 58 bool mAESExists;
michael@0 59 nsTArray<CLSID> mScanCLSID;
michael@0 60 bool IsAESAvailable();
michael@0 61 bool EnumerateOAVProviders();
michael@0 62
michael@0 63 nsAutoPtr<nsDownloadScannerWatchdog> mWatchdog;
michael@0 64
michael@0 65 static unsigned int __stdcall ScannerThreadFunction(void *p);
michael@0 66 class Scan : public nsRunnable
michael@0 67 {
michael@0 68 public:
michael@0 69 Scan(nsDownloadScanner *scanner, nsDownload *download);
michael@0 70 ~Scan();
michael@0 71 nsresult Start();
michael@0 72
michael@0 73 // Returns the time that Start was called
michael@0 74 PRTime GetStartTime() const { return mStartTime; }
michael@0 75 // Returns a copy of the thread handle that can be waited on, but not
michael@0 76 // terminated
michael@0 77 // The caller is responsible for closing the handle
michael@0 78 // If the thread has terminated, then this will return the pseudo-handle
michael@0 79 // INVALID_HANDLE_VALUE
michael@0 80 HANDLE GetWaitableThreadHandle() const;
michael@0 81
michael@0 82 // Called on a secondary thread to notify the scan that it has timed out
michael@0 83 // this is used only by the watchdog thread
michael@0 84 bool NotifyTimeout();
michael@0 85
michael@0 86 private:
michael@0 87 nsDownloadScanner *mDLScanner;
michael@0 88 PRTime mStartTime;
michael@0 89 HANDLE mThread;
michael@0 90 nsRefPtr<nsDownload> mDownload;
michael@0 91 // Guards mStatus
michael@0 92 CRITICAL_SECTION mStateSync;
michael@0 93 AVScanState mStatus;
michael@0 94 nsString mPath;
michael@0 95 nsString mName;
michael@0 96 nsString mOrigin;
michael@0 97 // Also true if it is an ftp download
michael@0 98 bool mIsHttpDownload;
michael@0 99 bool mSkipSource;
michael@0 100
michael@0 101 /* @summary Sets the Scan's state to newState if the current state is
michael@0 102 expectedState
michael@0 103 * @param newState The new state of the scan
michael@0 104 * @param expectedState The state that the caller expects the scan to be in
michael@0 105 * @return If the old state matched expectedState
michael@0 106 */
michael@0 107 bool CheckAndSetState(AVScanState newState, AVScanState expectedState);
michael@0 108
michael@0 109 NS_IMETHOD Run();
michael@0 110
michael@0 111 void DoScan();
michael@0 112 bool DoScanAES();
michael@0 113 bool DoScanOAV();
michael@0 114
michael@0 115 friend unsigned int __stdcall nsDownloadScanner::ScannerThreadFunction(void *);
michael@0 116 };
michael@0 117 // Used to give access to Scan
michael@0 118 friend class nsDownloadScannerWatchdog;
michael@0 119 };
michael@0 120 #endif
michael@0 121

mercurial