1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/file/ArchiveRequest.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_file_domarchiverequest_h__ 1.11 +#define mozilla_dom_file_domarchiverequest_h__ 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "ArchiveReader.h" 1.15 +#include "DOMRequest.h" 1.16 + 1.17 +#include "FileCommon.h" 1.18 + 1.19 +namespace mozilla { 1.20 +class EventChainPreVisitor; 1.21 +} // namespace mozilla 1.22 + 1.23 +BEGIN_FILE_NAMESPACE 1.24 + 1.25 +/** 1.26 + * This is the ArchiveRequest that handles any operation 1.27 + * related to ArchiveReader 1.28 + */ 1.29 +class ArchiveRequest : public mozilla::dom::DOMRequest 1.30 +{ 1.31 +public: 1.32 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.33 + 1.34 + ArchiveReader* Reader() const; 1.35 + 1.36 + NS_DECL_ISUPPORTS_INHERITED 1.37 + 1.38 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest) 1.39 + 1.40 + ArchiveRequest(nsPIDOMWindow* aWindow, 1.41 + ArchiveReader* aReader); 1.42 + 1.43 + // nsIDOMEventTarget 1.44 + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; 1.45 + 1.46 +public: 1.47 + // This is called by the DOMArchiveRequestEvent 1.48 + void Run(); 1.49 + 1.50 + // Set the types for this request 1.51 + void OpGetFilenames(); 1.52 + void OpGetFile(const nsAString& aFilename); 1.53 + void OpGetFiles(); 1.54 + 1.55 + nsresult ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList, 1.56 + nsresult aStatus); 1.57 + 1.58 +public: // static 1.59 + static already_AddRefed<ArchiveRequest> Create(nsPIDOMWindow* aOwner, 1.60 + ArchiveReader* aReader); 1.61 + 1.62 +private: 1.63 + ~ArchiveRequest(); 1.64 + 1.65 + nsresult GetFilenamesResult(JSContext* aCx, 1.66 + JS::Value* aValue, 1.67 + nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList); 1.68 + nsresult GetFileResult(JSContext* aCx, 1.69 + JS::MutableHandle<JS::Value> aValue, 1.70 + nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList); 1.71 + nsresult GetFilesResult(JSContext* aCx, 1.72 + JS::MutableHandle<JS::Value> aValue, 1.73 + nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList); 1.74 + 1.75 +protected: 1.76 + // The reader: 1.77 + nsRefPtr<ArchiveReader> mArchiveReader; 1.78 + 1.79 + // The operation: 1.80 + enum { 1.81 + GetFilenames, 1.82 + GetFile, 1.83 + GetFiles 1.84 + } mOperation; 1.85 + 1.86 + // The filename (needed by GetFile): 1.87 + nsString mFilename; 1.88 +}; 1.89 + 1.90 +END_FILE_NAMESPACE 1.91 + 1.92 +#endif // mozilla_dom_file_domarchiverequest_h__