Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_file_filestreamwrappers_h__ |
michael@0 | 8 | #define mozilla_dom_file_filestreamwrappers_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "FileCommon.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "nsIInputStream.h" |
michael@0 | 13 | #include "nsIOutputStream.h" |
michael@0 | 14 | |
michael@0 | 15 | BEGIN_FILE_NAMESPACE |
michael@0 | 16 | |
michael@0 | 17 | class FileHelper; |
michael@0 | 18 | |
michael@0 | 19 | class FileStreamWrapper : public nsISupports |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 23 | |
michael@0 | 24 | FileStreamWrapper(nsISupports* aFileStream, |
michael@0 | 25 | FileHelper* aFileHelper, |
michael@0 | 26 | uint64_t aOffset, |
michael@0 | 27 | uint64_t aLimit, |
michael@0 | 28 | uint32_t aFlags); |
michael@0 | 29 | |
michael@0 | 30 | virtual ~FileStreamWrapper(); |
michael@0 | 31 | |
michael@0 | 32 | enum { |
michael@0 | 33 | NOTIFY_PROGRESS = 1 << 0, |
michael@0 | 34 | NOTIFY_CLOSE = 1 << 1, |
michael@0 | 35 | NOTIFY_DESTROY = 1 << 2 |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | protected: |
michael@0 | 39 | nsCOMPtr<nsISupports> mFileStream; |
michael@0 | 40 | nsRefPtr<FileHelper> mFileHelper; |
michael@0 | 41 | uint64_t mOffset; |
michael@0 | 42 | uint64_t mLimit; |
michael@0 | 43 | uint32_t mFlags; |
michael@0 | 44 | bool mFirstTime; |
michael@0 | 45 | }; |
michael@0 | 46 | |
michael@0 | 47 | class FileInputStreamWrapper : public FileStreamWrapper, |
michael@0 | 48 | public nsIInputStream |
michael@0 | 49 | { |
michael@0 | 50 | public: |
michael@0 | 51 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 52 | NS_DECL_NSIINPUTSTREAM |
michael@0 | 53 | |
michael@0 | 54 | FileInputStreamWrapper(nsISupports* aFileStream, |
michael@0 | 55 | FileHelper* aFileHelper, |
michael@0 | 56 | uint64_t aOffset, |
michael@0 | 57 | uint64_t aLimit, |
michael@0 | 58 | uint32_t aFlags); |
michael@0 | 59 | |
michael@0 | 60 | protected: |
michael@0 | 61 | virtual ~FileInputStreamWrapper() |
michael@0 | 62 | { } |
michael@0 | 63 | |
michael@0 | 64 | private: |
michael@0 | 65 | nsCOMPtr<nsIInputStream> mInputStream; |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | class FileOutputStreamWrapper : public FileStreamWrapper, |
michael@0 | 69 | public nsIOutputStream |
michael@0 | 70 | { |
michael@0 | 71 | public: |
michael@0 | 72 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 73 | NS_DECL_NSIOUTPUTSTREAM |
michael@0 | 74 | |
michael@0 | 75 | FileOutputStreamWrapper(nsISupports* aFileStream, |
michael@0 | 76 | FileHelper* aFileHelper, |
michael@0 | 77 | uint64_t aOffset, |
michael@0 | 78 | uint64_t aLimit, |
michael@0 | 79 | uint32_t aFlags); |
michael@0 | 80 | |
michael@0 | 81 | protected: |
michael@0 | 82 | virtual ~FileOutputStreamWrapper() |
michael@0 | 83 | { } |
michael@0 | 84 | |
michael@0 | 85 | private: |
michael@0 | 86 | nsCOMPtr<nsIOutputStream> mOutputStream; |
michael@0 | 87 | #ifdef DEBUG |
michael@0 | 88 | void* mWriteThread; |
michael@0 | 89 | #endif |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | END_FILE_NAMESPACE |
michael@0 | 93 | |
michael@0 | 94 | #endif // mozilla_dom_file_filestreamwrappers_h__ |