Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/filesystem/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
0
  {
31
0
    MOZ_CRASH("This should not be called.");
32
0
    // Because OSFileSystem should not be used when the creation of directories
33
0
    // is needed. For that we have OSFileSystemParent.
34
0
    return false;
35
0
  }
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
0
  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
0
  {
69
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
70
0
    return nullptr;
71
0
  }
72
73
  virtual bool
74
0
  ShouldCreateDirectory() override { return false; }
75
76
  virtual nsISupports*
77
  GetParentObject() const override
78
0
  {
79
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
80
0
    return nullptr;
81
0
  }
82
83
  virtual void
84
  GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
85
                   ErrorResult& aRv) const override
86
0
  {
87
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
88
0
  }
89
90
  virtual bool
91
  IsSafeFile(nsIFile* aFile) const override
92
0
  {
93
0
    return true;
94
0
  }
95
96
  virtual bool
97
  IsSafeDirectory(Directory* aDir) const override
98
0
  {
99
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
100
0
    return true;
101
0
  }
102
103
  virtual void
104
  SerializeDOMPath(nsAString& aOutput) const override
105
0
  {
106
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
107
0
  }
108
109
  // CC methods
110
  virtual void
111
  Unlink() override
112
0
  {
113
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
114
0
  }
115
116
  virtual void
117
  Traverse(nsCycleCollectionTraversalCallback &cb) override
118
0
  {
119
0
    MOZ_CRASH("This should not be called on the PBackground thread.");
120
0
  }
121
122
private:
123
  virtual ~OSFileSystemParent() {}
124
};
125
126
} // namespace dom
127
} // namespace mozilla
128
129
#endif // mozilla_dom_OSFileSystem_h