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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // virtual_path() returns 'mount_name/foo/bar', | 55 // virtual_path() returns 'mount_name/foo/bar', |
56 // mount_type() returns kFileSystemTypeExternal. | 56 // mount_type() returns kFileSystemTypeExternal. |
57 // | 57 // |
58 // It is imposible to directly create a valid FileSystemURL instance (except by | 58 // It is imposible to directly create a valid FileSystemURL instance (except by |
59 // using CreatedForTest methods, which should not be used in production code). | 59 // using CreatedForTest methods, which should not be used in production code). |
60 // To get a valid FileSystemURL, one of the following methods can be used: | 60 // To get a valid FileSystemURL, one of the following methods can be used: |
61 // <Friend>::CrackURL, <Friend>::CreateCrackedFileSystemURL, where <Friend> is | 61 // <Friend>::CrackURL, <Friend>::CreateCrackedFileSystemURL, where <Friend> is |
62 // one of the friended classes. | 62 // one of the friended classes. |
63 // | 63 // |
64 // TODO(ericu): Look into making path() [and all FileSystem API virtual | 64 // TODO(ericu): Look into making path() [and all FileSystem API virtual |
65 // paths] just an std::string, to prevent platform-specific FilePath behavior | 65 // paths] just an std::string, to prevent platform-specific base::FilePath behav
ior |
66 // from getting invoked by accident. Currently the FilePath returned here needs | 66 // from getting invoked by accident. Currently the base::FilePath returned here
needs |
67 // special treatment, as it may contain paths that are illegal on the current | 67 // special treatment, as it may contain paths that are illegal on the current |
68 // platform. To avoid problems, use VirtualPath::BaseName and | 68 // platform. To avoid problems, use VirtualPath::BaseName and |
69 // VirtualPath::GetComponents instead of the FilePath methods. | 69 // VirtualPath::GetComponents instead of the base::FilePath methods. |
70 class WEBKIT_STORAGE_EXPORT FileSystemURL { | 70 class WEBKIT_STORAGE_EXPORT FileSystemURL { |
71 public: | 71 public: |
72 FileSystemURL(); | 72 FileSystemURL(); |
73 ~FileSystemURL(); | 73 ~FileSystemURL(); |
74 | 74 |
75 // Methods for creating FileSystemURL without attempting to crack them. | 75 // Methods for creating FileSystemURL without attempting to crack them. |
76 // Should be used only in tests. | 76 // Should be used only in tests. |
77 static FileSystemURL CreateForTest(const GURL& url); | 77 static FileSystemURL CreateForTest(const GURL& url); |
78 static FileSystemURL CreateForTest(const GURL& origin, | 78 static FileSystemURL CreateForTest(const GURL& origin, |
79 FileSystemType type, | 79 FileSystemType type, |
80 const FilePath& path); | 80 const base::FilePath& path); |
81 | 81 |
82 // Returns true if this instance represents a valid FileSystem URL. | 82 // Returns true if this instance represents a valid FileSystem URL. |
83 bool is_valid() const { return is_valid_; } | 83 bool is_valid() const { return is_valid_; } |
84 | 84 |
85 // Returns the origin part of this URL. See the class comment for details. | 85 // Returns the origin part of this URL. See the class comment for details. |
86 const GURL& origin() const { return origin_; } | 86 const GURL& origin() const { return origin_; } |
87 | 87 |
88 // Returns the type part of this URL. See the class comment for details. | 88 // Returns the type part of this URL. See the class comment for details. |
89 FileSystemType type() const { return type_; } | 89 FileSystemType type() const { return type_; } |
90 | 90 |
91 // Returns the path part of this URL. See the class comment for details. | 91 // Returns the path part of this URL. See the class comment for details. |
92 // TODO(kinuko): this must return std::string. | 92 // TODO(kinuko): this must return std::string. |
93 const FilePath& path() const { return path_; } | 93 const base::FilePath& path() const { return path_; } |
94 | 94 |
95 // Returns the original path part of this URL. | 95 // Returns the original path part of this URL. |
96 // See the class comment for details. | 96 // See the class comment for details. |
97 // TODO(kinuko): this must return std::string. | 97 // TODO(kinuko): this must return std::string. |
98 const FilePath& virtual_path() const { return virtual_path_; } | 98 const base::FilePath& virtual_path() const { return virtual_path_; } |
99 | 99 |
100 // Returns the filesystem ID/mount name for isolated/external filesystem URLs. | 100 // Returns the filesystem ID/mount name for isolated/external filesystem URLs. |
101 // See the class comment for details. | 101 // See the class comment for details. |
102 const std::string& filesystem_id() const { return filesystem_id_; } | 102 const std::string& filesystem_id() const { return filesystem_id_; } |
103 | 103 |
104 FileSystemType mount_type() const { return mount_type_; } | 104 FileSystemType mount_type() const { return mount_type_; } |
105 | 105 |
106 std::string DebugString() const; | 106 std::string DebugString() const; |
107 | 107 |
108 // Returns a new FileSystemURL with the given path. | 108 // Returns a new FileSystemURL with the given path. |
109 // This creates a new FileSystemURL, copies all fields of this instance | 109 // This creates a new FileSystemURL, copies all fields of this instance |
110 // to that one, resets the path_ to the given |path| and resets the | 110 // to that one, resets the path_ to the given |path| and resets the |
111 // virtual_path to *empty*. | 111 // virtual_path to *empty*. |
112 // Note that the resulting FileSystemURL loses original URL information | 112 // Note that the resulting FileSystemURL loses original URL information |
113 // if it was a cracked filesystem; i.e. virtual_path and mount_type will | 113 // if it was a cracked filesystem; i.e. virtual_path and mount_type will |
114 // be set to empty values. | 114 // be set to empty values. |
115 FileSystemURL WithPath(const FilePath& path) const; | 115 FileSystemURL WithPath(const base::FilePath& path) const; |
116 | 116 |
117 // Returns true if this URL is a strict parent of the |child|. | 117 // Returns true if this URL is a strict parent of the |child|. |
118 bool IsParent(const FileSystemURL& child) const; | 118 bool IsParent(const FileSystemURL& child) const; |
119 | 119 |
120 bool operator==(const FileSystemURL& that) const; | 120 bool operator==(const FileSystemURL& that) const; |
121 | 121 |
122 struct WEBKIT_STORAGE_EXPORT Comparator { | 122 struct WEBKIT_STORAGE_EXPORT Comparator { |
123 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; | 123 bool operator() (const FileSystemURL& lhs, const FileSystemURL& rhs) const; |
124 }; | 124 }; |
125 | 125 |
126 private: | 126 private: |
127 friend class FileSystemContext; | 127 friend class FileSystemContext; |
128 friend class ExternalMountPoints; | 128 friend class ExternalMountPoints; |
129 friend class IsolatedContext; | 129 friend class IsolatedContext; |
130 | 130 |
131 explicit FileSystemURL(const GURL& filesystem_url); | 131 explicit FileSystemURL(const GURL& filesystem_url); |
132 FileSystemURL(const GURL& origin, | 132 FileSystemURL(const GURL& origin, |
133 FileSystemType type, | 133 FileSystemType type, |
134 const FilePath& internal_path); | 134 const base::FilePath& internal_path); |
135 // Creates a cracked FileSystemURL. | 135 // Creates a cracked FileSystemURL. |
136 FileSystemURL(const GURL& origin, | 136 FileSystemURL(const GURL& origin, |
137 FileSystemType original_type, | 137 FileSystemType original_type, |
138 const FilePath& original_path, | 138 const base::FilePath& original_path, |
139 const std::string& filesystem_id, | 139 const std::string& filesystem_id, |
140 FileSystemType cracked_type, | 140 FileSystemType cracked_type, |
141 const FilePath& cracked_path); | 141 const base::FilePath& cracked_path); |
142 | 142 |
143 bool is_valid_; | 143 bool is_valid_; |
144 | 144 |
145 GURL origin_; | 145 GURL origin_; |
146 FileSystemType type_; | 146 FileSystemType type_; |
147 FileSystemType mount_type_; | 147 FileSystemType mount_type_; |
148 FilePath path_; | 148 base::FilePath path_; |
149 | 149 |
150 // Values specific to cracked URLs. | 150 // Values specific to cracked URLs. |
151 std::string filesystem_id_; | 151 std::string filesystem_id_; |
152 FilePath virtual_path_; | 152 base::FilePath virtual_path_; |
153 | 153 |
154 }; | 154 }; |
155 | 155 |
156 typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet; | 156 typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet; |
157 | 157 |
158 } // namespace fileapi | 158 } // namespace fileapi |
159 | 159 |
160 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ | 160 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_ |
OLD | NEW |