|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
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_CreateFileTask_h |
|
8 #define mozilla_dom_CreateFileTask_h |
|
9 |
|
10 #include "mozilla/dom/FileSystemTaskBase.h" |
|
11 #include "nsAutoPtr.h" |
|
12 |
|
13 class nsIDOMBlob; |
|
14 class nsIInputStream; |
|
15 |
|
16 namespace mozilla { |
|
17 namespace dom { |
|
18 |
|
19 class Promise; |
|
20 |
|
21 class CreateFileTask MOZ_FINAL |
|
22 : public FileSystemTaskBase |
|
23 { |
|
24 public: |
|
25 CreateFileTask(FileSystemBase* aFileSystem, |
|
26 const nsAString& aPath, |
|
27 nsIDOMBlob* aBlobData, |
|
28 InfallibleTArray<uint8_t>& aArrayData, |
|
29 bool replace); |
|
30 CreateFileTask(FileSystemBase* aFileSystem, |
|
31 const FileSystemCreateFileParams& aParam, |
|
32 FileSystemRequestParent* aParent); |
|
33 |
|
34 virtual |
|
35 ~CreateFileTask(); |
|
36 |
|
37 already_AddRefed<Promise> |
|
38 GetPromise(); |
|
39 |
|
40 virtual void |
|
41 GetPermissionAccessType(nsCString& aAccess) const MOZ_OVERRIDE; |
|
42 |
|
43 protected: |
|
44 virtual FileSystemParams |
|
45 GetRequestParams(const nsString& aFileSystem) const MOZ_OVERRIDE; |
|
46 |
|
47 virtual FileSystemResponseValue |
|
48 GetSuccessRequestResult() const MOZ_OVERRIDE; |
|
49 |
|
50 virtual void |
|
51 SetSuccessRequestResult(const FileSystemResponseValue& aValue) MOZ_OVERRIDE; |
|
52 |
|
53 virtual nsresult |
|
54 Work() MOZ_OVERRIDE; |
|
55 |
|
56 virtual void |
|
57 HandlerCallback() MOZ_OVERRIDE; |
|
58 |
|
59 private: |
|
60 void |
|
61 GetOutputBufferSize() const; |
|
62 |
|
63 static uint32_t sOutputBufferSize; |
|
64 nsRefPtr<Promise> mPromise; |
|
65 nsString mTargetRealPath; |
|
66 nsCOMPtr<nsIDOMBlob> mBlobData; |
|
67 nsCOMPtr<nsIInputStream> mBlobStream; |
|
68 InfallibleTArray<uint8_t> mArrayData; |
|
69 bool mReplace; |
|
70 nsCOMPtr<nsIDOMFile> mTargetFile; |
|
71 }; |
|
72 |
|
73 } // namespace dom |
|
74 } // namespace mozilla |
|
75 |
|
76 #endif // mozilla_dom_CreateFileTask_h |