| 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 STORAGE_BROWSER_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| 6 #define STORAGE_BROWSER_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 6 #define STORAGE_BROWSER_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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // empty, but |GetVirtualPath| will not work for those mount points. | 58 // empty, but |GetVirtualPath| will not work for those mount points. |
| 59 // | 59 // |
| 60 // An external file system registered by this method can be revoked | 60 // An external file system registered by this method can be revoked |
| 61 // by calling RevokeFileSystem with |mount_name|. | 61 // by calling RevokeFileSystem with |mount_name|. |
| 62 bool RegisterFileSystem(const std::string& mount_name, | 62 bool RegisterFileSystem(const std::string& mount_name, |
| 63 FileSystemType type, | 63 FileSystemType type, |
| 64 const FileSystemMountOption& mount_option, | 64 const FileSystemMountOption& mount_option, |
| 65 const base::FilePath& path); | 65 const base::FilePath& path); |
| 66 | 66 |
| 67 // MountPoints overrides. | 67 // MountPoints overrides. |
| 68 virtual bool HandlesFileSystemMountType(FileSystemType type) const OVERRIDE; | 68 virtual bool HandlesFileSystemMountType(FileSystemType type) const override; |
| 69 virtual bool RevokeFileSystem(const std::string& mount_name) OVERRIDE; | 69 virtual bool RevokeFileSystem(const std::string& mount_name) override; |
| 70 virtual bool GetRegisteredPath(const std::string& mount_name, | 70 virtual bool GetRegisteredPath(const std::string& mount_name, |
| 71 base::FilePath* path) const OVERRIDE; | 71 base::FilePath* path) const override; |
| 72 virtual bool CrackVirtualPath( | 72 virtual bool CrackVirtualPath( |
| 73 const base::FilePath& virtual_path, | 73 const base::FilePath& virtual_path, |
| 74 std::string* mount_name, | 74 std::string* mount_name, |
| 75 FileSystemType* type, | 75 FileSystemType* type, |
| 76 std::string* cracked_id, | 76 std::string* cracked_id, |
| 77 base::FilePath* path, | 77 base::FilePath* path, |
| 78 FileSystemMountOption* mount_option) const OVERRIDE; | 78 FileSystemMountOption* mount_option) const override; |
| 79 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE; | 79 virtual FileSystemURL CrackURL(const GURL& url) const override; |
| 80 virtual FileSystemURL CreateCrackedFileSystemURL( | 80 virtual FileSystemURL CreateCrackedFileSystemURL( |
| 81 const GURL& origin, | 81 const GURL& origin, |
| 82 FileSystemType type, | 82 FileSystemType type, |
| 83 const base::FilePath& path) const OVERRIDE; | 83 const base::FilePath& path) const override; |
| 84 | 84 |
| 85 // Returns a list of registered MountPointInfos (of <mount_name, path>). | 85 // Returns a list of registered MountPointInfos (of <mount_name, path>). |
| 86 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const; | 86 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const; |
| 87 | 87 |
| 88 // Converts a path on a registered file system to virtual path relative to the | 88 // Converts a path on a registered file system to virtual path relative to the |
| 89 // file system root. E.g. if 'Downloads' file system is mapped to | 89 // file system root. E.g. if 'Downloads' file system is mapped to |
| 90 // '/usr/local/home/Downloads', and |absolute| path is set to | 90 // '/usr/local/home/Downloads', and |absolute| path is set to |
| 91 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to | 91 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to |
| 92 // 'Downloads/foo'. | 92 // 'Downloads/foo'. |
| 93 // Returns false if the path cannot be resolved (e.g. if the path is not | 93 // Returns false if the path cannot be resolved (e.g. if the path is not |
| (...skipping 29 matching lines...) Expand all Loading... |
| 123 | 123 |
| 124 // Reverse map from registered path to its corresponding mount name. | 124 // Reverse map from registered path to its corresponding mount name. |
| 125 typedef std::map<base::FilePath, std::string> PathToName; | 125 typedef std::map<base::FilePath, std::string> PathToName; |
| 126 | 126 |
| 127 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance. | 127 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance. |
| 128 ExternalMountPoints(); | 128 ExternalMountPoints(); |
| 129 virtual ~ExternalMountPoints(); | 129 virtual ~ExternalMountPoints(); |
| 130 | 130 |
| 131 // MountPoint overrides. | 131 // MountPoint overrides. |
| 132 virtual FileSystemURL CrackFileSystemURL( | 132 virtual FileSystemURL CrackFileSystemURL( |
| 133 const FileSystemURL& url) const OVERRIDE; | 133 const FileSystemURL& url) const override; |
| 134 | 134 |
| 135 // Performs sanity checks on the new mount point. | 135 // Performs sanity checks on the new mount point. |
| 136 // Checks the following: | 136 // Checks the following: |
| 137 // - there is no registered mount point with mount_name | 137 // - there is no registered mount point with mount_name |
| 138 // - path does not contain a reference to a parent | 138 // - path does not contain a reference to a parent |
| 139 // - path is absolute | 139 // - path is absolute |
| 140 // - path does not overlap with an existing mount point path unless it is a | 140 // - path does not overlap with an existing mount point path unless it is a |
| 141 // media gallery type. | 141 // media gallery type. |
| 142 // | 142 // |
| 143 // |lock_| should be taken before calling this method. | 143 // |lock_| should be taken before calling this method. |
| 144 bool ValidateNewMountPoint(const std::string& mount_name, | 144 bool ValidateNewMountPoint(const std::string& mount_name, |
| 145 FileSystemType type, | 145 FileSystemType type, |
| 146 const base::FilePath& path); | 146 const base::FilePath& path); |
| 147 | 147 |
| 148 // This lock needs to be obtained when accessing the instance_map_. | 148 // This lock needs to be obtained when accessing the instance_map_. |
| 149 mutable base::Lock lock_; | 149 mutable base::Lock lock_; |
| 150 | 150 |
| 151 NameToInstance instance_map_; | 151 NameToInstance instance_map_; |
| 152 PathToName path_to_name_map_; | 152 PathToName path_to_name_map_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints); | 154 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace storage | 157 } // namespace storage |
| 158 | 158 |
| 159 #endif // STORAGE_BROWSER_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 159 #endif // STORAGE_BROWSER_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| OLD | NEW |