| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 5 #ifndef WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| 6 #define WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 6 #define WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 virtual bool CrackVirtualPath(const base::FilePath& virtual_path, | 79 virtual bool CrackVirtualPath(const base::FilePath& virtual_path, |
| 80 std::string* mount_name, | 80 std::string* mount_name, |
| 81 FileSystemType* type, | 81 FileSystemType* type, |
| 82 base::FilePath* path) const OVERRIDE; | 82 base::FilePath* path) const OVERRIDE; |
| 83 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE; | 83 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE; |
| 84 virtual FileSystemURL CreateCrackedFileSystemURL( | 84 virtual FileSystemURL CreateCrackedFileSystemURL( |
| 85 const GURL& origin, | 85 const GURL& origin, |
| 86 FileSystemType type, | 86 FileSystemType type, |
| 87 const base::FilePath& path) const OVERRIDE; | 87 const base::FilePath& path) const OVERRIDE; |
| 88 | 88 |
| 89 // Retrieves the remote file system proxy for the registered file system. | 89 // Retrieves the remote file system proxy for a path on a registered file |
| 90 // Returns NULL if there is no file system with the given name, or if the file | 90 // system. |
| 91 // system does not have a remote file system proxy. | 91 // Returns NULL if there is no file system for the path, or if the file system |
| 92 RemoteFileSystemProxyInterface* GetRemoteFileSystemProxy( | 92 // does not have a remote file system proxy. |
| 93 const std::string& mount_name) const; | 93 RemoteFileSystemProxyInterface* GetRemoteFileSystemProxyForPath( |
| 94 const base::FilePath& full_path) const; |
| 94 | 95 |
| 95 // Returns a list of registered MountPointInfos (of <mount_name, path>). | 96 // Returns a list of registered MountPointInfos (of <mount_name, path>). |
| 96 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const; | 97 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const; |
| 97 | 98 |
| 98 // Converts a path on a registered file system to virtual path relative to the | 99 // Converts a path on a registered file system to virtual path relative to the |
| 99 // file system root. E.g. if 'Downloads' file system is mapped to | 100 // file system root. E.g. if 'Downloads' file system is mapped to |
| 100 // '/usr/local/home/Downloads', and |absolute| path is set to | 101 // '/usr/local/home/Downloads', and |absolute| path is set to |
| 101 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to | 102 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to |
| 102 // 'Downloads/foo'. | 103 // 'Downloads/foo'. |
| 103 // Returns false if the path cannot be resolved (e.g. if the path is not | 104 // Returns false if the path cannot be resolved (e.g. if the path is not |
| (...skipping 25 matching lines...) Expand all Loading... |
| 129 // Checks the following: | 130 // Checks the following: |
| 130 // - there is no registered mount point with mount_name | 131 // - there is no registered mount point with mount_name |
| 131 // - path does not contain a reference to a parent | 132 // - path does not contain a reference to a parent |
| 132 // - path is absolute | 133 // - path is absolute |
| 133 // - path does not overlap with an existing mount point path. | 134 // - path does not overlap with an existing mount point path. |
| 134 // | 135 // |
| 135 // |lock_| should be taken before calling this method. | 136 // |lock_| should be taken before calling this method. |
| 136 bool ValidateNewMountPoint(const std::string& mount_name, | 137 bool ValidateNewMountPoint(const std::string& mount_name, |
| 137 const base::FilePath& path); | 138 const base::FilePath& path); |
| 138 | 139 |
| 140 // Sets |mount_point_name| and |mount_point_root| to the name and root path of |
| 141 // the mount point that |path| belongs to. |mount_point_root| may be NULL in |
| 142 // which case it is ignored. |
| 143 // If the path doesn't belong to any of the mount points, both |
| 144 // |mount_point_name| and |mount_point_root| are not changed. |
| 145 // Returns whether the mount point could be found. |
| 146 bool GetMountPointForPath(const base::FilePath& path, |
| 147 std::string* mount_point_name, |
| 148 base::FilePath* mount_point_root) const; |
| 149 |
| 139 // This lock needs to be obtained when accessing the instance_map_. | 150 // This lock needs to be obtained when accessing the instance_map_. |
| 140 mutable base::Lock lock_; | 151 mutable base::Lock lock_; |
| 141 | 152 |
| 142 NameToInstance instance_map_; | 153 NameToInstance instance_map_; |
| 143 PathToName path_to_name_map_; | 154 PathToName path_to_name_map_; |
| 144 | 155 |
| 145 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints); | 156 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints); |
| 146 }; | 157 }; |
| 147 | 158 |
| 148 // Registers a scoped external filesystem which gets revoked when it scopes out. | 159 // Registers a scoped external filesystem which gets revoked when it scopes out. |
| 149 class WEBKIT_STORAGE_EXPORT ScopedExternalFileSystem { | 160 class WEBKIT_STORAGE_EXPORT ScopedExternalFileSystem { |
| 150 public: | 161 public: |
| 151 ScopedExternalFileSystem(const std::string& mount_name, | 162 ScopedExternalFileSystem(const std::string& mount_name, |
| 152 FileSystemType type, | 163 FileSystemType type, |
| 153 const base::FilePath& path); | 164 const base::FilePath& path); |
| 154 ~ScopedExternalFileSystem(); | 165 ~ScopedExternalFileSystem(); |
| 155 | 166 |
| 156 base::FilePath GetVirtualRootPath() const; | 167 base::FilePath GetVirtualRootPath() const; |
| 157 | 168 |
| 158 private: | 169 private: |
| 159 const std::string mount_name_; | 170 const std::string mount_name_; |
| 160 }; | 171 }; |
| 161 | 172 |
| 162 } // namespace fileapi | 173 } // namespace fileapi |
| 163 | 174 |
| 164 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 175 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| 165 | 176 |
| OLD | NEW |