1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/file/FileStreamWrappers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_file_filestreamwrappers_h__ 1.11 +#define mozilla_dom_file_filestreamwrappers_h__ 1.12 + 1.13 +#include "FileCommon.h" 1.14 + 1.15 +#include "nsIInputStream.h" 1.16 +#include "nsIOutputStream.h" 1.17 + 1.18 +BEGIN_FILE_NAMESPACE 1.19 + 1.20 +class FileHelper; 1.21 + 1.22 +class FileStreamWrapper : public nsISupports 1.23 +{ 1.24 +public: 1.25 + NS_DECL_THREADSAFE_ISUPPORTS 1.26 + 1.27 + FileStreamWrapper(nsISupports* aFileStream, 1.28 + FileHelper* aFileHelper, 1.29 + uint64_t aOffset, 1.30 + uint64_t aLimit, 1.31 + uint32_t aFlags); 1.32 + 1.33 + virtual ~FileStreamWrapper(); 1.34 + 1.35 + enum { 1.36 + NOTIFY_PROGRESS = 1 << 0, 1.37 + NOTIFY_CLOSE = 1 << 1, 1.38 + NOTIFY_DESTROY = 1 << 2 1.39 + }; 1.40 + 1.41 +protected: 1.42 + nsCOMPtr<nsISupports> mFileStream; 1.43 + nsRefPtr<FileHelper> mFileHelper; 1.44 + uint64_t mOffset; 1.45 + uint64_t mLimit; 1.46 + uint32_t mFlags; 1.47 + bool mFirstTime; 1.48 +}; 1.49 + 1.50 +class FileInputStreamWrapper : public FileStreamWrapper, 1.51 + public nsIInputStream 1.52 +{ 1.53 +public: 1.54 + NS_DECL_ISUPPORTS_INHERITED 1.55 + NS_DECL_NSIINPUTSTREAM 1.56 + 1.57 + FileInputStreamWrapper(nsISupports* aFileStream, 1.58 + FileHelper* aFileHelper, 1.59 + uint64_t aOffset, 1.60 + uint64_t aLimit, 1.61 + uint32_t aFlags); 1.62 + 1.63 +protected: 1.64 + virtual ~FileInputStreamWrapper() 1.65 + { } 1.66 + 1.67 +private: 1.68 + nsCOMPtr<nsIInputStream> mInputStream; 1.69 +}; 1.70 + 1.71 +class FileOutputStreamWrapper : public FileStreamWrapper, 1.72 + public nsIOutputStream 1.73 +{ 1.74 +public: 1.75 + NS_DECL_ISUPPORTS_INHERITED 1.76 + NS_DECL_NSIOUTPUTSTREAM 1.77 + 1.78 + FileOutputStreamWrapper(nsISupports* aFileStream, 1.79 + FileHelper* aFileHelper, 1.80 + uint64_t aOffset, 1.81 + uint64_t aLimit, 1.82 + uint32_t aFlags); 1.83 + 1.84 +protected: 1.85 + virtual ~FileOutputStreamWrapper() 1.86 + { } 1.87 + 1.88 +private: 1.89 + nsCOMPtr<nsIOutputStream> mOutputStream; 1.90 +#ifdef DEBUG 1.91 + void* mWriteThread; 1.92 +#endif 1.93 +}; 1.94 + 1.95 +END_FILE_NAMESPACE 1.96 + 1.97 +#endif // mozilla_dom_file_filestreamwrappers_h__