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

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

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 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/external_mount_points_unittest.cc ('k') | webkit/fileapi/file_system_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CONTEXT_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/platform_file.h" 15 #include "base/platform_file.h"
15 #include "base/sequenced_task_runner_helpers.h" 16 #include "base/sequenced_task_runner_helpers.h"
16 #include "webkit/fileapi/file_system_types.h" 17 #include "webkit/fileapi/file_system_types.h"
18 #include "webkit/fileapi/file_system_url.h"
17 #include "webkit/fileapi/task_runner_bound_observer_list.h" 19 #include "webkit/fileapi/task_runner_bound_observer_list.h"
18 #include "webkit/storage/webkit_storage_export.h" 20 #include "webkit/storage/webkit_storage_export.h"
19 21
20 class FilePath; 22 class FilePath;
21 23
22 namespace quota { 24 namespace quota {
23 class QuotaManagerProxy; 25 class QuotaManagerProxy;
24 class SpecialStoragePolicy; 26 class SpecialStoragePolicy;
25 } 27 }
26 28
27 namespace webkit_blob { 29 namespace webkit_blob {
28 class FileStreamReader; 30 class FileStreamReader;
29 } 31 }
30 32
31 namespace fileapi { 33 namespace fileapi {
32 34
33 class ExternalFileSystemMountPointProvider; 35 class ExternalFileSystemMountPointProvider;
36 class ExternalMountPoints;
34 class FileSystemFileUtil; 37 class FileSystemFileUtil;
35 class FileSystemMountPointProvider; 38 class FileSystemMountPointProvider;
36 class FileSystemOperation; 39 class FileSystemOperation;
37 class FileSystemOptions; 40 class FileSystemOptions;
38 class FileSystemQuotaUtil; 41 class FileSystemQuotaUtil;
39 class FileSystemTaskRunners; 42 class FileSystemTaskRunners;
40 class FileSystemURL; 43 class FileSystemURL;
41 class IsolatedMountPointProvider; 44 class IsolatedMountPointProvider;
42 class LocalFileChangeTracker; 45 class LocalFileChangeTracker;
46 class LocalFileSyncContext;
47 class MountPoints;
43 class SandboxMountPointProvider; 48 class SandboxMountPointProvider;
44 class LocalFileSyncContext;
45 49
46 struct DefaultContextDeleter; 50 struct DefaultContextDeleter;
47 51
48 // This class keeps and provides a file system context for FileSystem API. 52 // This class keeps and provides a file system context for FileSystem API.
49 // An instance of this class is created and owned by profile. 53 // An instance of this class is created and owned by profile.
50 class WEBKIT_STORAGE_EXPORT FileSystemContext 54 class WEBKIT_STORAGE_EXPORT FileSystemContext
51 : public base::RefCountedThreadSafe<FileSystemContext, 55 : public base::RefCountedThreadSafe<FileSystemContext,
52 DefaultContextDeleter> { 56 DefaultContextDeleter> {
53 public: 57 public:
54 // task_runners->file_task_runner() is used as default TaskRunner. 58 // task_runners->file_task_runner() is used as default TaskRunner.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool create, 135 bool create,
132 const OpenFileSystemCallback& callback); 136 const OpenFileSystemCallback& callback);
133 137
134 // Deletes the filesystem for the given |origin_url| and |type|. This should 138 // Deletes the filesystem for the given |origin_url| and |type|. This should
135 // be called on the IO Thread. 139 // be called on the IO Thread.
136 void DeleteFileSystem( 140 void DeleteFileSystem(
137 const GURL& origin_url, 141 const GURL& origin_url,
138 FileSystemType type, 142 FileSystemType type,
139 const DeleteFileSystemCallback& callback); 143 const DeleteFileSystemCallback& callback);
140 144
141 // Creates a new FileSystemOperation instance by cracking 145 // Creates a new FileSystemOperation instance by getting an appropriate
142 // the given filesystem URL |url| to get an appropriate MountPointProvider 146 // MountPointProvider for |url| and calling the provider's corresponding
143 // and calling the provider's corresponding CreateFileSystemOperation method. 147 // CreateFileSystemOperation method.
144 // The resolved MountPointProvider could perform further specialization 148 // The resolved MountPointProvider could perform further specialization
145 // depending on the filesystem type pointed by the |url|. 149 // depending on the filesystem type pointed by the |url|.
146 FileSystemOperation* CreateFileSystemOperation( 150 FileSystemOperation* CreateFileSystemOperation(
147 const FileSystemURL& url, 151 const FileSystemURL& url,
148 base::PlatformFileError* error_code); 152 base::PlatformFileError* error_code);
149 153
150 // Creates new FileStreamReader instance to read a file pointed by the given 154 // Creates new FileStreamReader instance to read a file pointed by the given
151 // filesystem URL |url| starting from |offset|. |expected_modification_time| 155 // filesystem URL |url| starting from |offset|. |expected_modification_time|
152 // specifies the expected last modification if the value is non-null, the 156 // specifies the expected last modification if the value is non-null, the
153 // reader will check the underlying file's actual modification time to see if 157 // reader will check the underlying file's actual modification time to see if
(...skipping 16 matching lines...) Expand all
170 FileSystemTaskRunners* task_runners() { return task_runners_.get(); } 174 FileSystemTaskRunners* task_runners() { return task_runners_.get(); }
171 175
172 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); } 176 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); }
173 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker); 177 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker);
174 178
175 LocalFileSyncContext* sync_context() { return sync_context_.get(); } 179 LocalFileSyncContext* sync_context() { return sync_context_.get(); }
176 void set_sync_context(LocalFileSyncContext* sync_context); 180 void set_sync_context(LocalFileSyncContext* sync_context);
177 181
178 const FilePath& partition_path() const { return partition_path_; } 182 const FilePath& partition_path() const { return partition_path_; }
179 183
184 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from |url|.
185 FileSystemURL CrackURL(const GURL& url) const;
186 // Same as |CrackFileSystemURL|, but cracks FileSystemURL created from method
187 // arguments.
188 FileSystemURL CreateCrackedFileSystemURL(const GURL& origin,
189 FileSystemType type,
190 const FilePath& path) const;
191
180 private: 192 private:
181 friend struct DefaultContextDeleter; 193 friend struct DefaultContextDeleter;
182 friend class base::DeleteHelper<FileSystemContext>; 194 friend class base::DeleteHelper<FileSystemContext>;
183 friend class base::RefCountedThreadSafe<FileSystemContext, 195 friend class base::RefCountedThreadSafe<FileSystemContext,
184 DefaultContextDeleter>; 196 DefaultContextDeleter>;
185 ~FileSystemContext(); 197 ~FileSystemContext();
186 198
187 void DeleteOnCorrectThread() const; 199 void DeleteOnCorrectThread() const;
188 200
201 // For non-cracked isolated and external mount points, returns a FileSystemURL
202 // created by cracking |url|. The url is cracked using MountPoints registered
203 // as |url_crackers_|. If the url cannot be cracked, returns invalid
204 // FileSystemURL.
205 //
206 // If the original url does not point to an isolated or external filesystem,
207 // returns the original url, without attempting to crack it.
208 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const;
209
189 scoped_ptr<FileSystemTaskRunners> task_runners_; 210 scoped_ptr<FileSystemTaskRunners> task_runners_;
190 211
191 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 212 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
192 213
193 // Regular mount point providers. 214 // Regular mount point providers.
194 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; 215 scoped_ptr<SandboxMountPointProvider> sandbox_provider_;
195 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; 216 scoped_ptr<IsolatedMountPointProvider> isolated_provider_;
196 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; 217 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_;
197 218
198 // Registered mount point providers. 219 // Registered mount point providers.
199 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_; 220 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_;
200 221
222 // MountPoints used to crack FileSystemURLs. The MountPoints are ordered
223 // in order they should try to crack a FileSystemURL.
224 std::vector<MountPoints*> url_crackers_;
225
201 // The base path of the storage partition for this context. 226 // The base path of the storage partition for this context.
202 const FilePath partition_path_; 227 const FilePath partition_path_;
203 228
204 // For syncable file systems. 229 // For syncable file systems.
205 scoped_ptr<LocalFileChangeTracker> change_tracker_; 230 scoped_ptr<LocalFileChangeTracker> change_tracker_;
206 scoped_refptr<LocalFileSyncContext> sync_context_; 231 scoped_refptr<LocalFileSyncContext> sync_context_;
207 232
208 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); 233 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext);
209 }; 234 };
210 235
211 struct DefaultContextDeleter { 236 struct DefaultContextDeleter {
212 static void Destruct(const FileSystemContext* context) { 237 static void Destruct(const FileSystemContext* context) {
213 context->DeleteOnCorrectThread(); 238 context->DeleteOnCorrectThread();
214 } 239 }
215 }; 240 };
216 241
217 } // namespace fileapi 242 } // namespace fileapi
218 243
219 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ 244 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/external_mount_points_unittest.cc ('k') | webkit/fileapi/file_system_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698