/src/mozilla-central/dom/file/BlobImpl.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_BlobImpl_h |
8 | | #define mozilla_dom_BlobImpl_h |
9 | | |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/ErrorResult.h" |
12 | | #include "nsISupportsImpl.h" |
13 | | #include "nsString.h" |
14 | | |
15 | | #define BLOBIMPL_IID \ |
16 | | { 0xbccb3275, 0x6778, 0x4ac5, \ |
17 | | { 0xaf, 0x03, 0x90, 0xed, 0x37, 0xad, 0xdf, 0x5d } } |
18 | | |
19 | | class nsIInputStream; |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | // This is the abstract class for any File backend. It must be nsISupports |
25 | | // because this class must be ref-counted and it has to work with IPC. |
26 | | class BlobImpl : public nsISupports |
27 | | { |
28 | | public: |
29 | | NS_DECLARE_STATIC_IID_ACCESSOR(BLOBIMPL_IID) |
30 | | NS_DECL_THREADSAFE_ISUPPORTS |
31 | | |
32 | 0 | BlobImpl() {} |
33 | | |
34 | | virtual void GetName(nsAString& aName) const = 0; |
35 | | |
36 | | virtual void GetDOMPath(nsAString& aName) const = 0; |
37 | | |
38 | | virtual void SetDOMPath(const nsAString& aName) = 0; |
39 | | |
40 | | virtual int64_t GetLastModified(ErrorResult& aRv) = 0; |
41 | | |
42 | | virtual void SetLastModified(int64_t aLastModified) = 0; |
43 | | |
44 | | virtual void GetMozFullPath(nsAString& aName, |
45 | | SystemCallerGuarantee /* unused */, |
46 | | ErrorResult& aRv) const = 0; |
47 | | |
48 | | virtual void GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) const = 0; |
49 | | |
50 | | virtual uint64_t GetSize(ErrorResult& aRv) = 0; |
51 | | |
52 | | virtual void GetType(nsAString& aType) = 0; |
53 | | |
54 | | virtual size_t GetAllocationSize() const = 0; |
55 | | virtual size_t GetAllocationSize(FallibleTArray<BlobImpl*>& aVisitedBlobImpls) const = 0; |
56 | | |
57 | | /** |
58 | | * An effectively-unique serial number identifying this instance of FileImpl. |
59 | | * |
60 | | * Implementations should obtain a serial number from |
61 | | * FileImplBase::NextSerialNumber(). |
62 | | */ |
63 | | virtual uint64_t GetSerialNumber() const = 0; |
64 | | |
65 | | already_AddRefed<BlobImpl> |
66 | | Slice(const Optional<int64_t>& aStart, const Optional<int64_t>& aEnd, |
67 | | const nsAString& aContentType, ErrorResult& aRv); |
68 | | |
69 | | virtual already_AddRefed<BlobImpl> |
70 | | CreateSlice(uint64_t aStart, uint64_t aLength, |
71 | | const nsAString& aContentType, ErrorResult& aRv) = 0; |
72 | | |
73 | | virtual const nsTArray<RefPtr<BlobImpl>>* |
74 | | GetSubBlobImpls() const = 0; |
75 | | |
76 | | virtual void CreateInputStream(nsIInputStream** aStream, |
77 | | ErrorResult& aRv) = 0; |
78 | | |
79 | | virtual int64_t GetFileId() = 0; |
80 | | |
81 | | virtual nsresult GetSendInfo(nsIInputStream** aBody, |
82 | | uint64_t* aContentLength, |
83 | | nsACString& aContentType, |
84 | | nsACString& aCharset) = 0; |
85 | | |
86 | | virtual nsresult GetMutable(bool* aMutable) const = 0; |
87 | | |
88 | | virtual nsresult SetMutable(bool aMutable) = 0; |
89 | | |
90 | | virtual void SetLazyData(const nsAString& aName, |
91 | | const nsAString& aContentType, |
92 | | uint64_t aLength, |
93 | | int64_t aLastModifiedDate) = 0; |
94 | | |
95 | | virtual bool IsMemoryFile() const = 0; |
96 | | |
97 | | virtual bool IsSizeUnknown() const = 0; |
98 | | |
99 | | virtual bool IsDateUnknown() const = 0; |
100 | | |
101 | | virtual bool IsFile() const = 0; |
102 | | |
103 | | // Returns true if the BlobImpl is backed by an nsIFile and the underlying |
104 | | // file is a directory. |
105 | | virtual bool IsDirectory() const |
106 | 0 | { |
107 | 0 | return false; |
108 | 0 | } |
109 | | |
110 | | // True if this implementation can be sent to other threads. |
111 | | virtual bool MayBeClonedToOtherThreads() const |
112 | 0 | { |
113 | 0 | return true; |
114 | 0 | } |
115 | | |
116 | | protected: |
117 | 0 | virtual ~BlobImpl() {} |
118 | | }; |
119 | | |
120 | | NS_DEFINE_STATIC_IID_ACCESSOR(BlobImpl, BLOBIMPL_IID) |
121 | | |
122 | | } // namespace dom |
123 | | } // namespace mozilla |
124 | | |
125 | | #endif // mozilla_dom_BlobImpl_h |