| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Converts a path on a registered file system to virtual path relative to the | 98 // 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 | 99 // file system root. E.g. if 'Downloads' file system is mapped to |
| 100 // '/usr/local/home/Downloads', and |absolute| path is set to | 100 // '/usr/local/home/Downloads', and |absolute| path is set to |
| 101 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to | 101 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to |
| 102 // 'Downloads/foo'. | 102 // 'Downloads/foo'. |
| 103 // Returns false if the path cannot be resolved (e.g. if the path is not | 103 // Returns false if the path cannot be resolved (e.g. if the path is not |
| 104 // part of any registered filesystem). | 104 // part of any registered filesystem). |
| 105 // | 105 // |
| 106 // Returned virtual_path will have normalized path separators. | 106 // Returned virtual_path will have normalized path separators. |
| 107 bool GetVirtualPath(const base::FilePath& absolute_path, | 107 bool GetVirtualPath(const base::FilePath& absolute_path, |
| 108 base::FilePath* virtual_path); | 108 base::FilePath* virtual_path) const; |
| 109 | 109 |
| 110 // Returns the virtual root path that looks like /<mount_name>. | 110 // Returns the virtual root path that looks like /<mount_name>. |
| 111 base::FilePath CreateVirtualRootPath(const std::string& mount_name) const; | 111 base::FilePath CreateVirtualRootPath(const std::string& mount_name) const; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 friend class base::RefCountedThreadSafe<ExternalMountPoints>; | 114 friend class base::RefCountedThreadSafe<ExternalMountPoints>; |
| 115 | 115 |
| 116 // Represents each file system instance (defined in the .cc). | 116 // Represents each file system instance (defined in the .cc). |
| 117 class Instance; | 117 class Instance; |
| 118 | 118 |
| 119 typedef std::map<std::string, Instance*> NameToInstance; | 119 typedef std::map<std::string, Instance*> NameToInstance; |
| 120 | 120 |
| 121 // Reverse map from registered path to its corresponding mount name. | 121 // Reverse map from registered path to its corresponding mount name. |
| 122 typedef std::map<base::FilePath, std::string> PathToName; | 122 typedef std::map<base::FilePath, std::string> PathToName; |
| 123 | 123 |
| 124 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance. | 124 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance. |
| 125 ExternalMountPoints(); | 125 ExternalMountPoints(); |
| 126 virtual ~ExternalMountPoints(); | 126 virtual ~ExternalMountPoints(); |
| 127 | 127 |
| 128 // MountPoint overrides. |
| 129 virtual FileSystemURL CrackFileSystemURL( |
| 130 const FileSystemURL& url) const OVERRIDE; |
| 131 |
| 128 // Performs sanity checks on the new mount point. | 132 // Performs sanity checks on the new mount point. |
| 129 // Checks the following: | 133 // Checks the following: |
| 130 // - there is no registered mount point with mount_name | 134 // - there is no registered mount point with mount_name |
| 131 // - path does not contain a reference to a parent | 135 // - path does not contain a reference to a parent |
| 132 // - path is absolute | 136 // - path is absolute |
| 133 // - path does not overlap with an existing mount point path. | 137 // - path does not overlap with an existing mount point path. |
| 134 // | 138 // |
| 135 // |lock_| should be taken before calling this method. | 139 // |lock_| should be taken before calling this method. |
| 136 bool ValidateNewMountPoint(const std::string& mount_name, | 140 bool ValidateNewMountPoint(const std::string& mount_name, |
| 137 const base::FilePath& path); | 141 const base::FilePath& path); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 156 base::FilePath GetVirtualRootPath() const; | 160 base::FilePath GetVirtualRootPath() const; |
| 157 | 161 |
| 158 private: | 162 private: |
| 159 const std::string mount_name_; | 163 const std::string mount_name_; |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 } // namespace fileapi | 166 } // namespace fileapi |
| 163 | 167 |
| 164 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ | 168 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ |
| 165 | 169 |
| OLD | NEW |