dom/file/ArchiveRequest.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_file_domarchiverequest_h__
michael@0 8 #define mozilla_dom_file_domarchiverequest_h__
michael@0 9
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11 #include "ArchiveReader.h"
michael@0 12 #include "DOMRequest.h"
michael@0 13
michael@0 14 #include "FileCommon.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 class EventChainPreVisitor;
michael@0 18 } // namespace mozilla
michael@0 19
michael@0 20 BEGIN_FILE_NAMESPACE
michael@0 21
michael@0 22 /**
michael@0 23 * This is the ArchiveRequest that handles any operation
michael@0 24 * related to ArchiveReader
michael@0 25 */
michael@0 26 class ArchiveRequest : public mozilla::dom::DOMRequest
michael@0 27 {
michael@0 28 public:
michael@0 29 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 30
michael@0 31 ArchiveReader* Reader() const;
michael@0 32
michael@0 33 NS_DECL_ISUPPORTS_INHERITED
michael@0 34
michael@0 35 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
michael@0 36
michael@0 37 ArchiveRequest(nsPIDOMWindow* aWindow,
michael@0 38 ArchiveReader* aReader);
michael@0 39
michael@0 40 // nsIDOMEventTarget
michael@0 41 virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
michael@0 42
michael@0 43 public:
michael@0 44 // This is called by the DOMArchiveRequestEvent
michael@0 45 void Run();
michael@0 46
michael@0 47 // Set the types for this request
michael@0 48 void OpGetFilenames();
michael@0 49 void OpGetFile(const nsAString& aFilename);
michael@0 50 void OpGetFiles();
michael@0 51
michael@0 52 nsresult ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
michael@0 53 nsresult aStatus);
michael@0 54
michael@0 55 public: // static
michael@0 56 static already_AddRefed<ArchiveRequest> Create(nsPIDOMWindow* aOwner,
michael@0 57 ArchiveReader* aReader);
michael@0 58
michael@0 59 private:
michael@0 60 ~ArchiveRequest();
michael@0 61
michael@0 62 nsresult GetFilenamesResult(JSContext* aCx,
michael@0 63 JS::Value* aValue,
michael@0 64 nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
michael@0 65 nsresult GetFileResult(JSContext* aCx,
michael@0 66 JS::MutableHandle<JS::Value> aValue,
michael@0 67 nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
michael@0 68 nsresult GetFilesResult(JSContext* aCx,
michael@0 69 JS::MutableHandle<JS::Value> aValue,
michael@0 70 nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
michael@0 71
michael@0 72 protected:
michael@0 73 // The reader:
michael@0 74 nsRefPtr<ArchiveReader> mArchiveReader;
michael@0 75
michael@0 76 // The operation:
michael@0 77 enum {
michael@0 78 GetFilenames,
michael@0 79 GetFile,
michael@0 80 GetFiles
michael@0 81 } mOperation;
michael@0 82
michael@0 83 // The filename (needed by GetFile):
michael@0 84 nsString mFilename;
michael@0 85 };
michael@0 86
michael@0 87 END_FILE_NAMESPACE
michael@0 88
michael@0 89 #endif // mozilla_dom_file_domarchiverequest_h__

mercurial