|
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_filestreamwrappers_h__ |
|
8 #define mozilla_dom_file_filestreamwrappers_h__ |
|
9 |
|
10 #include "FileCommon.h" |
|
11 |
|
12 #include "nsIInputStream.h" |
|
13 #include "nsIOutputStream.h" |
|
14 |
|
15 BEGIN_FILE_NAMESPACE |
|
16 |
|
17 class FileHelper; |
|
18 |
|
19 class FileStreamWrapper : public nsISupports |
|
20 { |
|
21 public: |
|
22 NS_DECL_THREADSAFE_ISUPPORTS |
|
23 |
|
24 FileStreamWrapper(nsISupports* aFileStream, |
|
25 FileHelper* aFileHelper, |
|
26 uint64_t aOffset, |
|
27 uint64_t aLimit, |
|
28 uint32_t aFlags); |
|
29 |
|
30 virtual ~FileStreamWrapper(); |
|
31 |
|
32 enum { |
|
33 NOTIFY_PROGRESS = 1 << 0, |
|
34 NOTIFY_CLOSE = 1 << 1, |
|
35 NOTIFY_DESTROY = 1 << 2 |
|
36 }; |
|
37 |
|
38 protected: |
|
39 nsCOMPtr<nsISupports> mFileStream; |
|
40 nsRefPtr<FileHelper> mFileHelper; |
|
41 uint64_t mOffset; |
|
42 uint64_t mLimit; |
|
43 uint32_t mFlags; |
|
44 bool mFirstTime; |
|
45 }; |
|
46 |
|
47 class FileInputStreamWrapper : public FileStreamWrapper, |
|
48 public nsIInputStream |
|
49 { |
|
50 public: |
|
51 NS_DECL_ISUPPORTS_INHERITED |
|
52 NS_DECL_NSIINPUTSTREAM |
|
53 |
|
54 FileInputStreamWrapper(nsISupports* aFileStream, |
|
55 FileHelper* aFileHelper, |
|
56 uint64_t aOffset, |
|
57 uint64_t aLimit, |
|
58 uint32_t aFlags); |
|
59 |
|
60 protected: |
|
61 virtual ~FileInputStreamWrapper() |
|
62 { } |
|
63 |
|
64 private: |
|
65 nsCOMPtr<nsIInputStream> mInputStream; |
|
66 }; |
|
67 |
|
68 class FileOutputStreamWrapper : public FileStreamWrapper, |
|
69 public nsIOutputStream |
|
70 { |
|
71 public: |
|
72 NS_DECL_ISUPPORTS_INHERITED |
|
73 NS_DECL_NSIOUTPUTSTREAM |
|
74 |
|
75 FileOutputStreamWrapper(nsISupports* aFileStream, |
|
76 FileHelper* aFileHelper, |
|
77 uint64_t aOffset, |
|
78 uint64_t aLimit, |
|
79 uint32_t aFlags); |
|
80 |
|
81 protected: |
|
82 virtual ~FileOutputStreamWrapper() |
|
83 { } |
|
84 |
|
85 private: |
|
86 nsCOMPtr<nsIOutputStream> mOutputStream; |
|
87 #ifdef DEBUG |
|
88 void* mWriteThread; |
|
89 #endif |
|
90 }; |
|
91 |
|
92 END_FILE_NAMESPACE |
|
93 |
|
94 #endif // mozilla_dom_file_filestreamwrappers_h__ |