Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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 #ifndef mozilla_dom_FileSystemBase_h
8 #define mozilla_dom_FileSystemBase_h
10 #include "nsAutoPtr.h"
11 #include "nsString.h"
13 class nsIDOMFile;
14 class nsPIDOMWindow;
16 namespace mozilla {
17 namespace dom {
19 class Directory;
21 class FileSystemBase
22 {
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase)
24 public:
26 // Create file system object from its string representation.
27 static already_AddRefed<FileSystemBase>
28 FromString(const nsAString& aString);
30 FileSystemBase();
32 virtual void
33 Shutdown();
35 // Get the string representation of the file system.
36 const nsString&
37 ToString() const
38 {
39 return mString;
40 }
42 virtual nsPIDOMWindow*
43 GetWindow() const;
45 /*
46 * Create nsIFile object with the given real path (absolute DOM path).
47 */
48 virtual already_AddRefed<nsIFile>
49 GetLocalFile(const nsAString& aRealPath) const = 0;
51 /*
52 * Get the virtual name of the root directory. This name will be exposed to
53 * the content page.
54 */
55 virtual const nsAString&
56 GetRootName() const = 0;
58 bool
59 IsShutdown() const
60 {
61 return mShutdown;
62 }
64 virtual bool
65 IsSafeFile(nsIFile* aFile) const;
67 virtual bool
68 IsSafeDirectory(Directory* aDir) const;
70 /*
71 * Get the real path (absolute DOM path) of the DOM file in the file system.
72 * If succeeded, returns true. Otherwise, returns false and set aRealPath to
73 * empty string.
74 */
75 virtual bool
76 GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0;
78 /*
79 * Get the permission name required to access this file system.
80 */
81 const nsCString&
82 GetPermission() const
83 {
84 return mPermission;
85 }
87 bool
88 IsTesting() const
89 {
90 return mIsTesting;
91 }
92 protected:
93 virtual ~FileSystemBase();
95 // The string representation of the file system.
96 nsString mString;
98 bool mShutdown;
100 // The permission name required to access the file system.
101 nsCString mPermission;
103 bool mIsTesting;
104 };
106 } // namespace dom
107 } // namespace mozilla
109 #endif // mozilla_dom_FileSystemBase_h