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