dom/filesystem/FileSystemBase.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_FileSystemBase_h
michael@0 8 #define mozilla_dom_FileSystemBase_h
michael@0 9
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "nsString.h"
michael@0 12
michael@0 13 class nsIDOMFile;
michael@0 14 class nsPIDOMWindow;
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace dom {
michael@0 18
michael@0 19 class Directory;
michael@0 20
michael@0 21 class FileSystemBase
michael@0 22 {
michael@0 23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase)
michael@0 24 public:
michael@0 25
michael@0 26 // Create file system object from its string representation.
michael@0 27 static already_AddRefed<FileSystemBase>
michael@0 28 FromString(const nsAString& aString);
michael@0 29
michael@0 30 FileSystemBase();
michael@0 31
michael@0 32 virtual void
michael@0 33 Shutdown();
michael@0 34
michael@0 35 // Get the string representation of the file system.
michael@0 36 const nsString&
michael@0 37 ToString() const
michael@0 38 {
michael@0 39 return mString;
michael@0 40 }
michael@0 41
michael@0 42 virtual nsPIDOMWindow*
michael@0 43 GetWindow() const;
michael@0 44
michael@0 45 /*
michael@0 46 * Create nsIFile object with the given real path (absolute DOM path).
michael@0 47 */
michael@0 48 virtual already_AddRefed<nsIFile>
michael@0 49 GetLocalFile(const nsAString& aRealPath) const = 0;
michael@0 50
michael@0 51 /*
michael@0 52 * Get the virtual name of the root directory. This name will be exposed to
michael@0 53 * the content page.
michael@0 54 */
michael@0 55 virtual const nsAString&
michael@0 56 GetRootName() const = 0;
michael@0 57
michael@0 58 bool
michael@0 59 IsShutdown() const
michael@0 60 {
michael@0 61 return mShutdown;
michael@0 62 }
michael@0 63
michael@0 64 virtual bool
michael@0 65 IsSafeFile(nsIFile* aFile) const;
michael@0 66
michael@0 67 virtual bool
michael@0 68 IsSafeDirectory(Directory* aDir) const;
michael@0 69
michael@0 70 /*
michael@0 71 * Get the real path (absolute DOM path) of the DOM file in the file system.
michael@0 72 * If succeeded, returns true. Otherwise, returns false and set aRealPath to
michael@0 73 * empty string.
michael@0 74 */
michael@0 75 virtual bool
michael@0 76 GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0;
michael@0 77
michael@0 78 /*
michael@0 79 * Get the permission name required to access this file system.
michael@0 80 */
michael@0 81 const nsCString&
michael@0 82 GetPermission() const
michael@0 83 {
michael@0 84 return mPermission;
michael@0 85 }
michael@0 86
michael@0 87 bool
michael@0 88 IsTesting() const
michael@0 89 {
michael@0 90 return mIsTesting;
michael@0 91 }
michael@0 92 protected:
michael@0 93 virtual ~FileSystemBase();
michael@0 94
michael@0 95 // The string representation of the file system.
michael@0 96 nsString mString;
michael@0 97
michael@0 98 bool mShutdown;
michael@0 99
michael@0 100 // The permission name required to access the file system.
michael@0 101 nsCString mPermission;
michael@0 102
michael@0 103 bool mIsTesting;
michael@0 104 };
michael@0 105
michael@0 106 } // namespace dom
michael@0 107 } // namespace mozilla
michael@0 108
michael@0 109 #endif // mozilla_dom_FileSystemBase_h

mercurial