Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FILE_SYSTEM_URL_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // type() returns the kFileSystemTypeFoo, | 52 // type() returns the kFileSystemTypeFoo, |
| 53 // path() returns '/media/removable/foo/bar', | 53 // path() returns '/media/removable/foo/bar', |
| 54 // virtual_path() returns 'mount_name/foo/bar', | 54 // virtual_path() returns 'mount_name/foo/bar', |
| 55 // mount_type() returns kFileSystemTypeExternal. | 55 // mount_type() returns kFileSystemTypeExternal. |
| 56 // | 56 // |
| 57 // Note that in either case virtual_path() always returns the path part after | 57 // Note that in either case virtual_path() always returns the path part after |
| 58 // 'type' part in the original URL, and mount_type() always returns the 'type' | 58 // 'type' part in the original URL, and mount_type() always returns the 'type' |
| 59 // part in the original URL. | 59 // part in the original URL. |
| 60 // | 60 // |
| 61 // Additionally, following accessors would return valid values: | 61 // Additionally, following accessors would return valid values: |
| 62 // filesystem_id() returns 'mount_name'. | 62 // filesystem_id() returns 'mount_name'. |
|
kinuko
2013/03/21 16:47:51
can you add a brief explanation about mount_filesy
kinaba
2013/03/22 04:58:33
Done.
| |
| 63 // | 63 // |
| 64 // It is imposible to directly create a valid FileSystemURL instance (except by | 64 // It is impossible to directly create a valid FileSystemURL instance (except by |
| 65 // using CreatedForTest methods, which should not be used in production code). | 65 // using CreatedForTest methods, which should not be used in production code). |
| 66 // To get a valid FileSystemURL, one of the following methods can be used: | 66 // To get a valid FileSystemURL, one of the following methods can be used: |
| 67 // <Friend>::CrackURL, <Friend>::CreateCrackedFileSystemURL, where <Friend> is | 67 // <Friend>::CrackURL, <Friend>::CreateCrackedFileSystemURL, where <Friend> is |
| 68 // one of the friended classes. | 68 // one of the friended classes. |
| 69 // | 69 // |
| 70 // TODO(ericu): Look into making path() [and all FileSystem API virtual | 70 // TODO(ericu): Look into making path() [and all FileSystem API virtual |
| 71 // paths] just an std::string, to prevent platform-specific base::FilePath behav ior | 71 // paths] just an std::string, to prevent platform-specific base::FilePath behav ior |
| 72 // from getting invoked by accident. Currently the base::FilePath returned here needs | 72 // from getting invoked by accident. Currently the base::FilePath returned here needs |
| 73 // special treatment, as it may contain paths that are illegal on the current | 73 // special treatment, as it may contain paths that are illegal on the current |
| 74 // platform. To avoid problems, use VirtualPath::BaseName and | 74 // platform. To avoid problems, use VirtualPath::BaseName and |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 105 const base::FilePath& path() const { return path_; } | 105 const base::FilePath& path() const { return path_; } |
| 106 | 106 |
| 107 // Returns the original path part of this URL. | 107 // Returns the original path part of this URL. |
| 108 // See the class comment for details. | 108 // See the class comment for details. |
| 109 // TODO(kinuko): this must return std::string. | 109 // TODO(kinuko): this must return std::string. |
| 110 const base::FilePath& virtual_path() const { return virtual_path_; } | 110 const base::FilePath& virtual_path() const { return virtual_path_; } |
| 111 | 111 |
| 112 // Returns the filesystem ID/mount name for isolated/external filesystem URLs. | 112 // Returns the filesystem ID/mount name for isolated/external filesystem URLs. |
| 113 // See the class comment for details. | 113 // See the class comment for details. |
| 114 const std::string& filesystem_id() const { return filesystem_id_; } | 114 const std::string& filesystem_id() const { return filesystem_id_; } |
| 115 const std::string& mount_filesystem_id() const { | |
| 116 return mount_filesystem_id_; | |
| 117 } | |
| 115 | 118 |
| 116 FileSystemType mount_type() const { return mount_type_; } | 119 FileSystemType mount_type() const { return mount_type_; } |
| 117 | 120 |
| 118 std::string DebugString() const; | 121 std::string DebugString() const; |
| 119 | 122 |
| 120 // Returns true if this URL is a strict parent of the |child|. | 123 // Returns true if this URL is a strict parent of the |child|. |
| 121 bool IsParent(const FileSystemURL& child) const; | 124 bool IsParent(const FileSystemURL& child) const; |
| 122 | 125 |
| 123 bool operator==(const FileSystemURL& that) const; | 126 bool operator==(const FileSystemURL& that) const; |
| 124 | 127 |
| 125 struct WEBKIT_STORAGE_EXPORT Comparator { | 128 struct WEBKIT_STORAGE_EXPORT Comparator { |
| 126 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; | 129 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 private: | 132 private: |
| 130 friend class FileSystemContext; | 133 friend class FileSystemContext; |
| 131 friend class ExternalMountPoints; | 134 friend class ExternalMountPoints; |
| 132 friend class IsolatedContext; | 135 friend class IsolatedContext; |
| 133 | 136 |
| 134 explicit FileSystemURL(const GURL& filesystem_url); | 137 explicit FileSystemURL(const GURL& filesystem_url); |
| 135 FileSystemURL(const GURL& origin, | 138 FileSystemURL(const GURL& origin, |
| 136 FileSystemType mount_type, | 139 FileSystemType mount_type, |
| 137 const base::FilePath& virtual_path); | 140 const base::FilePath& virtual_path); |
| 138 // Creates a cracked FileSystemURL. | 141 // Creates a cracked FileSystemURL. |
| 139 FileSystemURL(const GURL& origin, | 142 FileSystemURL(const GURL& origin, |
| 140 FileSystemType mount_type, | 143 FileSystemType mount_type, |
| 141 const base::FilePath& virtual_path, | 144 const base::FilePath& virtual_path, |
| 142 const std::string& filesystem_id, | 145 const std::string& mount_filesystem_id, |
| 143 FileSystemType cracked_type, | 146 FileSystemType cracked_type, |
| 144 const base::FilePath& cracked_path); | 147 const base::FilePath& cracked_path, |
| 148 const std::string& filesystem_id); | |
| 145 | 149 |
| 146 bool is_valid_; | 150 bool is_valid_; |
| 147 | 151 |
| 152 // Values parsed from the original URL. | |
| 148 GURL origin_; | 153 GURL origin_; |
| 149 FileSystemType type_; | |
| 150 FileSystemType mount_type_; | 154 FileSystemType mount_type_; |
| 151 base::FilePath path_; | |
| 152 | |
| 153 // Values specific to cracked URLs. | |
| 154 std::string filesystem_id_; | |
| 155 base::FilePath virtual_path_; | 155 base::FilePath virtual_path_; |
| 156 | 156 |
| 157 // Values obtained by cracking URLs. | |
| 158 std::string mount_filesystem_id_; | |
| 159 FileSystemType type_; | |
| 160 base::FilePath path_; | |
| 161 std::string filesystem_id_; | |
| 157 }; | 162 }; |
| 158 | 163 |
| 159 typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet; | 164 typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet; |
| 160 | 165 |
| 161 } // namespace fileapi | 166 } // namespace fileapi |
| 162 | 167 |
| 163 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ | 168 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ |
| OLD | NEW |