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_StreamBlobImpl_h
8 : #define mozilla_dom_StreamBlobImpl_h
9 :
10 : #include "BaseBlobImpl.h"
11 : #include "nsIMemoryReporter.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : class StreamBlobImpl final : public BaseBlobImpl
17 : , public nsIMemoryReporter
18 : {
19 0 : MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
20 :
21 : public:
22 : NS_DECL_ISUPPORTS_INHERITED
23 : NS_DECL_NSIMEMORYREPORTER
24 :
25 : static already_AddRefed<StreamBlobImpl>
26 : Create(nsIInputStream* aInputStream,
27 : const nsAString& aContentType,
28 : uint64_t aLength);
29 :
30 : static already_AddRefed<StreamBlobImpl>
31 : Create(nsIInputStream* aInputStream,
32 : const nsAString& aName,
33 : const nsAString& aContentType,
34 : int64_t aLastModifiedDate,
35 : uint64_t aLength);
36 :
37 : virtual void GetInternalStream(nsIInputStream** aStream,
38 : ErrorResult& aRv) override;
39 :
40 : virtual already_AddRefed<BlobImpl>
41 : CreateSlice(uint64_t aStart, uint64_t aLength,
42 : const nsAString& aContentType, ErrorResult& aRv) override;
43 :
44 0 : virtual bool IsMemoryFile() const override
45 : {
46 0 : return true;
47 : }
48 :
49 0 : int64_t GetFileId() override
50 : {
51 0 : return mFileId;
52 : }
53 :
54 0 : void SetFileId(int64_t aFileId)
55 : {
56 0 : mFileId = aFileId;
57 0 : }
58 :
59 0 : void SetFullPath(const nsAString& aFullPath)
60 : {
61 0 : mFullPath = aFullPath;
62 0 : }
63 :
64 0 : void GetMozFullPathInternal(nsAString& aFullPath,
65 : ErrorResult& aRv) const override
66 : {
67 0 : aFullPath = mFullPath;
68 0 : }
69 :
70 0 : void SetIsDirectory(bool aIsDirectory)
71 : {
72 0 : mIsDirectory = aIsDirectory;
73 0 : }
74 :
75 0 : bool IsDirectory() const override
76 : {
77 0 : return mIsDirectory;
78 : }
79 :
80 : private:
81 : StreamBlobImpl(nsIInputStream* aInputStream,
82 : const nsAString& aContentType,
83 : uint64_t aLength);
84 :
85 : StreamBlobImpl(nsIInputStream* aInputStream,
86 : const nsAString& aName,
87 : const nsAString& aContentType,
88 : int64_t aLastModifiedDate,
89 : uint64_t aLength);
90 :
91 : StreamBlobImpl(StreamBlobImpl* aOther,
92 : const nsAString& aContentType,
93 : uint64_t aStart,
94 : uint64_t aLength);
95 :
96 : ~StreamBlobImpl();
97 :
98 : void MaybeRegisterMemoryReporter();
99 :
100 : nsCOMPtr<nsIInputStream> mInputStream;
101 :
102 : nsString mFullPath;
103 : bool mIsDirectory;
104 : int64_t mFileId;
105 : };
106 :
107 : } // namespace dom
108 : } // namespace mozilla
109 :
110 : #endif // mozilla_dom_StreamBlobImpl_h
|