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

Side by Side Diff: webkit/common/fileapi/file_system_util.h

Issue 15716007: Split webkit_storage target into webkit_storage_{browser,common,renderer} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: char* -> char[] Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ 5 #ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_
6 #define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ 6 #define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "third_party/WebKit/public/platform/WebFileSystemType.h" 13 #include "third_party/WebKit/public/platform/WebFileSystemType.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h"
15 #include "webkit/common/fileapi/file_system_types.h" 15 #include "webkit/common/fileapi/file_system_types.h"
16 #include "webkit/common/quota/quota_types.h" 16 #include "webkit/common/quota/quota_types.h"
17 #include "webkit/storage/webkit_storage_export.h" 17 #include "webkit/common/webkit_common_export.h"
18 18
19 class GURL; 19 class GURL;
20 20
21 namespace fileapi { 21 namespace fileapi {
22 22
23 extern const char kPersistentDir[]; 23 WEBKIT_COMMON_EXPORT extern const char kPersistentDir[];
24 extern const char kTemporaryDir[]; 24 WEBKIT_COMMON_EXPORT extern const char kTemporaryDir[];
25 extern const char kExternalDir[]; 25 WEBKIT_COMMON_EXPORT extern const char kExternalDir[];
26 extern const char kIsolatedDir[]; 26 WEBKIT_COMMON_EXPORT extern const char kIsolatedDir[];
27 extern const char kTestDir[]; 27 WEBKIT_COMMON_EXPORT extern const char kTestDir[];
28 28
29 class WEBKIT_STORAGE_EXPORT VirtualPath { 29 class WEBKIT_COMMON_EXPORT VirtualPath {
30 public: 30 public:
31 static const base::FilePath::CharType kRoot[]; 31 static const base::FilePath::CharType kRoot[];
32 static const base::FilePath::CharType kSeparator; 32 static const base::FilePath::CharType kSeparator;
33 33
34 // Use this instead of base::FilePath::BaseName when operating on virtual 34 // Use this instead of base::FilePath::BaseName when operating on virtual
35 // paths. FilePath::BaseName will get confused by ':' on Windows when it 35 // paths. FilePath::BaseName will get confused by ':' on Windows when it
36 // looks like a drive letter separator; this will treat it as just another 36 // looks like a drive letter separator; this will treat it as just another
37 // character. 37 // character.
38 static base::FilePath BaseName(const base::FilePath& virtual_path); 38 static base::FilePath BaseName(const base::FilePath& virtual_path);
39 39
(...skipping 20 matching lines...) Expand all
60 60
61 // Returns the root URI of the filesystem that can be specified by a pair of 61 // Returns the root URI of the filesystem that can be specified by a pair of
62 // |origin_url| and |type|. The returned URI can be used as a root path 62 // |origin_url| and |type|. The returned URI can be used as a root path
63 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose 63 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose
64 // a path pointing to the entry "/relative/path" in the filesystem). 64 // a path pointing to the entry "/relative/path" in the filesystem).
65 // 65 //
66 // For Isolated filesystem this returns the 'common' root part, e.g. 66 // For Isolated filesystem this returns the 'common' root part, e.g.
67 // returns URL without the filesystem ID. 67 // returns URL without the filesystem ID.
68 // 68 //
69 // |type| needs to be public type as the returned URI is given to the renderer. 69 // |type| needs to be public type as the returned URI is given to the renderer.
70 WEBKIT_STORAGE_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url, 70 WEBKIT_COMMON_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url,
71 FileSystemType type); 71 FileSystemType type);
72 72
73 // Returns the name for the filesystem that is specified by a pair of 73 // Returns the name for the filesystem that is specified by a pair of
74 // |origin_url| and |type|. 74 // |origin_url| and |type|.
75 // (The name itself is neither really significant nor a formal identifier 75 // (The name itself is neither really significant nor a formal identifier
76 // but can be read as the .name field of the returned FileSystem object 76 // but can be read as the .name field of the returned FileSystem object
77 // as a user-friendly name in the javascript layer). 77 // as a user-friendly name in the javascript layer).
78 // 78 //
79 // |type| needs to be public type as the returned name is given to the renderer. 79 // |type| needs to be public type as the returned name is given to the renderer.
80 // 80 //
81 // Example: 81 // Example:
82 // The name for a TEMPORARY filesystem of "http://www.example.com:80/" 82 // The name for a TEMPORARY filesystem of "http://www.example.com:80/"
83 // should look like: "http_www.example.host_80:temporary" 83 // should look like: "http_www.example.host_80:temporary"
84 WEBKIT_STORAGE_EXPORT std::string GetFileSystemName(const GURL& origin_url, 84 WEBKIT_COMMON_EXPORT std::string GetFileSystemName(const GURL& origin_url,
85 FileSystemType type); 85 FileSystemType type);
86 86
87 // Converts FileSystemType |type| to/from the StorageType |storage_type| that 87 // Converts FileSystemType |type| to/from the StorageType |storage_type| that
88 // is used for the unified quota system. 88 // is used for the unified quota system.
89 // (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem 89 // (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem
90 // type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.) 90 // type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.)
91 WEBKIT_STORAGE_EXPORT FileSystemType QuotaStorageTypeToFileSystemType( 91 WEBKIT_COMMON_EXPORT FileSystemType QuotaStorageTypeToFileSystemType(
92 quota::StorageType storage_type); 92 quota::StorageType storage_type);
93 WEBKIT_STORAGE_EXPORT quota::StorageType FileSystemTypeToQuotaStorageType( 93 WEBKIT_COMMON_EXPORT quota::StorageType FileSystemTypeToQuotaStorageType(
94 FileSystemType type); 94 FileSystemType type);
95 95
96 // Returns the string representation of the given filesystem |type|. 96 // Returns the string representation of the given filesystem |type|.
97 // Returns an empty string if the |type| is invalid. 97 // Returns an empty string if the |type| is invalid.
98 WEBKIT_STORAGE_EXPORT std::string GetFileSystemTypeString(FileSystemType type); 98 WEBKIT_COMMON_EXPORT std::string GetFileSystemTypeString(FileSystemType type);
99 99
100 // Sets type to FileSystemType enum that corresponds to the string name. 100 // Sets type to FileSystemType enum that corresponds to the string name.
101 // Returns false if the |type_string| is invalid. 101 // Returns false if the |type_string| is invalid.
102 WEBKIT_STORAGE_EXPORT bool GetFileSystemPublicType( 102 WEBKIT_COMMON_EXPORT bool GetFileSystemPublicType(
103 std::string type_string, 103 std::string type_string,
104 WebKit::WebFileSystemType* type); 104 WebKit::WebFileSystemType* type);
105 105
106 // Encodes |file_path| to a string. 106 // Encodes |file_path| to a string.
107 // Following conditions should be held: 107 // Following conditions should be held:
108 // - StringToFilePath(FilePathToString(path)) == path 108 // - StringToFilePath(FilePathToString(path)) == path
109 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == 109 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") ==
110 // path.AppendASCII("SubDirectory"); 110 // path.AppendASCII("SubDirectory");
111 // 111 //
112 // TODO(tzik): Replace CreateFilePath and FilePathToString in 112 // TODO(tzik): Replace CreateFilePath and FilePathToString in
113 // third_party/leveldatabase/env_chromium.cc with them. 113 // third_party/leveldatabase/env_chromium.cc with them.
114 WEBKIT_STORAGE_EXPORT std::string FilePathToString( 114 WEBKIT_COMMON_EXPORT std::string FilePathToString(
115 const base::FilePath& file_path); 115 const base::FilePath& file_path);
116 116
117 // Decode a file path from |file_path_string|. 117 // Decode a file path from |file_path_string|.
118 WEBKIT_STORAGE_EXPORT base::FilePath StringToFilePath( 118 WEBKIT_COMMON_EXPORT base::FilePath StringToFilePath(
119 const std::string& file_path_string); 119 const std::string& file_path_string);
120 120
121 // File error conversion 121 // File error conversion
122 WEBKIT_STORAGE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError( 122 WEBKIT_COMMON_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError(
123 base::PlatformFileError error_code); 123 base::PlatformFileError error_code);
124 124
125 // Generate a file system name for the given arguments. Should only be used by 125 // Generate a file system name for the given arguments. Should only be used by
126 // platform apps. 126 // platform apps.
127 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemName( 127 WEBKIT_COMMON_EXPORT std::string GetIsolatedFileSystemName(
128 const GURL& origin_url, 128 const GURL& origin_url,
129 const std::string& filesystem_id); 129 const std::string& filesystem_id);
130 130
131 // Find the file system id from |filesystem_name|. Should only be used by 131 // Find the file system id from |filesystem_name|. Should only be used by
132 // platform apps. This function will return false if the file system name is 132 // platform apps. This function will return false if the file system name is
133 // not of the form {origin}:Isolated_{id}, and will also check that there is an 133 // not of the form {origin}:Isolated_{id}, and will also check that there is an
134 // origin and id present. It will not check that the origin or id are valid. 134 // origin and id present. It will not check that the origin or id are valid.
135 WEBKIT_STORAGE_EXPORT bool CrackIsolatedFileSystemName( 135 WEBKIT_COMMON_EXPORT bool CrackIsolatedFileSystemName(
136 const std::string& filesystem_name, 136 const std::string& filesystem_name,
137 std::string* filesystem_id); 137 std::string* filesystem_id);
138 138
139 // Returns the root URI for an isolated filesystem for origin |origin_url| 139 // Returns the root URI for an isolated filesystem for origin |origin_url|
140 // and |filesystem_id|. If the |optional_root_name| is given the resulting 140 // and |filesystem_id|. If the |optional_root_name| is given the resulting
141 // root URI will point to the subfolder within the isolated filesystem. 141 // root URI will point to the subfolder within the isolated filesystem.
142 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( 142 WEBKIT_COMMON_EXPORT std::string GetIsolatedFileSystemRootURIString(
143 const GURL& origin_url, 143 const GURL& origin_url,
144 const std::string& filesystem_id, 144 const std::string& filesystem_id,
145 const std::string& optional_root_name); 145 const std::string& optional_root_name);
146 146
147 // Returns the root URI for an external filesystem for origin |origin_url| 147 // Returns the root URI for an external filesystem for origin |origin_url|
148 // and |mount_name|. 148 // and |mount_name|.
149 WEBKIT_STORAGE_EXPORT std::string GetExternalFileSystemRootURIString( 149 WEBKIT_COMMON_EXPORT std::string GetExternalFileSystemRootURIString(
150 const GURL& origin_url, 150 const GURL& origin_url,
151 const std::string& mount_name); 151 const std::string& mount_name);
152 152
153 } // namespace fileapi 153 } // namespace fileapi
154 154
155 #endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ 155 #endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/common/fileapi/file_system_types.h ('k') | webkit/common/fileapi/webkit_common_fileapi.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698