1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/filesystem/FileSystemBase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,109 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_FileSystemBase_h 1.11 +#define mozilla_dom_FileSystemBase_h 1.12 + 1.13 +#include "nsAutoPtr.h" 1.14 +#include "nsString.h" 1.15 + 1.16 +class nsIDOMFile; 1.17 +class nsPIDOMWindow; 1.18 + 1.19 +namespace mozilla { 1.20 +namespace dom { 1.21 + 1.22 +class Directory; 1.23 + 1.24 +class FileSystemBase 1.25 +{ 1.26 + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase) 1.27 +public: 1.28 + 1.29 + // Create file system object from its string representation. 1.30 + static already_AddRefed<FileSystemBase> 1.31 + FromString(const nsAString& aString); 1.32 + 1.33 + FileSystemBase(); 1.34 + 1.35 + virtual void 1.36 + Shutdown(); 1.37 + 1.38 + // Get the string representation of the file system. 1.39 + const nsString& 1.40 + ToString() const 1.41 + { 1.42 + return mString; 1.43 + } 1.44 + 1.45 + virtual nsPIDOMWindow* 1.46 + GetWindow() const; 1.47 + 1.48 + /* 1.49 + * Create nsIFile object with the given real path (absolute DOM path). 1.50 + */ 1.51 + virtual already_AddRefed<nsIFile> 1.52 + GetLocalFile(const nsAString& aRealPath) const = 0; 1.53 + 1.54 + /* 1.55 + * Get the virtual name of the root directory. This name will be exposed to 1.56 + * the content page. 1.57 + */ 1.58 + virtual const nsAString& 1.59 + GetRootName() const = 0; 1.60 + 1.61 + bool 1.62 + IsShutdown() const 1.63 + { 1.64 + return mShutdown; 1.65 + } 1.66 + 1.67 + virtual bool 1.68 + IsSafeFile(nsIFile* aFile) const; 1.69 + 1.70 + virtual bool 1.71 + IsSafeDirectory(Directory* aDir) const; 1.72 + 1.73 + /* 1.74 + * Get the real path (absolute DOM path) of the DOM file in the file system. 1.75 + * If succeeded, returns true. Otherwise, returns false and set aRealPath to 1.76 + * empty string. 1.77 + */ 1.78 + virtual bool 1.79 + GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0; 1.80 + 1.81 + /* 1.82 + * Get the permission name required to access this file system. 1.83 + */ 1.84 + const nsCString& 1.85 + GetPermission() const 1.86 + { 1.87 + return mPermission; 1.88 + } 1.89 + 1.90 + bool 1.91 + IsTesting() const 1.92 + { 1.93 + return mIsTesting; 1.94 + } 1.95 +protected: 1.96 + virtual ~FileSystemBase(); 1.97 + 1.98 + // The string representation of the file system. 1.99 + nsString mString; 1.100 + 1.101 + bool mShutdown; 1.102 + 1.103 + // The permission name required to access the file system. 1.104 + nsCString mPermission; 1.105 + 1.106 + bool mIsTesting; 1.107 +}; 1.108 + 1.109 +} // namespace dom 1.110 +} // namespace mozilla 1.111 + 1.112 +#endif // mozilla_dom_FileSystemBase_h