/work/obj-fuzz/dist/include/mozilla/dom/FileBlobImpl.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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_FileBlobImpl_h |
8 | | #define mozilla_dom_FileBlobImpl_h |
9 | | |
10 | | #include "mozilla/dom/BaseBlobImpl.h" |
11 | | |
12 | | class nsIFile; |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | class FileBlobImpl : public BaseBlobImpl |
18 | | { |
19 | | public: |
20 | | NS_INLINE_DECL_REFCOUNTING_INHERITED(FileBlobImpl, BaseBlobImpl) |
21 | | |
22 | | // Create as a file |
23 | | explicit FileBlobImpl(nsIFile* aFile); |
24 | | |
25 | | // Create as a file |
26 | | FileBlobImpl(const nsAString& aName, const nsAString& aContentType, |
27 | | uint64_t aLength, nsIFile* aFile); |
28 | | |
29 | | FileBlobImpl(const nsAString& aName, const nsAString& aContentType, |
30 | | uint64_t aLength, nsIFile* aFile, |
31 | | int64_t aLastModificationDate); |
32 | | |
33 | | // Create as a file with custom name |
34 | | FileBlobImpl(nsIFile* aFile, const nsAString& aName, |
35 | | const nsAString& aContentType); |
36 | | |
37 | | // Overrides |
38 | | virtual uint64_t GetSize(ErrorResult& aRv) override; |
39 | | virtual void GetType(nsAString& aType) override; |
40 | | virtual int64_t GetLastModified(ErrorResult& aRv) override; |
41 | | virtual void SetLastModified(int64_t aLastModified) override; |
42 | | virtual void GetMozFullPathInternal(nsAString& aFullPath, |
43 | | ErrorResult& aRv) const override; |
44 | | virtual void CreateInputStream(nsIInputStream** aInputStream, |
45 | | ErrorResult& aRv) override; |
46 | | |
47 | | virtual bool IsDirectory() const override; |
48 | | |
49 | | // We always have size and date for this kind of blob. |
50 | | virtual bool IsSizeUnknown() const override { return false; } |
51 | | virtual bool IsDateUnknown() const override { return false; } |
52 | | |
53 | | void SetName(const nsAString& aName) |
54 | | { |
55 | | mName = aName; |
56 | | } |
57 | | |
58 | | void SetType(const nsAString& aType) |
59 | | { |
60 | | mContentType = aType; |
61 | | } |
62 | | |
63 | | int64_t GetFileId() override |
64 | | { |
65 | | return mFileId; |
66 | | } |
67 | | |
68 | | void SetFileId(int64_t aFileId) |
69 | 0 | { |
70 | 0 | mFileId = aFileId; |
71 | 0 | } |
72 | | |
73 | | protected: |
74 | | virtual ~FileBlobImpl() = default; |
75 | | |
76 | | // Create slice |
77 | | FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart, |
78 | | uint64_t aLength, const nsAString& aContentType); |
79 | | |
80 | | virtual already_AddRefed<BlobImpl> |
81 | | CreateSlice(uint64_t aStart, uint64_t aLength, |
82 | | const nsAString& aContentType, ErrorResult& aRv) override; |
83 | | |
84 | | nsCOMPtr<nsIFile> mFile; |
85 | | bool mWholeFile; |
86 | | int64_t mFileId; |
87 | | }; |
88 | | |
89 | | } // namespace dom |
90 | | } // namespace mozilla |
91 | | |
92 | | #endif // mozilla_dom_FileBlobImpl_h |