| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_FILEAPI_MOUNT_POINTS_H_ | |
| 6 #define WEBKIT_FILEAPI_MOUNT_POINTS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "webkit/fileapi/file_system_util.h" | |
| 14 #include "webkit/storage/webkit_storage_export.h" | |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 namespace fileapi { | |
| 19 class FileSystemURL; | |
| 20 } | |
| 21 | |
| 22 namespace fileapi { | |
| 23 | |
| 24 // Represents a set of mount points for File API. | |
| 25 class WEBKIT_STORAGE_EXPORT MountPoints { | |
| 26 public: | |
| 27 struct WEBKIT_STORAGE_EXPORT MountPointInfo { | |
| 28 MountPointInfo(); | |
| 29 MountPointInfo(const std::string& name, const base::FilePath& path); | |
| 30 | |
| 31 // The name to be used to register the path. The registered file can | |
| 32 // be referred by a virtual path /<filesystem_id>/<name>. | |
| 33 // The name should NOT contain a path separator '/'. | |
| 34 std::string name; | |
| 35 | |
| 36 // The path of the file. | |
| 37 base::FilePath path; | |
| 38 | |
| 39 // For STL operation. | |
| 40 bool operator<(const MountPointInfo& that) const { | |
| 41 return name < that.name; | |
| 42 } | |
| 43 }; | |
| 44 | |
| 45 MountPoints() {} | |
| 46 virtual ~MountPoints() {} | |
| 47 | |
| 48 // Revokes a mount point identified by |mount_name|. | |
| 49 // Returns false if the |mount_name| is not (no longer) registered. | |
| 50 // TODO(kinuko): Probably this should be rather named RevokeMountPoint. | |
| 51 virtual bool RevokeFileSystem(const std::string& mount_name) = 0; | |
| 52 | |
| 53 // Returns true if the MountPoints implementation handles filesystems with | |
| 54 // the given mount type. | |
| 55 virtual bool HandlesFileSystemMountType(FileSystemType type) const = 0; | |
| 56 | |
| 57 // Same as CreateCrackedFileSystemURL, but cracks FileSystemURL created | |
| 58 // from |url|. | |
| 59 virtual FileSystemURL CrackURL(const GURL& url) const = 0; | |
| 60 | |
| 61 // Creates a FileSystemURL with the given origin, type and path and tries to | |
| 62 // crack it as a part of one of the registered mount points. | |
| 63 // If the the URL is not valid or does not belong to any of the mount points | |
| 64 // registered in this context, returns empty, invalid FileSystemURL. | |
| 65 virtual FileSystemURL CreateCrackedFileSystemURL( | |
| 66 const GURL& origin, | |
| 67 fileapi::FileSystemType type, | |
| 68 const base::FilePath& path) const = 0; | |
| 69 | |
| 70 // Returns the mount point root path registered for a given |mount_name|. | |
| 71 // Returns false if the given |mount_name| is not valid. | |
| 72 virtual bool GetRegisteredPath(const std::string& mount_name, | |
| 73 base::FilePath* path) const = 0; | |
| 74 | |
| 75 // Cracks the given |virtual_path| (which is the path part of a filesystem URL | |
| 76 // without '/external' or '/isolated' prefix part) and populates the | |
| 77 // |mount_name|, |type|, and |path| if the <mount_name> part embedded in | |
| 78 // the |virtual_path| (i.e. the first component of the |virtual_path|) is a | |
| 79 // valid registered filesystem ID or mount name for an existing mount point. | |
| 80 // | |
| 81 // Returns false if the given virtual_path cannot be cracked. | |
| 82 // | |
| 83 // Note that |path| is set to empty paths if the filesystem type is isolated | |
| 84 // and |virtual_path| has no <relative_path> part (i.e. pointing to the | |
| 85 // virtual root). | |
| 86 virtual bool CrackVirtualPath(const base::FilePath& virtual_path, | |
| 87 std::string* mount_name, | |
| 88 FileSystemType* type, | |
| 89 base::FilePath* path) const = 0; | |
| 90 | |
| 91 protected: | |
| 92 friend class FileSystemContext; | |
| 93 | |
| 94 // Same as CrackURL and CreateCrackedFileSystemURL, but cracks the url already | |
| 95 // instantiated as the FileSystemURL class. This is internally used for nested | |
| 96 // URL cracking in FileSystemContext. | |
| 97 virtual FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const = 0; | |
| 98 | |
| 99 private: | |
| 100 DISALLOW_COPY_AND_ASSIGN(MountPoints); | |
| 101 }; | |
| 102 | |
| 103 } // namespace fileapi | |
| 104 | |
| 105 #endif // WEBKIT_FILEAPI_MOUNT_POINTS_H_ | |
| 106 | |
| OLD | NEW |