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_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/quota/quota_types.h" | 15 #include "webkit/quota/quota_types.h" |
16 #include "webkit/storage/webkit_storage_export.h" | 16 #include "webkit/storage/webkit_storage_export.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 | 19 |
20 namespace fileapi { | 20 namespace fileapi { |
21 | 21 |
22 extern const char kPersistentDir[]; | 22 extern const char kPersistentDir[]; |
23 extern const char kTemporaryDir[]; | 23 extern const char kTemporaryDir[]; |
24 extern const char kExternalDir[]; | 24 extern const char kExternalDir[]; |
25 extern const char kIsolatedDir[]; | 25 extern const char kIsolatedDir[]; |
26 extern const char kTestDir[]; | 26 extern const char kTestDir[]; |
27 | 27 |
28 class WEBKIT_STORAGE_EXPORT VirtualPath { | 28 class WEBKIT_STORAGE_EXPORT VirtualPath { |
29 public: | 29 public: |
30 // Use this instead of FilePath::BaseName when operating on virtual paths. | 30 // Use this instead of base::FilePath::BaseName when operating on virtual path
s. |
31 // FilePath::BaseName will get confused by ':' on Windows when it looks like a | 31 // base::FilePath::BaseName will get confused by ':' on Windows when it looks
like a |
32 // drive letter separator; this will treat it as just another character. | 32 // drive letter separator; this will treat it as just another character. |
33 static FilePath BaseName(const FilePath& virtual_path); | 33 static base::FilePath BaseName(const base::FilePath& virtual_path); |
34 | 34 |
35 // Likewise, use this instead of FilePath::GetComponents when operating on | 35 // Likewise, use this instead of base::FilePath::GetComponents when operating
on |
36 // virtual paths. | 36 // virtual paths. |
37 // Note that this assumes very clean input, with no leading slash, and it will | 37 // Note that this assumes very clean input, with no leading slash, and it will |
38 // not evaluate '.' or '..' components. | 38 // not evaluate '.' or '..' components. |
39 static void GetComponents(const FilePath& path, | 39 static void GetComponents(const base::FilePath& path, |
40 std::vector<FilePath::StringType>* components); | 40 std::vector<base::FilePath::StringType>* components); |
41 }; | 41 }; |
42 | 42 |
43 // Returns the root URI of the filesystem that can be specified by a pair of | 43 // Returns the root URI of the filesystem that can be specified by a pair of |
44 // |origin_url| and |type|. The returned URI can be used as a root path | 44 // |origin_url| and |type|. The returned URI can be used as a root path |
45 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose | 45 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose |
46 // a path pointing to the entry "/relative/path" in the filesystem). | 46 // a path pointing to the entry "/relative/path" in the filesystem). |
47 // | 47 // |
48 // For Isolated filesystem this returns the 'common' root part, e.g. | 48 // For Isolated filesystem this returns the 'common' root part, e.g. |
49 // returns URL without the filesystem ID. | 49 // returns URL without the filesystem ID. |
50 // | 50 // |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 WEBKIT_STORAGE_EXPORT std::string GetFileSystemTypeString(FileSystemType type); | 92 WEBKIT_STORAGE_EXPORT std::string GetFileSystemTypeString(FileSystemType type); |
93 | 93 |
94 // Encodes |file_path| to a string. | 94 // Encodes |file_path| to a string. |
95 // Following conditions should be held: | 95 // Following conditions should be held: |
96 // - StringToFilePath(FilePathToString(path)) == path | 96 // - StringToFilePath(FilePathToString(path)) == path |
97 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == | 97 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == |
98 // path.AppendASCII("SubDirectory"); | 98 // path.AppendASCII("SubDirectory"); |
99 // | 99 // |
100 // TODO(tzik): Replace CreateFilePath and FilePathToString in | 100 // TODO(tzik): Replace CreateFilePath and FilePathToString in |
101 // third_party/leveldatabase/env_chromium.cc with them. | 101 // third_party/leveldatabase/env_chromium.cc with them. |
102 WEBKIT_STORAGE_EXPORT std::string FilePathToString(const FilePath& file_path); | 102 WEBKIT_STORAGE_EXPORT std::string FilePathToString(const base::FilePath& file_pa
th); |
103 | 103 |
104 // Decode a file path from |file_path_string|. | 104 // Decode a file path from |file_path_string|. |
105 WEBKIT_STORAGE_EXPORT FilePath StringToFilePath( | 105 WEBKIT_STORAGE_EXPORT base::FilePath StringToFilePath( |
106 const std::string& file_path_string); | 106 const std::string& file_path_string); |
107 | 107 |
108 // File error conversion | 108 // File error conversion |
109 WEBKIT_STORAGE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError( | 109 WEBKIT_STORAGE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError( |
110 base::PlatformFileError error_code); | 110 base::PlatformFileError error_code); |
111 | 111 |
112 // Generate a file system name for the given arguments. Should only be used by | 112 // Generate a file system name for the given arguments. Should only be used by |
113 // platform apps. | 113 // platform apps. |
114 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemName( | 114 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemName( |
115 const GURL& origin_url, | 115 const GURL& origin_url, |
(...skipping 11 matching lines...) Expand all Loading... |
127 // and |filesystem_id|. If the |optional_root_name| is given the resulting | 127 // and |filesystem_id|. If the |optional_root_name| is given the resulting |
128 // root URI will point to the subfolder within the isolated filesystem. | 128 // root URI will point to the subfolder within the isolated filesystem. |
129 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( | 129 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( |
130 const GURL& origin_url, | 130 const GURL& origin_url, |
131 const std::string& filesystem_id, | 131 const std::string& filesystem_id, |
132 const std::string& optional_root_name); | 132 const std::string& optional_root_name); |
133 | 133 |
134 } // namespace fileapi | 134 } // namespace fileapi |
135 | 135 |
136 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 136 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |