dom/file/FileRequest.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:bd2b91de2778
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_file_filerequest_h__
8 #define mozilla_dom_file_filerequest_h__
9
10 #include "mozilla/Attributes.h"
11 #include "FileCommon.h"
12
13 #include "DOMRequest.h"
14
15 namespace mozilla {
16 class EventChainPreVisitor;
17 } // namespace mozilla
18
19 BEGIN_FILE_NAMESPACE
20
21 class FileHelper;
22 class LockedFile;
23
24 class FileRequest : public mozilla::dom::DOMRequest
25 {
26 public:
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileRequest, DOMRequest)
29
30 static already_AddRefed<FileRequest>
31 Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile,
32 bool aWrapAsDOMRequest);
33
34 // nsIDOMEventTarget
35 virtual nsresult
36 PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
37
38 void
39 OnProgress(uint64_t aProgress, uint64_t aProgressMax)
40 {
41 FireProgressEvent(aProgress, aProgressMax);
42 }
43
44 nsresult
45 NotifyHelperCompleted(FileHelper* aFileHelper);
46
47 // nsWrapperCache
48 virtual JSObject*
49 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
50
51 // WebIDL
52 LockedFile*
53 GetLockedFile() const;
54
55 IMPL_EVENT_HANDLER(progress)
56
57 protected:
58 FileRequest(nsPIDOMWindow* aWindow);
59 ~FileRequest();
60
61 void
62 FireProgressEvent(uint64_t aLoaded, uint64_t aTotal);
63
64 nsRefPtr<LockedFile> mLockedFile;
65
66 bool mWrapAsDOMRequest;
67 };
68
69 END_FILE_NAMESPACE
70
71 #endif // mozilla_dom_file_filerequest_h__

mercurial