Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/filesystem/OSFileSystem.cpp
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
#include "mozilla/dom/OSFileSystem.h"
8
9
#include "mozilla/dom/Directory.h"
10
#include "mozilla/dom/File.h"
11
#include "mozilla/dom/FileSystemUtils.h"
12
#include "nsIGlobalObject.h"
13
#include "nsCOMPtr.h"
14
#include "nsDebug.h"
15
#include "nsIFile.h"
16
17
namespace mozilla {
18
namespace dom {
19
20
OSFileSystem::OSFileSystem(const nsAString& aRootDir)
21
0
{
22
0
  mLocalRootPath = aRootDir;
23
0
}
24
25
already_AddRefed<FileSystemBase>
26
OSFileSystem::Clone()
27
0
{
28
0
  AssertIsOnOwningThread();
29
0
30
0
  RefPtr<OSFileSystem> fs = new OSFileSystem(mLocalRootPath);
31
0
  if (mParent) {
32
0
    fs->Init(mParent);
33
0
  }
34
0
35
0
  return fs.forget();
36
0
}
37
38
void
39
OSFileSystem::Init(nsISupports* aParent)
40
0
{
41
0
  AssertIsOnOwningThread();
42
0
  MOZ_ASSERT(!mParent, "No duple Init() calls");
43
0
  MOZ_ASSERT(aParent);
44
0
45
0
  mParent = aParent;
46
0
47
#ifdef DEBUG
48
  nsCOMPtr<nsIGlobalObject> obj = do_QueryInterface(aParent);
49
  MOZ_ASSERT(obj);
50
#endif
51
}
52
53
nsISupports*
54
OSFileSystem::GetParentObject() const
55
0
{
56
0
  AssertIsOnOwningThread();
57
0
  return mParent;
58
0
}
59
60
bool
61
OSFileSystem::IsSafeFile(nsIFile* aFile) const
62
0
{
63
0
  // The concept of "safe files" is specific to the Device Storage API where
64
0
  // files are only "safe" if they're of a type that is appropriate for the
65
0
  // area of device storage that is being used.
66
0
  MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
67
0
  return true;
68
0
}
69
70
bool
71
OSFileSystem::IsSafeDirectory(Directory* aDir) const
72
0
{
73
0
  // The concept of "safe directory" is specific to the Device Storage API
74
0
  // where a directory is only "safe" if it belongs to the area of device
75
0
  // storage that it is being used with.
76
0
  MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
77
0
  return true;
78
0
}
79
80
void
81
OSFileSystem::Unlink()
82
0
{
83
0
  AssertIsOnOwningThread();
84
0
  mParent = nullptr;
85
0
}
86
87
void
88
OSFileSystem::Traverse(nsCycleCollectionTraversalCallback &cb)
89
0
{
90
0
  AssertIsOnOwningThread();
91
0
92
0
  OSFileSystem* tmp = this;
93
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent);
94
0
}
95
96
void
97
OSFileSystem::SerializeDOMPath(nsAString& aOutput) const
98
0
{
99
0
  AssertIsOnOwningThread();
100
0
  aOutput = mLocalRootPath;
101
0
}
102
103
/**
104
 * OSFileSystemParent
105
 */
106
107
OSFileSystemParent::OSFileSystemParent(const nsAString& aRootDir)
108
0
{
109
0
  mLocalRootPath = aRootDir;
110
0
}
111
112
} // namespace dom
113
} // namespace mozilla