| OLD | NEW |
| 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_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "webkit/browser/fileapi/file_system_operation.h" | 13 #include "webkit/browser/fileapi/file_system_operation.h" |
| 14 #include "webkit/browser/fileapi/file_system_operation_context.h" | 14 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 15 #include "webkit/browser/fileapi/file_system_url.h" | 15 #include "webkit/browser/fileapi/file_system_url.h" |
| 16 #include "webkit/browser/fileapi/file_writer_delegate.h" | 16 #include "webkit/browser/fileapi/file_writer_delegate.h" |
| 17 #include "webkit/common/blob/scoped_file.h" | 17 #include "webkit/common/blob/scoped_file.h" |
| 18 #include "webkit/common/quota/quota_types.h" | 18 #include "webkit/common/quota/quota_types.h" |
| 19 #include "webkit/storage/webkit_storage_export.h" | 19 #include "webkit/storage/webkit_storage_export.h" |
| 20 | 20 |
| 21 namespace chromeos { | |
| 22 class CrosMountPointProvider; | |
| 23 } | |
| 24 | |
| 25 namespace sync_file_system { | |
| 26 class SyncableFileSystemOperation; | |
| 27 } | |
| 28 | |
| 29 namespace fileapi { | 21 namespace fileapi { |
| 30 | 22 |
| 31 class AsyncFileUtil; | 23 class AsyncFileUtil; |
| 32 class FileSystemContext; | 24 class FileSystemContext; |
| 33 class RecursiveOperationDelegate; | 25 class RecursiveOperationDelegate; |
| 34 | 26 |
| 35 // FileSystemOperation implementation for local file systems. | 27 // FileSystemOperation implementation for local file systems. |
| 36 class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation | 28 class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
| 37 : public NON_EXPORTED_BASE(FileSystemOperation), | 29 : public NON_EXPORTED_BASE(FileSystemOperation), |
| 38 public base::SupportsWeakPtr<LocalFileSystemOperation> { | 30 public base::SupportsWeakPtr<LocalFileSystemOperation> { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 65 virtual void DirectoryExists(const FileSystemURL& url, | 57 virtual void DirectoryExists(const FileSystemURL& url, |
| 66 const StatusCallback& callback) OVERRIDE; | 58 const StatusCallback& callback) OVERRIDE; |
| 67 virtual void FileExists(const FileSystemURL& url, | 59 virtual void FileExists(const FileSystemURL& url, |
| 68 const StatusCallback& callback) OVERRIDE; | 60 const StatusCallback& callback) OVERRIDE; |
| 69 virtual void GetMetadata(const FileSystemURL& url, | 61 virtual void GetMetadata(const FileSystemURL& url, |
| 70 const GetMetadataCallback& callback) OVERRIDE; | 62 const GetMetadataCallback& callback) OVERRIDE; |
| 71 virtual void ReadDirectory(const FileSystemURL& url, | 63 virtual void ReadDirectory(const FileSystemURL& url, |
| 72 const ReadDirectoryCallback& callback) OVERRIDE; | 64 const ReadDirectoryCallback& callback) OVERRIDE; |
| 73 virtual void Remove(const FileSystemURL& url, bool recursive, | 65 virtual void Remove(const FileSystemURL& url, bool recursive, |
| 74 const StatusCallback& callback) OVERRIDE; | 66 const StatusCallback& callback) OVERRIDE; |
| 75 virtual void Write(const net::URLRequestContext* url_request_context, | 67 virtual void Write(const FileSystemURL& url, |
| 76 const FileSystemURL& url, | 68 scoped_ptr<FileWriterDelegate> writer_delegate, |
| 77 const GURL& blob_url, | 69 scoped_ptr<net::URLRequest> blob_request, |
| 78 int64 offset, | |
| 79 const WriteCallback& callback) OVERRIDE; | 70 const WriteCallback& callback) OVERRIDE; |
| 80 virtual void Truncate(const FileSystemURL& url, int64 length, | 71 virtual void Truncate(const FileSystemURL& url, int64 length, |
| 81 const StatusCallback& callback) OVERRIDE; | 72 const StatusCallback& callback) OVERRIDE; |
| 82 virtual void TouchFile(const FileSystemURL& url, | 73 virtual void TouchFile(const FileSystemURL& url, |
| 83 const base::Time& last_access_time, | 74 const base::Time& last_access_time, |
| 84 const base::Time& last_modified_time, | 75 const base::Time& last_modified_time, |
| 85 const StatusCallback& callback) OVERRIDE; | 76 const StatusCallback& callback) OVERRIDE; |
| 86 virtual void OpenFile(const FileSystemURL& url, | 77 virtual void OpenFile(const FileSystemURL& url, |
| 87 int file_flags, | 78 int file_flags, |
| 88 base::ProcessHandle peer_handle, | 79 base::ProcessHandle peer_handle, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const StatusCallback& callback); | 152 const StatusCallback& callback); |
| 162 | 153 |
| 163 // Synchronously gets the platform path for the given |url|. | 154 // Synchronously gets the platform path for the given |url|. |
| 164 void SyncGetPlatformPath(const FileSystemURL& url, | 155 void SyncGetPlatformPath(const FileSystemURL& url, |
| 165 base::FilePath* platform_path); | 156 base::FilePath* platform_path); |
| 166 | 157 |
| 167 FileSystemContext* file_system_context() const { | 158 FileSystemContext* file_system_context() const { |
| 168 return file_system_context_.get(); | 159 return file_system_context_.get(); |
| 169 } | 160 } |
| 170 | 161 |
| 171 private: | 162 protected: |
| 172 friend class sync_file_system::SyncableFileSystemOperation; | |
| 173 | |
| 174 // Queries the quota and usage and then runs the given |task|. | 163 // Queries the quota and usage and then runs the given |task|. |
| 175 // If an error occurs during the quota query it runs |error_callback| instead. | 164 // If an error occurs during the quota query it runs |error_callback| instead. |
| 176 void GetUsageAndQuotaThenRunTask( | 165 void GetUsageAndQuotaThenRunTask( |
| 177 const FileSystemURL& url, | 166 const FileSystemURL& url, |
| 178 const base::Closure& task, | 167 const base::Closure& task, |
| 179 const base::Closure& error_callback); | 168 const base::Closure& error_callback); |
| 180 | 169 |
| 181 // Called after the quota info is obtained from the quota manager | 170 // Called after the quota info is obtained from the quota manager |
| 182 // (which is triggered by GetUsageAndQuotaThenRunTask). | 171 // (which is triggered by GetUsageAndQuotaThenRunTask). |
| 183 // Sets the quota info in the operation_context_ and then runs the given | 172 // Sets the quota info in the operation_context_ and then runs the given |
| 184 // |task| if the returned quota status is successful, otherwise runs | 173 // |task| if the returned quota status is successful, otherwise runs |
| 185 // |error_callback|. | 174 // |error_callback|. |
| 186 void DidGetUsageAndQuotaAndRunTask( | 175 void DidGetUsageAndQuotaAndRunTask( |
| 187 const base::Closure& task, | 176 const base::Closure& task, |
| 188 const base::Closure& error_callback, | 177 const base::Closure& error_callback, |
| 189 quota::QuotaStatusCode status, | 178 quota::QuotaStatusCode status, |
| 190 int64 usage, int64 quota); | 179 int64 usage, int64 quota); |
| 191 | 180 |
| 192 // returns a closure which actually perform the write operation. | |
| 193 base::Closure GetWriteClosure( | |
| 194 const net::URLRequestContext* url_request_context, | |
| 195 const FileSystemURL& url, | |
| 196 const GURL& blob_url, | |
| 197 int64 offset, | |
| 198 const WriteCallback& callback); | |
| 199 void DidFailWrite( | |
| 200 const WriteCallback& callback, | |
| 201 base::PlatformFileError result); | |
| 202 | |
| 203 // The 'body' methods that perform the actual work (i.e. posting the | 181 // The 'body' methods that perform the actual work (i.e. posting the |
| 204 // file task on proxy_) after the quota check. | 182 // file task on proxy_) after the quota check. |
| 205 void DoCreateFile(const FileSystemURL& url, | 183 void DoCreateFile(const FileSystemURL& url, |
| 206 const StatusCallback& callback, bool exclusive); | 184 const StatusCallback& callback, bool exclusive); |
| 207 void DoCreateDirectory(const FileSystemURL& url, | 185 void DoCreateDirectory(const FileSystemURL& url, |
| 208 const StatusCallback& callback, | 186 const StatusCallback& callback, |
| 209 bool exclusive, | 187 bool exclusive, |
| 210 bool recursive); | 188 bool recursive); |
| 211 void DoCopyFileLocal(const FileSystemURL& src, | 189 void DoCopyFileLocal(const FileSystemURL& src, |
| 212 const FileSystemURL& dest, | 190 const FileSystemURL& dest, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 250 |
| 273 // A flag to make sure we call operation only once per instance. | 251 // A flag to make sure we call operation only once per instance. |
| 274 OperationType pending_operation_; | 252 OperationType pending_operation_; |
| 275 | 253 |
| 276 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperation); | 254 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperation); |
| 277 }; | 255 }; |
| 278 | 256 |
| 279 } // namespace fileapi | 257 } // namespace fileapi |
| 280 | 258 |
| 281 #endif // WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ | 259 #endif // WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |