Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2326)

Unified Diff: webkit/fileapi/file_system_url.h

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_tests compile Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a76a0e8b9ff11180f9de2748c0f517a80d3b4166 100644
--- a/webkit/fileapi/file_system_url.h
+++ b/webkit/fileapi/file_system_url.h
@@ -18,29 +18,46 @@ 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.
+// type() and mount_type return kFileSystemTypeTemporary,
+// path() returns 'foo/bar',
+// is_cracked() returns false.
//
-// 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. This type of FileSystemURL
+// can only be created by a special static create method: CreateForCrackedURL.
+// It is advised not to use this method directly, but to crack URLs using
+// FileSystemContext::CrackURL/CrackFileSystemURL, or, in case it is clear which
+// MountPoints implementation contains target path, MountPoints::CrackURL.
//
// 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':
+//
+// CrateForCrackedURL(original_filesystem_url,
+// "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',
+// is_cracked() returns false.
+//
+// Additionally, following accessors would return valid values:
// filesystem_id() returns 'mount_name', and
-// mount_type() returns kFileSystemTypeExternal.
+// virtual_path() returns 'mount_name/foo/bar' (original url's path()),
+// mount_type() returns kFileSystemTypeExternal (original url's type()).
//
// TODO(ericu): Look into making path() [and all FileSystem API virtual
// paths] just an std::string, to prevent platform-specific FilePath behavior
@@ -51,15 +68,21 @@ 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_; }
+ // Returns true if this instance is created by CreateForCrackedURL.
+ bool is_cracked() const { return is_cracked_; }
+
// Returns the origin part of this URL. See the class comment for details.
const GURL& origin() const { return origin_; }
@@ -75,12 +98,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 +110,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 +125,40 @@ 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);
+ FileSystemURL(const GURL& original,
+ FileSystemType original_type,
+ const FilePath& original_path,
+ const std::string& filesystem_id,
+ FileSystemType cracked_type,
+ const FilePath& cracked_path);
+
+ // Creates a cracked URL. Generally, this method should not be used directly.
+ // See class comment for details.
+ static FileSystemURL CreateForCrackedURL(const FileSystemURL& original,
kinuko 2013/01/18 07:33:32 nit: indent
tbarzic 2013/01/18 21:33:15 Done. (jeez, Eclipse is killing me with its auto-
+ const std::string& filesystem_id,
+ FileSystemType cracked_type,
+ const FilePath& cracked_path);
+
+ bool is_valid_;
+ bool is_cracked_;
GURL origin_;
FileSystemType type_;
FilePath path_;
- // For isolated filesystem.
+ // Values specific to cracked URLs.
std::string filesystem_id_;
- FilePath virtual_path_;
FileSystemType mount_type_;
+ FilePath virtual_path_;
- bool is_valid_;
};
typedef std::set<FileSystemURL, FileSystemURL::Comparator> FileSystemURLSet;

Powered by Google App Engine
This is Rietveld 408576698