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

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

Issue 15658004: Split FileAPI code for common|common_child|renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « webkit/fileapi/file_system_types.h ('k') | webkit/fileapi/file_system_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/files/file_path.h"
12 #include "base/platform_file.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystemType.h "
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h"
15 #include "webkit/fileapi/file_system_types.h"
16 #include "webkit/quota/quota_types.h"
17 #include "webkit/storage/webkit_storage_export.h"
18
19 class GURL;
20
21 namespace fileapi {
22
23 extern const char kPersistentDir[];
24 extern const char kTemporaryDir[];
25 extern const char kExternalDir[];
26 extern const char kIsolatedDir[];
27 extern const char kTestDir[];
28
29 class WEBKIT_STORAGE_EXPORT VirtualPath {
30 public:
31 static const base::FilePath::CharType kRoot[];
32 static const base::FilePath::CharType kSeparator;
33
34 // Use this instead of base::FilePath::BaseName when operating on virtual
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
37 // character.
38 static base::FilePath BaseName(const base::FilePath& virtual_path);
39
40 // Use this instead of base::FilePath::DirName when operating on virtual
41 // paths.
42 static base::FilePath DirName(const base::FilePath& virtual_path);
43
44 // Likewise, use this instead of base::FilePath::GetComponents when
45 // operating on virtual paths.
46 // Note that this assumes very clean input, with no leading slash, and
47 // it will not evaluate '..' components.
48 static void GetComponents(
49 const base::FilePath& path,
50 std::vector<base::FilePath::StringType>* components);
51
52 // Returns a path name ensuring that it begins with kRoot and all path
53 // separators are forward slashes /.
54 static base::FilePath::StringType GetNormalizedFilePath(
55 const base::FilePath& path);
56
57 // Returns true if the given path begins with kRoot.
58 static bool IsAbsolute(const base::FilePath::StringType& path);
59 };
60
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
63 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose
64 // a path pointing to the entry "/relative/path" in the filesystem).
65 //
66 // For Isolated filesystem this returns the 'common' root part, e.g.
67 // returns URL without the filesystem ID.
68 //
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,
71 FileSystemType type);
72
73 // Returns the name for the filesystem that is specified by a pair of
74 // |origin_url| and |type|.
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
77 // as a user-friendly name in the javascript layer).
78 //
79 // |type| needs to be public type as the returned name is given to the renderer.
80 //
81 // Example:
82 // The name for a TEMPORARY filesystem of "http://www.example.com:80/"
83 // should look like: "http_www.example.host_80:temporary"
84 WEBKIT_STORAGE_EXPORT std::string GetFileSystemName(const GURL& origin_url,
85 FileSystemType type);
86
87 // Converts FileSystemType |type| to/from the StorageType |storage_type| that
88 // is used for the unified quota system.
89 // (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem
90 // type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.)
91 WEBKIT_STORAGE_EXPORT FileSystemType QuotaStorageTypeToFileSystemType(
92 quota::StorageType storage_type);
93 WEBKIT_STORAGE_EXPORT quota::StorageType FileSystemTypeToQuotaStorageType(
94 FileSystemType type);
95
96 // Returns the string representation of the given filesystem |type|.
97 // Returns an empty string if the |type| is invalid.
98 WEBKIT_STORAGE_EXPORT std::string GetFileSystemTypeString(FileSystemType type);
99
100 // Sets type to FileSystemType enum that corresponds to the string name.
101 // Returns false if the |type_string| is invalid.
102 WEBKIT_STORAGE_EXPORT bool GetFileSystemPublicType(
103 std::string type_string,
104 WebKit::WebFileSystemType* type);
105
106 // Encodes |file_path| to a string.
107 // Following conditions should be held:
108 // - StringToFilePath(FilePathToString(path)) == path
109 // - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") ==
110 // path.AppendASCII("SubDirectory");
111 //
112 // TODO(tzik): Replace CreateFilePath and FilePathToString in
113 // third_party/leveldatabase/env_chromium.cc with them.
114 WEBKIT_STORAGE_EXPORT std::string FilePathToString(const base::FilePath& file_pa th);
115
116 // Decode a file path from |file_path_string|.
117 WEBKIT_STORAGE_EXPORT base::FilePath StringToFilePath(
118 const std::string& file_path_string);
119
120 // File error conversion
121 WEBKIT_STORAGE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError(
122 base::PlatformFileError error_code);
123
124 // Generate a file system name for the given arguments. Should only be used by
125 // platform apps.
126 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemName(
127 const GURL& origin_url,
128 const std::string& filesystem_id);
129
130 // Find the file system id from |filesystem_name|. Should only be used by
131 // platform apps. This function will return false if the file system name is
132 // not of the form {origin}:Isolated_{id}, and will also check that there is an
133 // origin and id present. It will not check that the origin or id are valid.
134 WEBKIT_STORAGE_EXPORT bool CrackIsolatedFileSystemName(
135 const std::string& filesystem_name,
136 std::string* filesystem_id);
137
138 // Returns the root URI for an isolated filesystem for origin |origin_url|
139 // and |filesystem_id|. If the |optional_root_name| is given the resulting
140 // root URI will point to the subfolder within the isolated filesystem.
141 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString(
142 const GURL& origin_url,
143 const std::string& filesystem_id,
144 const std::string& optional_root_name);
145
146 } // namespace fileapi
147
148 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_types.h ('k') | webkit/fileapi/file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698