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/. */
7 #ifndef mozilla_dom_file_filehandle_h__
8 #define mozilla_dom_file_filehandle_h__
10 #include "FileCommon.h"
12 #include "nsIDOMFileHandle.h"
14 #include "nsIFileStorage.h"
16 #include "nsDOMEventTargetHelper.h"
18 #include "mozilla/Attributes.h"
19 #include "mozilla/dom/FileModeBinding.h"
28 } // namespace mozilla
38 * Must be subclassed. The subclass must implement CreateStream and
39 * CreateFileObject. Basically, every file storage implementation provides its
40 * own FileHandle implementation (for example IDBFileHandle provides IndexedDB
41 * specific implementation).
43 class FileHandle
: public nsDOMEventTargetHelper
,
44 public nsIDOMFileHandle
46 friend class FileService
;
47 friend class LockedFile
;
48 friend class FinishHelper
;
49 friend class FileHelper
;
52 NS_DECL_ISUPPORTS_INHERITED
53 NS_DECL_NSIDOMFILEHANDLE
55 nsPIDOMWindow
* GetParentObject() const
59 virtual JSObject
* WrapObject(JSContext
* aCx
,
60 JS::Handle
<JSObject
*> aScope
) MOZ_OVERRIDE
;
62 void GetName(nsString
& aName
) const
66 void GetType(nsString
& aType
) const
70 already_AddRefed
<nsIDOMLockedFile
> Open(FileMode aMode
, ErrorResult
& aError
);
71 already_AddRefed
<DOMRequest
> GetFile(ErrorResult
& aError
);
72 IMPL_EVENT_HANDLER(abort
)
73 IMPL_EVENT_HANDLER(error
)
75 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileHandle
, nsDOMEventTargetHelper
)
89 virtual already_AddRefed
<nsISupports
>
90 CreateStream(nsIFile
* aFile
, bool aReadOnly
) = 0;
92 virtual already_AddRefed
<nsIDOMFile
>
93 CreateFileObject(LockedFile
* aLockedFile
, uint32_t aFileSize
) = 0;
104 nsCOMPtr
<nsIFileStorage
> mFileStorage
;
109 nsCOMPtr
<nsIFile
> mFile
;
115 #endif // mozilla_dom_file_filehandle_h__