OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MOUNT_POINTS_H_ | 5 #ifndef WEBKIT_FILEAPI_MOUNT_POINTS_H_ |
6 #define WEBKIT_FILEAPI_MOUNT_POINTS_H_ | 6 #define WEBKIT_FILEAPI_MOUNT_POINTS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "webkit/fileapi/file_system_util.h" | 13 #include "webkit/fileapi/file_system_util.h" |
14 #include "webkit/storage/webkit_storage_export.h" | 14 #include "webkit/storage/webkit_storage_export.h" |
15 | 15 |
16 class GURL; | 16 class GURL; |
17 | 17 |
18 namespace fileapi { | 18 namespace fileapi { |
| 19 class FileSystemURL; |
| 20 } |
| 21 |
| 22 namespace fileapi { |
19 | 23 |
20 // Represents a set of mount points for File API. | 24 // Represents a set of mount points for File API. |
21 class WEBKIT_STORAGE_EXPORT MountPoints { | 25 class WEBKIT_STORAGE_EXPORT MountPoints { |
22 public: | 26 public: |
23 struct WEBKIT_STORAGE_EXPORT MountPointInfo { | 27 struct WEBKIT_STORAGE_EXPORT MountPointInfo { |
24 MountPointInfo(); | 28 MountPointInfo(); |
25 MountPointInfo(const std::string& name, const FilePath& path); | 29 MountPointInfo(const std::string& name, const FilePath& path); |
26 | 30 |
27 // The name to be used to register the path. The registered file can | 31 // The name to be used to register the path. The registered file can |
28 // be referred by a virtual path /<filesystem_id>/<name>. | 32 // be referred by a virtual path /<filesystem_id>/<name>. |
(...skipping 10 matching lines...) Expand all Loading... |
39 }; | 43 }; |
40 | 44 |
41 MountPoints() {} | 45 MountPoints() {} |
42 virtual ~MountPoints() {} | 46 virtual ~MountPoints() {} |
43 | 47 |
44 // Revokes a mount point identified by |mount_name|. | 48 // Revokes a mount point identified by |mount_name|. |
45 // Returns false if the |mount_name| is not (no longer) registered. | 49 // Returns false if the |mount_name| is not (no longer) registered. |
46 // TODO(kinuko): Probably this should be rather named RevokeMountPoint. | 50 // TODO(kinuko): Probably this should be rather named RevokeMountPoint. |
47 virtual bool RevokeFileSystem(const std::string& mount_name) = 0; | 51 virtual bool RevokeFileSystem(const std::string& mount_name) = 0; |
48 | 52 |
| 53 // Returns true if the given url is valid and MountPoints implementation can |
| 54 // be used to crack FileSystemURLs with the url's type. |
| 55 virtual bool CanHandleURL(const FileSystemURL& url) const = 0; |
| 56 |
| 57 // Cracks a given FileSystemURL. |
| 58 // If the the URL is not valid or does not belong to any of the mount points |
| 59 // registered in this context, returns empty, invalid FileSystemURL. |
| 60 virtual FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const = 0; |
| 61 |
| 62 // Same as CrackFileSystemURL, but cracks FileSystemURL created from |url|. |
| 63 virtual FileSystemURL CrackURL(const GURL& url) const = 0; |
| 64 |
| 65 // Same as CrackFileSystemURL, but cracks FileSystemURL created from |
| 66 // method arguments. |
| 67 virtual FileSystemURL CreateCrackedFileSystemURL( |
| 68 const GURL& origin, |
| 69 fileapi::FileSystemType type, |
| 70 const FilePath& path) const = 0; |
| 71 |
49 // Returns the mount point root path registered for a given |mount_name|. | 72 // Returns the mount point root path registered for a given |mount_name|. |
50 // Returns false if the given |mount_name| is not valid. | 73 // Returns false if the given |mount_name| is not valid. |
51 virtual bool GetRegisteredPath(const std::string& mount_name, | 74 virtual bool GetRegisteredPath(const std::string& mount_name, |
52 FilePath* path) const = 0; | 75 FilePath* path) const = 0; |
53 | 76 |
54 // Cracks the given |virtual_path| (which is the path part of a filesystem URL | 77 // Cracks the given |virtual_path| (which is the path part of a filesystem URL |
55 // without '/external' or '/isolated' prefix part) and populates the | 78 // without '/external' or '/isolated' prefix part) and populates the |
56 // |mount_name|, |type|, and |path| if the <mount_name> part embedded in | 79 // |mount_name|, |type|, and |path| if the <mount_name> part embedded in |
57 // the |virtual_path| (i.e. the first component of the |virtual_path|) is a | 80 // the |virtual_path| (i.e. the first component of the |virtual_path|) is a |
58 // valid registered filesystem ID or mount name for an existing mount point. | 81 // valid registered filesystem ID or mount name for an existing mount point. |
59 // | 82 // |
60 // Returns false if the given virtual_path cannot be cracked. | 83 // Returns false if the given virtual_path cannot be cracked. |
61 // | 84 // |
62 // Note that |path| is set to empty paths if the filesystem type is isolated | 85 // Note that |path| is set to empty paths if the filesystem type is isolated |
63 // and |virtual_path| has no <relative_path> part (i.e. pointing to the | 86 // and |virtual_path| has no <relative_path> part (i.e. pointing to the |
64 // virtual root). | 87 // virtual root). |
65 virtual bool CrackVirtualPath(const FilePath& virtual_path, | 88 virtual bool CrackVirtualPath(const FilePath& virtual_path, |
66 std::string* mount_name, | 89 std::string* mount_name, |
67 FileSystemType* type, | 90 FileSystemType* type, |
68 FilePath* path) const = 0; | 91 FilePath* path) const = 0; |
69 | 92 |
70 private: | 93 private: |
71 DISALLOW_COPY_AND_ASSIGN(MountPoints); | 94 DISALLOW_COPY_AND_ASSIGN(MountPoints); |
72 }; | 95 }; |
73 | 96 |
74 } // namespace fileapi | 97 } // namespace fileapi |
75 | 98 |
76 #endif // WEBKIT_FILEAPI_MOUNT_POINTS_H_ | 99 #endif // WEBKIT_FILEAPI_MOUNT_POINTS_H_ |
77 | 100 |
OLD | NEW |