Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/file/StreamBlobImpl.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_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
  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(already_AddRefed<nsIInputStream> aInputStream,
27
         const nsAString& aContentType,
28
         uint64_t aLength);
29
30
  static already_AddRefed<StreamBlobImpl>
31
  Create(already_AddRefed<nsIInputStream> aInputStream,
32
         const nsAString& aName,
33
         const nsAString& aContentType,
34
         int64_t aLastModifiedDate,
35
         uint64_t aLength);
36
37
  virtual void CreateInputStream(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
  virtual bool IsMemoryFile() const override
45
0
  {
46
0
    return true;
47
0
  }
48
49
  int64_t GetFileId() override
50
0
  {
51
0
    return mFileId;
52
0
  }
53
54
  void SetFileId(int64_t aFileId)
55
0
  {
56
0
    mFileId = aFileId;
57
0
  }
58
59
  void SetFullPath(const nsAString& aFullPath)
60
0
  {
61
0
    mFullPath = aFullPath;
62
0
  }
63
64
  void GetMozFullPathInternal(nsAString& aFullPath,
65
                              ErrorResult& aRv) const override
66
0
  {
67
0
    aFullPath = mFullPath;
68
0
  }
69
70
  void SetIsDirectory(bool aIsDirectory)
71
0
  {
72
0
    mIsDirectory = aIsDirectory;
73
0
  }
74
75
  bool IsDirectory() const override
76
0
  {
77
0
    return mIsDirectory;
78
0
  }
79
80
  size_t GetAllocationSize() const override;
81
82
  size_t GetAllocationSize(FallibleTArray<BlobImpl*>& aVisitedBlobImpls) const override
83
0
  {
84
0
    return GetAllocationSize();
85
0
  }
86
87
private:
88
  StreamBlobImpl(already_AddRefed<nsIInputStream> aInputStream,
89
                 const nsAString& aContentType,
90
                 uint64_t aLength);
91
92
  StreamBlobImpl(already_AddRefed<nsIInputStream> aInputStream,
93
                 const nsAString& aName,
94
                 const nsAString& aContentType,
95
                 int64_t aLastModifiedDate,
96
                 uint64_t aLength);
97
98
  ~StreamBlobImpl();
99
100
  void MaybeRegisterMemoryReporter();
101
102
  nsCOMPtr<nsIInputStream> mInputStream;
103
104
  nsString mFullPath;
105
  bool mIsDirectory;
106
  int64_t mFileId;
107
};
108
109
} // namespace dom
110
} // namespace mozilla
111
112
#endif // mozilla_dom_StreamBlobImpl_h