/work/obj-fuzz/dist/include/mozilla/dom/IDBFileRequest.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=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_idbfilerequest_h__ |
8 | | #define mozilla_dom_idbfilerequest_h__ |
9 | | |
10 | | #include "DOMRequest.h" |
11 | | #include "js/TypeDecls.h" |
12 | | #include "mozilla/Attributes.h" |
13 | | #include "nsCycleCollectionParticipant.h" |
14 | | #include "nsString.h" |
15 | | |
16 | | template <class> struct already_AddRefed; |
17 | | |
18 | | namespace mozilla { |
19 | | |
20 | | class EventChainPreVisitor; |
21 | | |
22 | | namespace dom { |
23 | | |
24 | | class IDBFileHandle; |
25 | | |
26 | | class IDBFileRequest final |
27 | | : public DOMRequest |
28 | | { |
29 | | RefPtr<IDBFileHandle> mFileHandle; |
30 | | |
31 | | nsString mEncoding; |
32 | | |
33 | | bool mWrapAsDOMRequest; |
34 | | bool mHasEncoding; |
35 | | |
36 | | public: |
37 | | class ResultCallback; |
38 | | |
39 | | static already_AddRefed<IDBFileRequest> |
40 | | Create(IDBFileHandle* aFileHandle, |
41 | | bool aWrapAsDOMRequest); |
42 | | |
43 | | void |
44 | | SetEncoding(const nsAString& aEncoding) |
45 | | { |
46 | | mEncoding = aEncoding; |
47 | | mHasEncoding = true; |
48 | | } |
49 | | |
50 | | const nsAString& |
51 | | GetEncoding() const |
52 | | { |
53 | | return mEncoding; |
54 | | } |
55 | | |
56 | | bool |
57 | | HasEncoding() const |
58 | | { |
59 | | return mHasEncoding; |
60 | | } |
61 | | |
62 | | void |
63 | | FireProgressEvent(uint64_t aLoaded, uint64_t aTotal); |
64 | | |
65 | | void |
66 | | SetResultCallback(ResultCallback* aCallback); |
67 | | |
68 | | // WebIDL |
69 | | IDBFileHandle* |
70 | | GetFileHandle() const |
71 | 0 | { |
72 | 0 | AssertIsOnOwningThread(); |
73 | 0 | return mFileHandle; |
74 | 0 | } |
75 | | |
76 | | IDBFileHandle* |
77 | | GetLockedFile() const |
78 | 0 | { |
79 | 0 | AssertIsOnOwningThread(); |
80 | 0 | return GetFileHandle(); |
81 | 0 | } |
82 | | |
83 | | IMPL_EVENT_HANDLER(progress) |
84 | | |
85 | | void |
86 | | AssertIsOnOwningThread() const |
87 | 0 | { |
88 | 0 | NS_ASSERT_OWNINGTHREAD(IDBFileRequest); |
89 | 0 | } |
90 | | |
91 | | NS_DECL_ISUPPORTS_INHERITED |
92 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBFileRequest, DOMRequest) |
93 | | |
94 | | // EventTarget |
95 | | void GetEventTargetParent(EventChainPreVisitor& aVisitor) override; |
96 | | |
97 | | // nsWrapperCache |
98 | | virtual JSObject* |
99 | | WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
100 | | |
101 | | private: |
102 | | IDBFileRequest(IDBFileHandle* aFileHandle, |
103 | | bool aWrapAsDOMRequest); |
104 | | |
105 | | ~IDBFileRequest(); |
106 | | }; |
107 | | |
108 | | class NS_NO_VTABLE IDBFileRequest::ResultCallback |
109 | | { |
110 | | public: |
111 | | virtual nsresult |
112 | | GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult) = 0; |
113 | | |
114 | | protected: |
115 | | ResultCallback() |
116 | | { } |
117 | | }; |
118 | | |
119 | | } // namespace dom |
120 | | } // namespace mozilla |
121 | | |
122 | | #endif // mozilla_dom_idbfilerequest_h__ |