dom/file/ArchiveRequest.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial