| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_ | 5 #include "storage/browser/fileapi/plugin_private_file_system_backend.h" |
| 6 #define WEBKIT_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "webkit/browser/fileapi/file_system_backend.h" | |
| 14 #include "webkit/browser/fileapi/file_system_options.h" | |
| 15 #include "webkit/browser/fileapi/file_system_quota_util.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class SequencedTaskRunner; | |
| 19 } | |
| 20 | |
| 21 namespace content { | |
| 22 class PluginPrivateFileSystemBackendTest; | |
| 23 } | |
| 24 | |
| 25 namespace storage { | |
| 26 class SpecialStoragePolicy; | |
| 27 } | |
| 28 | |
| 29 namespace storage { | |
| 30 | |
| 31 class ObfuscatedFileUtil; | |
| 32 class WatcherManager; | |
| 33 | |
| 34 class STORAGE_EXPORT PluginPrivateFileSystemBackend | |
| 35 : public FileSystemBackend, | |
| 36 public FileSystemQuotaUtil { | |
| 37 public: | |
| 38 class FileSystemIDToPluginMap; | |
| 39 typedef base::Callback<void(base::File::Error result)> StatusCallback; | |
| 40 | |
| 41 PluginPrivateFileSystemBackend( | |
| 42 base::SequencedTaskRunner* file_task_runner, | |
| 43 const base::FilePath& profile_path, | |
| 44 storage::SpecialStoragePolicy* special_storage_policy, | |
| 45 const FileSystemOptions& file_system_options); | |
| 46 virtual ~PluginPrivateFileSystemBackend(); | |
| 47 | |
| 48 // This must be used to open 'private' filesystem instead of regular | |
| 49 // OpenFileSystem. | |
| 50 // |plugin_id| must be an identifier string for per-plugin | |
| 51 // isolation, e.g. name, MIME type etc. | |
| 52 // NOTE: |plugin_id| must be sanitized ASCII string that doesn't | |
| 53 // include *any* dangerous character like '/'. | |
| 54 void OpenPrivateFileSystem( | |
| 55 const GURL& origin_url, | |
| 56 FileSystemType type, | |
| 57 const std::string& filesystem_id, | |
| 58 const std::string& plugin_id, | |
| 59 OpenFileSystemMode mode, | |
| 60 const StatusCallback& callback); | |
| 61 | |
| 62 // FileSystemBackend overrides. | |
| 63 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | |
| 64 virtual void Initialize(FileSystemContext* context) OVERRIDE; | |
| 65 virtual void ResolveURL(const FileSystemURL& url, | |
| 66 OpenFileSystemMode mode, | |
| 67 const OpenFileSystemCallback& callback) OVERRIDE; | |
| 68 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; | |
| 69 virtual WatcherManager* GetWatcherManager(FileSystemType type) OVERRIDE; | |
| 70 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( | |
| 71 FileSystemType type, | |
| 72 base::File::Error* error_code) OVERRIDE; | |
| 73 virtual FileSystemOperation* CreateFileSystemOperation( | |
| 74 const FileSystemURL& url, | |
| 75 FileSystemContext* context, | |
| 76 base::File::Error* error_code) const OVERRIDE; | |
| 77 virtual bool SupportsStreaming(const FileSystemURL& url) const OVERRIDE; | |
| 78 virtual bool HasInplaceCopyImplementation( | |
| 79 storage::FileSystemType type) const OVERRIDE; | |
| 80 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( | |
| 81 const FileSystemURL& url, | |
| 82 int64 offset, | |
| 83 const base::Time& expected_modification_time, | |
| 84 FileSystemContext* context) const OVERRIDE; | |
| 85 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( | |
| 86 const FileSystemURL& url, | |
| 87 int64 offset, | |
| 88 FileSystemContext* context) const OVERRIDE; | |
| 89 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | |
| 90 | |
| 91 // FileSystemQuotaUtil overrides. | |
| 92 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( | |
| 93 FileSystemContext* context, | |
| 94 storage::QuotaManagerProxy* proxy, | |
| 95 const GURL& origin_url, | |
| 96 FileSystemType type) OVERRIDE; | |
| 97 virtual void GetOriginsForTypeOnFileTaskRunner( | |
| 98 FileSystemType type, | |
| 99 std::set<GURL>* origins) OVERRIDE; | |
| 100 virtual void GetOriginsForHostOnFileTaskRunner( | |
| 101 FileSystemType type, | |
| 102 const std::string& host, | |
| 103 std::set<GURL>* origins) OVERRIDE; | |
| 104 virtual int64 GetOriginUsageOnFileTaskRunner( | |
| 105 FileSystemContext* context, | |
| 106 const GURL& origin_url, | |
| 107 FileSystemType type) OVERRIDE; | |
| 108 virtual scoped_refptr<QuotaReservation> | |
| 109 CreateQuotaReservationOnFileTaskRunner( | |
| 110 const GURL& origin_url, | |
| 111 FileSystemType type) OVERRIDE; | |
| 112 virtual void AddFileUpdateObserver( | |
| 113 FileSystemType type, | |
| 114 FileUpdateObserver* observer, | |
| 115 base::SequencedTaskRunner* task_runner) OVERRIDE; | |
| 116 virtual void AddFileChangeObserver( | |
| 117 FileSystemType type, | |
| 118 FileChangeObserver* observer, | |
| 119 base::SequencedTaskRunner* task_runner) OVERRIDE; | |
| 120 virtual void AddFileAccessObserver( | |
| 121 FileSystemType type, | |
| 122 FileAccessObserver* observer, | |
| 123 base::SequencedTaskRunner* task_runner) OVERRIDE; | |
| 124 virtual const UpdateObserverList* GetUpdateObservers( | |
| 125 FileSystemType type) const OVERRIDE; | |
| 126 virtual const ChangeObserverList* GetChangeObservers( | |
| 127 FileSystemType type) const OVERRIDE; | |
| 128 virtual const AccessObserverList* GetAccessObservers( | |
| 129 FileSystemType type) const OVERRIDE; | |
| 130 | |
| 131 private: | |
| 132 friend class content::PluginPrivateFileSystemBackendTest; | |
| 133 | |
| 134 ObfuscatedFileUtil* obfuscated_file_util(); | |
| 135 const base::FilePath& base_path() const { return base_path_; } | |
| 136 | |
| 137 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | |
| 138 const FileSystemOptions file_system_options_; | |
| 139 const base::FilePath base_path_; | |
| 140 scoped_ptr<AsyncFileUtil> file_util_; | |
| 141 FileSystemIDToPluginMap* plugin_map_; // Owned by file_util_. | |
| 142 base::WeakPtrFactory<PluginPrivateFileSystemBackend> weak_factory_; | |
| 143 | |
| 144 DISALLOW_COPY_AND_ASSIGN(PluginPrivateFileSystemBackend); | |
| 145 }; | |
| 146 | |
| 147 } // namespace storage | |
| 148 | |
| 149 #endif // WEBKIT_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_ | |
| OLD | NEW |