no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / filesystem / OSFileSystem.cpp
blob2322d07b930321f7ecdd8901c73624c9e117b691
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/. */
7 #include "mozilla/dom/OSFileSystem.h"
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"
17 namespace mozilla::dom {
19 OSFileSystem::OSFileSystem(const nsAString& aRootDir) {
20 mLocalRootPath = aRootDir;
23 already_AddRefed<FileSystemBase> OSFileSystem::Clone() {
24 AssertIsOnOwningThread();
26 RefPtr<OSFileSystem> fs = new OSFileSystem(mLocalRootPath);
27 if (mGlobal) {
28 fs->Init(mGlobal);
31 return fs.forget();
34 void OSFileSystem::Init(nsIGlobalObject* aGlobal) {
35 AssertIsOnOwningThread();
36 MOZ_ASSERT(!mGlobal, "No duple Init() calls");
37 MOZ_ASSERT(aGlobal);
39 mGlobal = aGlobal;
42 nsIGlobalObject* OSFileSystem::GetParentObject() const {
43 AssertIsOnOwningThread();
44 return mGlobal;
47 bool OSFileSystem::IsSafeFile(nsIFile* aFile) const {
48 // The concept of "safe files" is specific to the Device Storage API where
49 // files are only "safe" if they're of a type that is appropriate for the
50 // area of device storage that is being used.
51 MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
52 return true;
55 bool OSFileSystem::IsSafeDirectory(Directory* aDir) const {
56 // The concept of "safe directory" is specific to the Device Storage API
57 // where a directory is only "safe" if it belongs to the area of device
58 // storage that it is being used with.
59 MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
60 return true;
63 void OSFileSystem::Unlink() {
64 AssertIsOnOwningThread();
65 mGlobal = nullptr;
68 void OSFileSystem::Traverse(nsCycleCollectionTraversalCallback& cb) {
69 AssertIsOnOwningThread();
71 OSFileSystem* tmp = this;
72 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal);
75 void OSFileSystem::SerializeDOMPath(nsAString& aOutput) const {
76 AssertIsOnOwningThread();
77 aOutput = mLocalRootPath;
80 /**
81 * OSFileSystemParent
84 OSFileSystemParent::OSFileSystemParent(const nsAString& aRootDir) {
85 mLocalRootPath = aRootDir;
88 } // namespace mozilla::dom