Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/OSFileSystem.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 file,
5
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_OSFileSystem_h
8
#define mozilla_dom_OSFileSystem_h
9
10
#include "mozilla/dom/FileSystemBase.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
class OSFileSystem final : public FileSystemBase
16
{
17
public:
18
  explicit OSFileSystem(const nsAString& aRootDir);
19
20
  void
21
  Init(nsISupports* aParent);
22
23
  // Overrides FileSystemBase
24
25
  virtual already_AddRefed<FileSystemBase>
26
  Clone() override;
27
28
  virtual bool
29
  ShouldCreateDirectory() override
30
  {
31
    MOZ_CRASH("This should not be called.");
32
    // Because OSFileSystem should not be used when the creation of directories
33
    // is needed. For that we have OSFileSystemParent.
34
    return false;
35
  }
36
37
  virtual nsISupports*
38
  GetParentObject() const override;
39
40
  virtual bool
41
  IsSafeFile(nsIFile* aFile) const override;
42
43
  virtual bool
44
  IsSafeDirectory(Directory* aDir) const override;
45
46
  virtual void
47
  SerializeDOMPath(nsAString& aOutput) const override;
48
49
  // CC methods
50
  virtual void Unlink() override;
51
  virtual void Traverse(nsCycleCollectionTraversalCallback &cb) override;
52
53
private:
54
  virtual ~OSFileSystem() {}
55
56
  nsCOMPtr<nsISupports> mParent;
57
};
58
59
class OSFileSystemParent final : public FileSystemBase
60
{
61
public:
62
  explicit OSFileSystemParent(const nsAString& aRootDir);
63
64
  // Overrides FileSystemBase
65
66
  virtual already_AddRefed<FileSystemBase>
67
  Clone() override
68
  {
69
    MOZ_CRASH("This should not be called on the PBackground thread.");
70
    return nullptr;
71
  }
72
73
  virtual bool
74
  ShouldCreateDirectory() override { return false; }
75
76
  virtual nsISupports*
77
  GetParentObject() const override
78
  {
79
    MOZ_CRASH("This should not be called on the PBackground thread.");
80
    return nullptr;
81
  }
82
83
  virtual void
84
  GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
85
                   ErrorResult& aRv) const override
86
  {
87
    MOZ_CRASH("This should not be called on the PBackground thread.");
88
  }
89
90
  virtual bool
91
  IsSafeFile(nsIFile* aFile) const override
92
  {
93
    return true;
94
  }
95
96
  virtual bool
97
  IsSafeDirectory(Directory* aDir) const override
98
  {
99
    MOZ_CRASH("This should not be called on the PBackground thread.");
100
    return true;
101
  }
102
103
  virtual void
104
  SerializeDOMPath(nsAString& aOutput) const override
105
  {
106
    MOZ_CRASH("This should not be called on the PBackground thread.");
107
  }
108
109
  // CC methods
110
  virtual void
111
  Unlink() override
112
  {
113
    MOZ_CRASH("This should not be called on the PBackground thread.");
114
  }
115
116
  virtual void
117
  Traverse(nsCycleCollectionTraversalCallback &cb) override
118
  {
119
    MOZ_CRASH("This should not be called on the PBackground thread.");
120
  }
121
122
private:
123
0
  virtual ~OSFileSystemParent() {}
124
};
125
126
} // namespace dom
127
} // namespace mozilla
128
129
#endif // mozilla_dom_OSFileSystem_h