michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_file_domarchiverequest_h__ michael@0: #define mozilla_dom_file_domarchiverequest_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "ArchiveReader.h" michael@0: #include "DOMRequest.h" michael@0: michael@0: #include "FileCommon.h" michael@0: michael@0: namespace mozilla { michael@0: class EventChainPreVisitor; michael@0: } // namespace mozilla michael@0: michael@0: BEGIN_FILE_NAMESPACE michael@0: michael@0: /** michael@0: * This is the ArchiveRequest that handles any operation michael@0: * related to ArchiveReader michael@0: */ michael@0: class ArchiveRequest : public mozilla::dom::DOMRequest michael@0: { michael@0: public: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: ArchiveReader* Reader() const; michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest) michael@0: michael@0: ArchiveRequest(nsPIDOMWindow* aWindow, michael@0: ArchiveReader* aReader); michael@0: michael@0: // nsIDOMEventTarget michael@0: virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; michael@0: michael@0: public: michael@0: // This is called by the DOMArchiveRequestEvent michael@0: void Run(); michael@0: michael@0: // Set the types for this request michael@0: void OpGetFilenames(); michael@0: void OpGetFile(const nsAString& aFilename); michael@0: void OpGetFiles(); michael@0: michael@0: nsresult ReaderReady(nsTArray >& aFileList, michael@0: nsresult aStatus); michael@0: michael@0: public: // static michael@0: static already_AddRefed Create(nsPIDOMWindow* aOwner, michael@0: ArchiveReader* aReader); michael@0: michael@0: private: michael@0: ~ArchiveRequest(); michael@0: michael@0: nsresult GetFilenamesResult(JSContext* aCx, michael@0: JS::Value* aValue, michael@0: nsTArray >& aFileList); michael@0: nsresult GetFileResult(JSContext* aCx, michael@0: JS::MutableHandle aValue, michael@0: nsTArray >& aFileList); michael@0: nsresult GetFilesResult(JSContext* aCx, michael@0: JS::MutableHandle aValue, michael@0: nsTArray >& aFileList); michael@0: michael@0: protected: michael@0: // The reader: michael@0: nsRefPtr mArchiveReader; michael@0: michael@0: // The operation: michael@0: enum { michael@0: GetFilenames, michael@0: GetFile, michael@0: GetFiles michael@0: } mOperation; michael@0: michael@0: // The filename (needed by GetFile): michael@0: nsString mFilename; michael@0: }; michael@0: michael@0: END_FILE_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_file_domarchiverequest_h__