dom/file/ArchiveEvent.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:83abaa668615
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_domarchiveevent_h__
8 #define mozilla_dom_file_domarchiveevent_h__
9
10 #include "ArchiveReader.h"
11
12 #include "nsISeekableStream.h"
13 #include "nsIMIMEService.h"
14 #include "nsDOMFile.h"
15
16 #include "FileCommon.h"
17
18 BEGIN_FILE_NAMESPACE
19
20 /**
21 * This class contains all the info needed for a single item
22 * It must contain the implementation of the File() method.
23 */
24 class ArchiveItem : public nsISupports
25 {
26 public:
27 NS_DECL_THREADSAFE_ISUPPORTS
28
29 ArchiveItem();
30 virtual ~ArchiveItem();
31
32 // Getter/Setter for the type
33 nsCString GetType();
34 void SetType(const nsCString& aType);
35
36 // Getter for the filename
37 virtual nsresult GetFilename(nsString& aFilename) = 0;
38
39 // Generate a DOMFile
40 virtual nsIDOMFile* File(ArchiveReader* aArchiveReader) = 0;
41
42 protected:
43 nsCString mType;
44 };
45
46 /**
47 * This class must be extended by any archive format supported by ArchiveReader API
48 * This class runs in a different thread and it calls the 'exec()' method.
49 * The exec() must populate mFileList and mStatus then it must call RunShare();
50 */
51 class ArchiveReaderEvent : public nsRunnable
52 {
53 public:
54 NS_DECL_NSIRUNNABLE
55
56 ArchiveReaderEvent(ArchiveReader* aArchiveReader);
57
58 virtual ~ArchiveReaderEvent();
59
60 // This must be implemented
61 virtual nsresult Exec() = 0;
62
63 protected:
64 nsresult GetType(nsCString& aExt,
65 nsCString& aMimeType);
66
67 nsresult RunShare(nsresult aStatus);
68 void ShareMainThread();
69
70 protected: // data
71 ArchiveReader* mArchiveReader;
72
73 nsCOMPtr<nsIMIMEService> mMimeService;
74
75 nsTArray<nsRefPtr<ArchiveItem> > mFileList; // this must be populated
76 nsresult mStatus;
77 };
78
79 END_FILE_NAMESPACE
80
81 #endif // mozilla_dom_file_domarchiveevent_h__
82

mercurial