Index: webkit/fileapi/file_system_url.h |
diff --git a/webkit/fileapi/file_system_url.h b/webkit/fileapi/file_system_url.h |
index 0d4bb6540ab1e4614bce6e59cbd5631285caa7d2..0245d94126f2e44cae57d6ee4abf4c7d37952c95 100644 |
--- a/webkit/fileapi/file_system_url.h |
+++ b/webkit/fileapi/file_system_url.h |
@@ -18,30 +18,49 @@ namespace fileapi { |
// A class representing a filesystem URL which consists of origin URL, |
// type and an internal path used inside the filesystem. |
// |
-// When a FileSystemURL instance is created for regular sandbox file systems |
+// When a FileSystemURL instance is created for a GURL (for filesystem: scheme), |
// each accessor method would return following values: |
// |
// Example: For a URL 'filesystem:http://foo.com/temporary/foo/bar': |
// origin() returns 'http://foo.com', |
// type() and mount_type() return kFileSystemTypeTemporary, |
-// path() and virtual_path() return 'foo/bar', and |
-// filesystem_id() returns an empty string. |
+// path() returns 'foo/bar', |
// |
-// path() and virtual_path() usually return the same value, but they |
-// have different values if an instance is created for Isolated or External |
-// FileSystem URL, for which we may mount different paths from its exposed |
-// virtual paths. |
+// All other accessors return empty or invalid value. |
+// |
+// FileSystemURL can also be created to represent a 'cracked' filesystem URL if |
+// the original URL's type/path is pointing to a mount point which can be |
+// further resolved to a lower filesystem type/path. |
// |
// Example: Assume a path '/media/removable' is mounted at mount name |
// 'mount_name' with type kFileSystemTypeFoo as an external file system. |
-// For a URL 'filesystem:http://bar.com/external/mount_name/foo/bar': |
+// |
+// The original URL would look like: |
+// 'filesystem:http://bar.com/external/mount_name/foo/bar': |
+// |
+// FileSystemURL('http://bar.com', |
+// kFileSystemTypeExternal, |
+// 'mount_name/foo/bar' |
+// 'mount_name', |
+// kFileSystemTypeFoo, |
+// '/media/removable/foo/bar'); |
+// would create a FileSystemURL whose accessors return: |
+// |
// origin() returns 'http://bar.com', |
// type() returns the kFileSystemTypeFoo, |
// path() returns '/media/removable/foo/bar', |
-// virtual_path() returns 'mount_name/foo/bar', |
+// |
+// Additionally, following accessors would return valid values: |
// filesystem_id() returns 'mount_name', and |
+// virtual_path() returns 'mount_name/foo/bar', |
// mount_type() returns kFileSystemTypeExternal. |
// |
+// It is imposible to directly create a valid FileSystemURL instance (except by |
+// using CreatedForTest methods, which should not be used in production code). |
+// To get a valid FileSystemURL, one of the following methods can be used: |
+// <Friend>::CrackURL, <Friend>::CreateCrackedFileSystemURL, where <Friend> is |
+// one of the friended classes. |
+// |
// TODO(ericu): Look into making path() [and all FileSystem API virtual |
// paths] just an std::string, to prevent platform-specific FilePath behavior |
// from getting invoked by accident. Currently the FilePath returned here needs |
@@ -51,12 +70,15 @@ namespace fileapi { |
class WEBKIT_STORAGE_EXPORT FileSystemURL { |
public: |
FileSystemURL(); |
- explicit FileSystemURL(const GURL& filesystem_url); |
- FileSystemURL(const GURL& origin, |
- FileSystemType type, |
- const FilePath& internal_path); |
~FileSystemURL(); |
+ // Methods for creating FileSystemURL without attempting to crack them. |
+ // Should be used only in tests. |
+ static FileSystemURL CreateForTest(const GURL& url); |
+ static FileSystemURL CreateForTest(const GURL& origin, |
+ FileSystemType type, |
+ const FilePath& path); |
+ |
// Returns true if this instance represents a valid FileSystem URL. |
bool is_valid() const { return is_valid_; } |
@@ -75,12 +97,10 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { |
// TODO(kinuko): this must return std::string. |
const FilePath& virtual_path() const { return virtual_path_; } |
- // Returns the filesystem ID/name for isolated/external file system URLs. |
+ // Returns the filesystem ID/mount name for isolated/external filesystem URLs. |
// See the class comment for details. |
const std::string& filesystem_id() const { return filesystem_id_; } |
- // Returns the public file system type of this URL. |
- // See the class comment for details. |
FileSystemType mount_type() const { return mount_type_; } |
std::string DebugString() const; |
@@ -89,9 +109,9 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { |
// This creates a new FileSystemURL, copies all fields of this instance |
// to that one, resets the path_ to the given |path| and resets the |
// virtual_path to *empty*. |
- // Note that the resulting FileSystemURL always has an empty virtual_path |
- // (as virtual_path is meant to represent the path that is given in the |
- // original filesystem: URL in the current implementation). |
+ // Note that the resulting FileSystemURL loses original URL information |
+ // if it was a cracked filesystem; i.e. virtual_path and mount_type will |
+ // be set to empty values. |
FileSystemURL WithPath(const FilePath& path) const; |
// Returns true if this URL is a strict parent of the |child|. |
@@ -104,18 +124,33 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { |
}; |
private: |
- void MayCrackIsolatedPath(); |
+ friend class FileSystemContext; |
+ friend class ExternalMountPoints; |
+ friend class IsolatedContext; |
+ |
+ explicit FileSystemURL(const GURL& filesystem_url); |
+ FileSystemURL(const GURL& origin, |
+ FileSystemType type, |
+ const FilePath& internal_path); |
+ // Creates a cracked FileSystemURL. |
+ FileSystemURL(const GURL& origin, |
+ FileSystemType original_type, |
+ const FilePath& original_path, |
+ const std::string& filesystem_id, |
+ FileSystemType cracked_type, |
+ const FilePath& cracked_path); |
+ |
+ bool is_valid_; |
GURL origin_; |
FileSystemType type_; |
+ FileSystemType mount_type_; |
FilePath path_; |
- // For isolated filesystem. |
+ // Values specific to cracked URLs. |
std::string filesystem_id_; |
FilePath virtual_path_; |
- FileSystemType mount_type_; |
- bool is_valid_; |
}; |
typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet; |