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_archivereader_domarchivereader_h__
8 #define mozilla_dom_archivereader_domarchivereader_h__
10 #include "nsWrapperCache.h"
12 #include "ArchiveReaderCommon.h"
14 #include "nsCOMArray.h"
15 #include "nsIChannel.h"
16 #include "nsIDOMFile.h"
17 #include "mozilla/Attributes.h"
21 struct ArchiveReaderOptions
;
26 } // namespace mozilla
28 BEGIN_ARCHIVEREADER_NAMESPACE
33 * This is the ArchiveReader object
35 class ArchiveReader MOZ_FINAL
: public nsISupports
,
39 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
40 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ArchiveReader
)
42 static already_AddRefed
<ArchiveReader
>
43 Constructor(const GlobalObject
& aGlobal
, File
& aBlob
,
44 const ArchiveReaderOptions
& aOptions
, ErrorResult
& aError
);
46 ArchiveReader(File
& aBlob
, nsPIDOMWindow
* aWindow
,
47 const nsACString
& aEncoding
);
49 nsIDOMWindow
* GetParentObject() const
54 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
56 already_AddRefed
<ArchiveRequest
> GetFilenames();
57 already_AddRefed
<ArchiveRequest
> GetFile(const nsAString
& filename
);
58 already_AddRefed
<ArchiveRequest
> GetFiles();
60 nsresult
GetInputStream(nsIInputStream
** aInputStream
);
61 nsresult
GetSize(uint64_t* aSize
);
63 public: // for the ArchiveRequest:
64 nsresult
RegisterRequest(ArchiveRequest
* aRequest
);
66 public: // For events:
67 FileImpl
* GetFileImpl() const
72 void Ready(nsTArray
<nsCOMPtr
<nsIDOMFile
> >& aFileList
,
78 already_AddRefed
<ArchiveRequest
> GenerateArchiveRequest();
80 nsresult
OpenArchive();
82 void RequestReady(ArchiveRequest
* aRequest
);
85 // The archive blob/file
86 nsRefPtr
<FileImpl
> mFileImpl
;
88 // The window is needed by the requests
89 nsCOMPtr
<nsPIDOMWindow
> mWindow
;
91 // Are we ready to return data?
100 Header
, // We are collecting the header: 30bytes
101 Name
, // The name length is contained in the header
102 Data
, // The length of the data segment COULD be written in the header
103 Search
// ... if the data length is unknown (== 0) we wait until we read a new header
106 // List of requests to be processed
107 nsTArray
<nsRefPtr
<ArchiveRequest
> > mRequests
;
109 // Everything related to the blobs and the status:
111 nsTArray
<nsCOMPtr
<nsIDOMFile
> > fileList
;
118 END_ARCHIVEREADER_NAMESPACE
120 #endif // mozilla_dom_archivereader_domarchivereader_h__