| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "webkit/fileapi/file_system_types.h" | 12 #include "webkit/fileapi/file_system_types.h" |
| 13 #include "webkit/fileapi/fileapi_export.h" | 13 #include "webkit/storage/webkit_storage_export.h" |
| 14 | 14 |
| 15 namespace fileapi { | 15 namespace fileapi { |
| 16 | 16 |
| 17 // A class representing a filesystem URL which consists of origin URL, | 17 // A class representing a filesystem URL which consists of origin URL, |
| 18 // type and an internal path used inside the filesystem. | 18 // type and an internal path used inside the filesystem. |
| 19 // | 19 // |
| 20 // When a FileSystemURL instance is created for regular sandbox file systems | 20 // When a FileSystemURL instance is created for regular sandbox file systems |
| 21 // each accessor method would return following values: | 21 // each accessor method would return following values: |
| 22 // | 22 // |
| 23 // Example: For a URL 'filesystem:http://foo.com/temporary/foo/bar': | 23 // Example: For a URL 'filesystem:http://foo.com/temporary/foo/bar': |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 // virtual_path() returns 'mount_name/foo/bar', | 40 // virtual_path() returns 'mount_name/foo/bar', |
| 41 // filesystem_id() returns 'mount_name', and | 41 // filesystem_id() returns 'mount_name', and |
| 42 // mount_type() returns kFileSystemTypeExternal. | 42 // mount_type() returns kFileSystemTypeExternal. |
| 43 // | 43 // |
| 44 // TODO(ericu): Look into making path() [and all FileSystem API virtual | 44 // TODO(ericu): Look into making path() [and all FileSystem API virtual |
| 45 // paths] just an std::string, to prevent platform-specific FilePath behavior | 45 // paths] just an std::string, to prevent platform-specific FilePath behavior |
| 46 // from getting invoked by accident. Currently the FilePath returned here needs | 46 // from getting invoked by accident. Currently the FilePath returned here needs |
| 47 // special treatment, as it may contain paths that are illegal on the current | 47 // special treatment, as it may contain paths that are illegal on the current |
| 48 // platform. To avoid problems, use VirtualPath::BaseName and | 48 // platform. To avoid problems, use VirtualPath::BaseName and |
| 49 // VirtualPath::GetComponents instead of the FilePath methods. | 49 // VirtualPath::GetComponents instead of the FilePath methods. |
| 50 class FILEAPI_EXPORT FileSystemURL { | 50 class WEBKIT_STORAGE_EXPORT FileSystemURL { |
| 51 public: | 51 public: |
| 52 FileSystemURL(); | 52 FileSystemURL(); |
| 53 explicit FileSystemURL(const GURL& filesystem_url); | 53 explicit FileSystemURL(const GURL& filesystem_url); |
| 54 FileSystemURL(const GURL& origin, | 54 FileSystemURL(const GURL& origin, |
| 55 FileSystemType type, | 55 FileSystemType type, |
| 56 const FilePath& internal_path); | 56 const FilePath& internal_path); |
| 57 ~FileSystemURL(); | 57 ~FileSystemURL(); |
| 58 | 58 |
| 59 // Returns true if this instance represents a valid FileSystem URL. | 59 // Returns true if this instance represents a valid FileSystem URL. |
| 60 bool is_valid() const { return is_valid_; } | 60 bool is_valid() const { return is_valid_; } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 // Note that the resulting FileSystemURL always has an empty virtual_path | 91 // Note that the resulting FileSystemURL always has an empty virtual_path |
| 92 // (as virtual_path is meant to represent the path that is given in the | 92 // (as virtual_path is meant to represent the path that is given in the |
| 93 // original filesystem: URL in the current implementation). | 93 // original filesystem: URL in the current implementation). |
| 94 FileSystemURL WithPath(const FilePath& path) const; | 94 FileSystemURL WithPath(const FilePath& path) const; |
| 95 | 95 |
| 96 // Returns true if this URL is a strict parent of the |child|. | 96 // Returns true if this URL is a strict parent of the |child|. |
| 97 bool IsParent(const FileSystemURL& child) const; | 97 bool IsParent(const FileSystemURL& child) const; |
| 98 | 98 |
| 99 bool operator==(const FileSystemURL& that) const; | 99 bool operator==(const FileSystemURL& that) const; |
| 100 | 100 |
| 101 struct FILEAPI_EXPORT Comparator { | 101 struct WEBKIT_STORAGE_EXPORT Comparator { |
| 102 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; | 102 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 void MayCrackIsolatedPath(); | 106 void MayCrackIsolatedPath(); |
| 107 | 107 |
| 108 GURL origin_; | 108 GURL origin_; |
| 109 FileSystemType type_; | 109 FileSystemType type_; |
| 110 FilePath path_; | 110 FilePath path_; |
| 111 | 111 |
| 112 // For isolated filesystem. | 112 // For isolated filesystem. |
| 113 std::string filesystem_id_; | 113 std::string filesystem_id_; |
| 114 FilePath virtual_path_; | 114 FilePath virtual_path_; |
| 115 FileSystemType mount_type_; | 115 FileSystemType mount_type_; |
| 116 | 116 |
| 117 bool is_valid_; | 117 bool is_valid_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace fileapi | 120 } // namespace fileapi |
| 121 | 121 |
| 122 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ | 122 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ |
| OLD | NEW |