|
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/. */ |
|
6 |
|
7 #ifndef mozilla_dom_file_domarchivefile_h__ |
|
8 #define mozilla_dom_file_domarchivefile_h__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "nsDOMFile.h" |
|
12 |
|
13 #include "ArchiveReader.h" |
|
14 |
|
15 #include "FileCommon.h" |
|
16 #include "zipstruct.h" |
|
17 |
|
18 BEGIN_FILE_NAMESPACE |
|
19 |
|
20 /** |
|
21 * ZipFile to DOMFileCC |
|
22 */ |
|
23 class ArchiveZipFile : public nsDOMFileCC |
|
24 { |
|
25 public: |
|
26 ArchiveZipFile(const nsAString& aName, |
|
27 const nsAString& aContentType, |
|
28 uint64_t aLength, |
|
29 ZipCentral& aCentral, |
|
30 ArchiveReader* aReader) |
|
31 : nsDOMFileCC(aName, aContentType, aLength), |
|
32 mCentral(aCentral), |
|
33 mArchiveReader(aReader), |
|
34 mFilename(aName) |
|
35 { |
|
36 NS_ASSERTION(mArchiveReader, "must have a reader"); |
|
37 MOZ_COUNT_CTOR(ArchiveZipFile); |
|
38 } |
|
39 |
|
40 ArchiveZipFile(const nsAString& aName, |
|
41 const nsAString& aContentType, |
|
42 uint64_t aStart, |
|
43 uint64_t aLength, |
|
44 ZipCentral& aCentral, |
|
45 ArchiveReader* aReader) |
|
46 : nsDOMFileCC(aContentType, aStart, aLength), |
|
47 mCentral(aCentral), |
|
48 mArchiveReader(aReader), |
|
49 mFilename(aName) |
|
50 { |
|
51 NS_ASSERTION(mArchiveReader, "must have a reader"); |
|
52 MOZ_COUNT_CTOR(ArchiveZipFile); |
|
53 } |
|
54 |
|
55 virtual ~ArchiveZipFile() |
|
56 { |
|
57 MOZ_COUNT_DTOR(ArchiveZipFile); |
|
58 } |
|
59 |
|
60 // Overrides: |
|
61 NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE; |
|
62 |
|
63 NS_DECL_ISUPPORTS_INHERITED |
|
64 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveZipFile, nsDOMFileCC) |
|
65 |
|
66 protected: |
|
67 virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart, |
|
68 uint64_t aLength, |
|
69 const nsAString& aContentType) MOZ_OVERRIDE; |
|
70 |
|
71 private: // Data |
|
72 ZipCentral mCentral; |
|
73 nsRefPtr<ArchiveReader> mArchiveReader; |
|
74 |
|
75 nsString mFilename; |
|
76 }; |
|
77 |
|
78 END_FILE_NAMESPACE |
|
79 |
|
80 #endif // mozilla_dom_file_domarchivefile_h__ |