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

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

Issue 11103031: webkit: Merge blob and fileapi into one build target 'storage' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 2 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_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/fileapi/fileapi_export.h"
16 #include "webkit/quota/quota_types.h" 15 #include "webkit/quota/quota_types.h"
16 #include "webkit/storage/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 extern const char kPersistentName[]; 27 extern const char kPersistentName[];
28 extern const char kTemporaryName[]; 28 extern const char kTemporaryName[];
29 extern const char kExternalName[]; 29 extern const char kExternalName[];
30 extern const char kIsolatedName[]; 30 extern const char kIsolatedName[];
31 extern const char kTestName[]; 31 extern const char kTestName[];
32 32
33 class FILEAPI_EXPORT VirtualPath { 33 class STORAGE_EXPORT VirtualPath {
34 public: 34 public:
35 // Use this instead of FilePath::BaseName when operating on virtual paths. 35 // Use this instead of FilePath::BaseName when operating on virtual paths.
36 // FilePath::BaseName will get confused by ':' on Windows when it looks like a 36 // FilePath::BaseName will get confused by ':' on Windows when it looks like a
37 // drive letter separator; this will treat it as just another character. 37 // drive letter separator; this will treat it as just another character.
38 static FilePath BaseName(const FilePath& virtual_path); 38 static FilePath BaseName(const FilePath& virtual_path);
39 39
40 // Likewise, use this instead of FilePath::GetComponents when operating on 40 // Likewise, use this instead of FilePath::GetComponents when operating on
41 // virtual paths. 41 // virtual paths.
42 // Note that this assumes very clean input, with no leading slash, and it will 42 // Note that this assumes very clean input, with no leading slash, and it will
43 // not evaluate '.' or '..' components. 43 // not evaluate '.' or '..' components.
44 static void GetComponents(const FilePath& path, 44 static void GetComponents(const FilePath& path,
45 std::vector<FilePath::StringType>* components); 45 std::vector<FilePath::StringType>* components);
46 }; 46 };
47 47
48 // Returns the root URI of the filesystem that can be specified by a pair of 48 // Returns the root URI of the filesystem that can be specified by a pair of
49 // |origin_url| and |type|. The returned URI can be used as a root path 49 // |origin_url| and |type|. The returned URI can be used as a root path
50 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose 50 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose
51 // a path pointing to the entry "/relative/path" in the filesystem). 51 // a path pointing to the entry "/relative/path" in the filesystem).
52 // 52 //
53 // For Isolated filesystem this returns the 'common' root part, e.g. 53 // For Isolated filesystem this returns the 'common' root part, e.g.
54 // returns URL without the filesystem ID. 54 // returns URL without the filesystem ID.
55 // 55 //
56 // |type| needs to be public type as the returned URI is given to the renderer. 56 // |type| needs to be public type as the returned URI is given to the renderer.
57 FILEAPI_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url, 57 STORAGE_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url,
58 FileSystemType type); 58 FileSystemType type);
59 59
60 // Returns the name for the filesystem that is specified by a pair of 60 // Returns the name for the filesystem that is specified by a pair of
61 // |origin_url| and |type|. 61 // |origin_url| and |type|.
62 // (The name itself is neither really significant nor a formal identifier 62 // (The name itself is neither really significant nor a formal identifier
63 // but can be read as the .name field of the returned FileSystem object 63 // but can be read as the .name field of the returned FileSystem object
64 // as a user-friendly name in the javascript layer). 64 // as a user-friendly name in the javascript layer).
65 // 65 //
66 // |type| needs to be public type as the returned name is given to the renderer. 66 // |type| needs to be public type as the returned name is given to the renderer.
67 // 67 //
68 // Example: 68 // Example:
69 // The name for a TEMPORARY filesystem of "http://www.example.com:80/" 69 // The name for a TEMPORARY filesystem of "http://www.example.com:80/"
70 // should look like: "http_www.example.host_80:temporary" 70 // should look like: "http_www.example.host_80:temporary"
71 FILEAPI_EXPORT std::string GetFileSystemName(const GURL& origin_url, 71 STORAGE_EXPORT std::string GetFileSystemName(const GURL& origin_url,
72 FileSystemType type); 72 FileSystemType type);
73 73
74 // Converts FileSystemType |type| to/from the StorageType |storage_type| that 74 // Converts FileSystemType |type| to/from the StorageType |storage_type| that
75 // is used for the unified quota system. 75 // is used for the unified quota system.
76 // (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem 76 // (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem
77 // type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.) 77 // type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.)
78 FILEAPI_EXPORT FileSystemType QuotaStorageTypeToFileSystemType( 78 STORAGE_EXPORT FileSystemType QuotaStorageTypeToFileSystemType(
79 quota::StorageType storage_type); 79 quota::StorageType storage_type);
80 FILEAPI_EXPORT quota::StorageType FileSystemTypeToQuotaStorageType( 80 STORAGE_EXPORT quota::StorageType FileSystemTypeToQuotaStorageType(
81 FileSystemType type); 81 FileSystemType type);
82 82
83 // Returns the origin identifier string for the given |url| and vice versa. 83 // Returns the origin identifier string for the given |url| and vice versa.
84 // The origin identifier string is a serialized form of a security origin 84 // The origin identifier string is a serialized form of a security origin
85 // and can be used as a path name as it contains no "/" or other possibly 85 // and can be used as a path name as it contains no "/" or other possibly
86 // unsafe characters. (See WebKit's SecurityOrigin code for more details.) 86 // unsafe characters. (See WebKit's SecurityOrigin code for more details.)
87 // 87 //
88 // Example: 88 // Example:
89 // "http://www.example.com:80/"'s identifier should look like: 89 // "http://www.example.com:80/"'s identifier should look like:
90 // "http_www.example.host_80" 90 // "http_www.example.host_80"
91 FILEAPI_EXPORT std::string GetOriginIdentifierFromURL(const GURL& url); 91 STORAGE_EXPORT std::string GetOriginIdentifierFromURL(const GURL& url);
92 FILEAPI_EXPORT GURL GetOriginURLFromIdentifier( 92 STORAGE_EXPORT GURL GetOriginURLFromIdentifier(
93 const std::string& origin_identifier); 93 const std::string& origin_identifier);
94 94
95 // Returns the string representation of the given filesystem |type|. 95 // Returns the string representation of the given filesystem |type|.
96 // Returns an empty string if the |type| is invalid. 96 // Returns an empty string if the |type| is invalid.
97 FILEAPI_EXPORT std::string GetFileSystemTypeString(FileSystemType type); 97 STORAGE_EXPORT std::string GetFileSystemTypeString(FileSystemType type);
98 98
99 // Encodes |file_path| to a string. 99 // Encodes |file_path| to a string.
100 // Following conditions should be held: 100 // Following conditions should be held:
101 // - StringToFilePath(FilePathToString(path)) == path 101 // - StringToFilePath(FilePathToString(path)) == path
102 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == 102 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") ==
103 // path.AppendASCII("SubDirectory"); 103 // path.AppendASCII("SubDirectory");
104 // 104 //
105 // TODO(tzik): Replace CreateFilePath and FilePathToString in 105 // TODO(tzik): Replace CreateFilePath and FilePathToString in
106 // third_party/leveldatabase/env_chromium.cc with them. 106 // third_party/leveldatabase/env_chromium.cc with them.
107 FILEAPI_EXPORT std::string FilePathToString(const FilePath& file_path); 107 STORAGE_EXPORT std::string FilePathToString(const FilePath& file_path);
108 108
109 // Decode a file path from |file_path_string|. 109 // Decode a file path from |file_path_string|.
110 FILEAPI_EXPORT FilePath StringToFilePath(const std::string& file_path_string); 110 STORAGE_EXPORT FilePath StringToFilePath(const std::string& file_path_string);
111 111
112 // File error conversion 112 // File error conversion
113 FILEAPI_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError( 113 STORAGE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError(
114 base::PlatformFileError error_code); 114 base::PlatformFileError error_code);
115 115
116 // Generate a file system name for the given arguments. Should only be used by 116 // Generate a file system name for the given arguments. Should only be used by
117 // platform apps. 117 // platform apps.
118 FILEAPI_EXPORT std::string GetIsolatedFileSystemName( 118 STORAGE_EXPORT std::string GetIsolatedFileSystemName(
119 const GURL& origin_url, 119 const GURL& origin_url,
120 const std::string& filesystem_id); 120 const std::string& filesystem_id);
121 121
122 // Find the file system id from |filesystem_name|. Should only be used by 122 // Find the file system id from |filesystem_name|. Should only be used by
123 // platform apps. This function will return false if the file system name is 123 // platform apps. This function will return false if the file system name is
124 // not of the form {origin}:Isolated_{id}, and will also check that there is an 124 // not of the form {origin}:Isolated_{id}, and will also check that there is an
125 // origin and id present. It will not check that the origin or id are valid. 125 // origin and id present. It will not check that the origin or id are valid.
126 FILEAPI_EXPORT bool CrackIsolatedFileSystemName( 126 STORAGE_EXPORT bool CrackIsolatedFileSystemName(
127 const std::string& filesystem_name, 127 const std::string& filesystem_name,
128 std::string* filesystem_id); 128 std::string* filesystem_id);
129 129
130 } // namespace fileapi 130 } // namespace fileapi
131 131
132 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ 132 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698