Line data Source code
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
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_FileCreatorHelper_h
8 : #define mozilla_dom_FileCreatorHelper_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "mozilla/RefPtr.h"
13 : #include "nsISupportsImpl.h"
14 :
15 : // Undefine the macro of CreateFile to avoid FileCreatorHelper#CreateFile being
16 : // replaced by FileCreatorHelper#CreateFileW.
17 : #ifdef CreateFile
18 : #undef CreateFile
19 : #endif
20 :
21 : class nsIFile;
22 : class nsIGlobalObject;
23 : class nsPIDOMWindowInner;
24 :
25 : namespace mozilla {
26 : namespace dom {
27 :
28 : struct ChromeFilePropertyBag;
29 : class Promise;
30 : class File;
31 :
32 : class FileCreatorHelper final
33 : {
34 : public:
35 0 : NS_INLINE_DECL_REFCOUNTING(FileCreatorHelper);
36 :
37 : static already_AddRefed<Promise>
38 : CreateFile(nsIGlobalObject* aGlobalObject,
39 : nsIFile* aFile,
40 : const ChromeFilePropertyBag& aBag,
41 : bool aIsFromNsIFile,
42 : ErrorResult& aRv);
43 :
44 : void
45 : ResponseReceived(BlobImpl* aBlobImpl, nsresult aRv);
46 :
47 : // For IPC only
48 : static nsresult
49 : CreateBlobImplForIPC(const nsAString& aPath,
50 : const nsAString& aType,
51 : const nsAString& aName,
52 : bool aLastModifiedPassed,
53 : int64_t aLastModified,
54 : bool aExistenceCheck,
55 : bool aIsFromNsIFile,
56 : BlobImpl** aBlobImpl);
57 :
58 : private:
59 : static already_AddRefed<File>
60 : CreateFileInternal(nsPIDOMWindowInner* aWindow,
61 : nsIFile* aFile,
62 : const ChromeFilePropertyBag& aBag,
63 : bool aIsFromNsIFile,
64 : ErrorResult& aRv);
65 :
66 : static nsresult
67 : CreateBlobImpl(nsIFile* aFile,
68 : const nsAString& aType,
69 : const nsAString& aName,
70 : bool aLastModifiedPassed,
71 : int64_t aLastModified,
72 : bool aExistenceCheck,
73 : bool aIsFromNsIFile,
74 : BlobImpl** aBlobImpl);
75 :
76 : FileCreatorHelper(Promise* aPromise, nsPIDOMWindowInner* aWindow);
77 : ~FileCreatorHelper();
78 :
79 : void
80 : SendRequest(nsIFile* aFile, const ChromeFilePropertyBag& aBag,
81 : bool aIsFromNsIFile, ErrorResult& aRv);
82 :
83 : RefPtr<Promise> mPromise;
84 : nsCOMPtr<nsPIDOMWindowInner> mWindow;
85 : };
86 :
87 : } // dom namespace
88 : } // mozilla namespace
89 :
90 : #endif // mozilla_dom_FileCreatorHelper_h
|