|
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_indexeddb_idbfilehandle_h__ |
|
8 #define mozilla_dom_indexeddb_idbfilehandle_h__ |
|
9 |
|
10 #include "IndexedDatabase.h" |
|
11 |
|
12 #include "mozilla/dom/file/FileHandle.h" |
|
13 #include "mozilla/dom/indexedDB/FileInfo.h" |
|
14 |
|
15 BEGIN_INDEXEDDB_NAMESPACE |
|
16 |
|
17 class IDBDatabase; |
|
18 |
|
19 class IDBFileHandle : public file::FileHandle |
|
20 { |
|
21 typedef mozilla::dom::file::LockedFile LockedFile; |
|
22 |
|
23 public: |
|
24 static already_AddRefed<IDBFileHandle> |
|
25 Create(IDBDatabase* aDatabase, const nsAString& aName, |
|
26 const nsAString& aType, already_AddRefed<FileInfo> aFileInfo); |
|
27 |
|
28 |
|
29 virtual int64_t |
|
30 GetFileId() MOZ_OVERRIDE |
|
31 { |
|
32 return mFileInfo->Id(); |
|
33 } |
|
34 |
|
35 virtual FileInfo* |
|
36 GetFileInfo() MOZ_OVERRIDE |
|
37 { |
|
38 return mFileInfo; |
|
39 } |
|
40 |
|
41 virtual already_AddRefed<nsISupports> |
|
42 CreateStream(nsIFile* aFile, bool aReadOnly) MOZ_OVERRIDE; |
|
43 |
|
44 virtual already_AddRefed<nsIDOMFile> |
|
45 CreateFileObject(LockedFile* aLockedFile, uint32_t aFileSize) MOZ_OVERRIDE; |
|
46 |
|
47 // nsWrapperCache |
|
48 virtual JSObject* |
|
49 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
50 |
|
51 // WebIDL |
|
52 IDBDatabase* |
|
53 Database(); |
|
54 |
|
55 private: |
|
56 IDBFileHandle(IDBDatabase* aOwner); |
|
57 |
|
58 ~IDBFileHandle() |
|
59 { |
|
60 } |
|
61 |
|
62 nsRefPtr<FileInfo> mFileInfo; |
|
63 }; |
|
64 |
|
65 END_INDEXEDDB_NAMESPACE |
|
66 |
|
67 #endif // mozilla_dom_indexeddb_idbfilehandle_h__ |