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

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

Issue 9004019: Cleanup: Removing FileSystemPathManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SANDBOX_MOUNT_POINT_PROVIDER_H_ 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_
6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "webkit/fileapi/file_system_mount_point_provider.h" 15 #include "webkit/fileapi/file_system_mount_point_provider.h"
16 #include "webkit/fileapi/file_system_quota_util.h" 16 #include "webkit/fileapi/file_system_quota_util.h"
17 17
18 namespace base { 18 namespace base {
19 class MessageLoopProxy; 19 class MessageLoopProxy;
20 } 20 }
21 21
22 namespace quota { 22 namespace quota {
23 class QuotaManagerProxy; 23 class QuotaManagerProxy;
24 } 24 }
25 25
26 namespace fileapi { 26 namespace fileapi {
27 27
28 class FileSystemOptions;
28 class ObfuscatedFileUtil; 29 class ObfuscatedFileUtil;
29 30
30 // An interface to construct or crack sandboxed filesystem paths for 31 // An interface to construct or crack sandboxed filesystem paths for
31 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's 32 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's
32 // profile directory in a sandboxed way. 33 // profile directory in a sandboxed way.
33 // This interface also lets one enumerate and remove storage for the origins 34 // This interface also lets one enumerate and remove storage for the origins
34 // that use the filesystem. 35 // that use the filesystem.
35 class SandboxMountPointProvider 36 class SandboxMountPointProvider
36 : public FileSystemMountPointProvider, 37 : public FileSystemMountPointProvider,
37 public FileSystemQuotaUtil { 38 public FileSystemQuotaUtil {
38 public: 39 public:
40 typedef FileSystemMountPointProvider::GetRootPathCallback GetRootPathCallback;
41
39 // Origin enumerator interface. 42 // Origin enumerator interface.
40 // An instance of this interface is assumed to be called on the file thread. 43 // An instance of this interface is assumed to be called on the file thread.
41 class OriginEnumerator { 44 class OriginEnumerator {
42 public: 45 public:
43 virtual ~OriginEnumerator() {} 46 virtual ~OriginEnumerator() {}
44 47
45 // Returns the next origin. Returns empty if there are no more origins. 48 // Returns the next origin. Returns empty if there are no more origins.
46 virtual GURL Next() = 0; 49 virtual GURL Next() = 0;
47 50
48 // Returns the current origin's information. 51 // Returns the current origin's information.
49 virtual bool HasFileSystemType(FileSystemType type) const = 0; 52 virtual bool HasFileSystemType(FileSystemType type) const = 0;
50 }; 53 };
51 54
52 SandboxMountPointProvider(
53 FileSystemPathManager* path_manager,
54 scoped_refptr<base::MessageLoopProxy> file_message_loop,
55 const FilePath& profile_path);
56 virtual ~SandboxMountPointProvider();
57
58 // Checks if access to |virtual_path| is allowed from |origin_url|.
59 virtual bool IsAccessAllowed(const GURL& origin_url,
60 FileSystemType type,
61 const FilePath& virtual_path) OVERRIDE;
62
63 // Retrieves the root path for the given |origin_url| and |type|, and
64 // calls the given |callback| with the root path and name.
65 // If |create| is true this also creates the directory if it doesn't exist.
66 virtual void ValidateFileSystemRootAndGetURL(
67 const GURL& origin_url,
68 FileSystemType type,
69 bool create,
70 const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE;
71
72 // Like GetFileSystemRootPath, but synchronous, and can be called only while
73 // running on the file thread.
74 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread(
75 const GURL& origin_url,
76 FileSystemType type,
77 const FilePath& unused,
78 bool create) OVERRIDE;
79
80 // The legacy [pre-obfuscation] FileSystem directory name, kept around for 55 // The legacy [pre-obfuscation] FileSystem directory name, kept around for
81 // migration and migration testing. 56 // migration and migration testing.
82 static const FilePath::CharType kOldFileSystemDirectory[]; 57 static const FilePath::CharType kOldFileSystemDirectory[];
83 // The FileSystem directory name. 58 // The FileSystem directory name.
84 static const FilePath::CharType kNewFileSystemDirectory[]; 59 static const FilePath::CharType kNewFileSystemDirectory[];
85 // Where we move the old filesystem directory if migration fails. 60 // Where we move the old filesystem directory if migration fails.
86 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; 61 static const FilePath::CharType kRenamedOldFileSystemDirectory[];
87 62
63 SandboxMountPointProvider(
64 scoped_refptr<base::MessageLoopProxy> file_message_loop,
65 const FilePath& profile_path,
66 FileSystemOptions* file_system_options);
67 virtual ~SandboxMountPointProvider();
68
69 // FileSystemMountPointProvider overrides.
70 virtual bool IsAccessAllowed(
71 const GURL& origin_url,
72 FileSystemType type,
73 const FilePath& virtual_path) OVERRIDE;
74 virtual void ValidateFileSystemRootAndGetURL(
75 const GURL& origin_url,
76 FileSystemType type,
77 bool create,
78 const GetRootPathCallback& callback) OVERRIDE;
79 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread(
80 const GURL& origin_url,
81 FileSystemType type,
82 const FilePath& unused,
83 bool create) OVERRIDE;
84 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE;
85 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE;
86 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE;
87
88 FilePath old_base_path() const; 88 FilePath old_base_path() const;
89 FilePath new_base_path() const; 89 FilePath new_base_path() const;
90 FilePath renamed_old_base_path() const; 90 FilePath renamed_old_base_path() const;
91 91
92 // Checks if a given |name| contains any restricted names/chars in it.
93 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE;
94
95 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE;
96
97 // Returns an origin enumerator of this provider. 92 // Returns an origin enumerator of this provider.
98 // This method can only be called on the file thread. 93 // This method can only be called on the file thread.
99 OriginEnumerator* CreateOriginEnumerator() const; 94 OriginEnumerator* CreateOriginEnumerator() const;
100 95
101 // Gets a base directory path of the sandboxed filesystem that is 96 // Gets a base directory path of the sandboxed filesystem that is
102 // specified by |origin_url| and |type|. 97 // specified by |origin_url| and |type|.
103 // (The path is similar to the origin's root path but doesn't contain 98 // (The path is similar to the origin's root path but doesn't contain
104 // the 'unique' part.) 99 // the 'unique' part.)
105 // Returns an empty path if the given type is invalid. 100 // Returns an empty path if the given type is invalid.
106 // This method can only be called on the file thread. 101 // This method can only be called on the file thread.
107 FilePath GetBaseDirectoryForOriginAndType( 102 FilePath GetBaseDirectoryForOriginAndType(
108 const GURL& origin_url, 103 const GURL& origin_url,
109 FileSystemType type, 104 FileSystemType type,
110 bool create) const; 105 bool create) const;
111 106
112 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE;
113
114 // Deletes the data on the origin and reports the amount of deleted data 107 // Deletes the data on the origin and reports the amount of deleted data
115 // to the quota manager via |proxy|. 108 // to the quota manager via |proxy|.
116 bool DeleteOriginDataOnFileThread( 109 bool DeleteOriginDataOnFileThread(
117 quota::QuotaManagerProxy* proxy, 110 quota::QuotaManagerProxy* proxy,
118 const GURL& origin_url, 111 const GURL& origin_url,
119 FileSystemType type); 112 FileSystemType type);
120 113
121 // Quota util methods. 114 // Quota util methods.
122 virtual void GetOriginsForTypeOnFileThread( 115 virtual void GetOriginsForTypeOnFileThread(
123 FileSystemType type, 116 FileSystemType type,
(...skipping 27 matching lines...) Expand all
151 144
152 private: 145 private:
153 // Returns a path to the usage cache file. 146 // Returns a path to the usage cache file.
154 FilePath GetUsageCachePathForOriginAndType( 147 FilePath GetUsageCachePathForOriginAndType(
155 const GURL& origin_url, 148 const GURL& origin_url,
156 FileSystemType type) const; 149 FileSystemType type) const;
157 150
158 FilePath OldCreateFileSystemRootPath( 151 FilePath OldCreateFileSystemRootPath(
159 const GURL& origin_url, FileSystemType type); 152 const GURL& origin_url, FileSystemType type);
160 153
154 // Returns true if the given |url|'s scheme is allowed to access
155 // filesystem.
156 bool IsAllowedScheme(const GURL& url) const;
157
161 class GetFileSystemRootPathTask; 158 class GetFileSystemRootPathTask;
162 159
163 friend class FileSystemTestOriginHelper; 160 friend class FileSystemTestOriginHelper;
164 friend class SandboxMountPointProviderMigrationTest; 161 friend class SandboxMountPointProviderMigrationTest;
165 friend class SandboxMountPointProviderOriginEnumeratorTest; 162 friend class SandboxMountPointProviderOriginEnumeratorTest;
166 163
167 // The path_manager_ isn't owned by this instance; this instance is owned by
168 // the path_manager_, and they have the same lifetime.
169 FileSystemPathManager* path_manager_;
170
171 scoped_refptr<base::MessageLoopProxy> file_message_loop_; 164 scoped_refptr<base::MessageLoopProxy> file_message_loop_;
172 165
173 const FilePath profile_path_; 166 const FilePath profile_path_;
174 167
168 scoped_ptr<FileSystemOptions> file_system_options_;
169
175 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; 170 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_;
176 171
177 // Acccessed only on the file thread. 172 // Acccessed only on the file thread.
178 std::set<GURL> visited_origins_; 173 std::set<GURL> visited_origins_;
179 174
180 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); 175 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider);
181 }; 176 };
182 177
183 } // namespace fileapi 178 } // namespace fileapi
184 179
185 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ 180 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698