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_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 15 #include "webkit/browser/webkit_storage_browser_export.h" |
14 #include "webkit/common/fileapi/directory_entry.h" | 16 #include "webkit/common/fileapi/directory_entry.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class Time; | 19 class Time; |
18 } | 20 } |
19 | 21 |
20 namespace net { | 22 namespace net { |
21 class URLRequest; | 23 class URLRequest; |
22 } | 24 } |
23 | 25 |
24 namespace webkit_blob { | 26 namespace webkit_blob { |
25 class ShareableFileReference; | 27 class ShareableFileReference; |
26 } | 28 } |
27 | 29 |
28 class GURL; | 30 class GURL; |
29 | 31 |
30 namespace fileapi { | 32 namespace fileapi { |
31 | 33 |
| 34 class FileSystemContext; |
32 class FileSystemURL; | 35 class FileSystemURL; |
33 class FileWriterDelegate; | 36 class FileWriterDelegate; |
34 class FileSystemOperationImpl; | |
35 | 37 |
36 // The interface class for FileSystemOperation implementations. | 38 // The interface class for FileSystemOperation implementations. |
37 // | 39 // |
38 // This interface defines file system operations required to implement | 40 // This interface defines file system operations required to implement |
39 // "File API: Directories and System" | 41 // "File API: Directories and System" |
40 // http://www.w3.org/TR/file-system-api/ | 42 // http://www.w3.org/TR/file-system-api/ |
41 // | 43 // |
42 // DESIGN NOTES | 44 // DESIGN NOTES |
43 // | 45 // |
44 // This class is designed to | 46 // This class is designed to |
45 // | 47 // |
46 // 1) Serve one-time file system operation per instance. Only one | 48 // 1) Serve one-time file system operation per instance. Only one |
47 // method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, | 49 // method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, |
48 // GetMetadata, ReadDirectory and Remove) may be called during the | 50 // GetMetadata, ReadDirectory and Remove) may be called during the |
49 // lifetime of this object and it should be called no more than once. | 51 // lifetime of this object and it should be called no more than once. |
50 // | 52 // |
51 // 2) Deliver the results of operations to the client via the callback function | 53 // 2) Deliver the results of operations to the client via the callback function |
52 // passed as the last parameter of the method. | 54 // passed as the last parameter of the method. |
53 // | 55 // |
54 // Note that it is valid to delete an operation while it is running. | 56 // Note that it is valid to delete an operation while it is running. |
55 // The callback will NOT be fired if the operation is deleted before | 57 // The callback will NOT be fired if the operation is deleted before |
56 // it gets called. | 58 // it gets called. |
57 class FileSystemOperation { | 59 class FileSystemOperation { |
58 public: | 60 public: |
| 61 WEBKIT_STORAGE_BROWSER_EXPORT static FileSystemOperation* Create( |
| 62 const FileSystemURL& url, |
| 63 FileSystemContext* file_system_context, |
| 64 scoped_ptr<FileSystemOperationContext> operation_context); |
| 65 |
59 virtual ~FileSystemOperation() {} | 66 virtual ~FileSystemOperation() {} |
60 | 67 |
61 // Used for CreateFile(), etc. |result| is the return code of the operation. | 68 // Used for CreateFile(), etc. |result| is the return code of the operation. |
62 typedef base::Callback<void(base::PlatformFileError result)> StatusCallback; | 69 typedef base::Callback<void(base::PlatformFileError result)> StatusCallback; |
63 | 70 |
64 // Used for GetMetadata(). |result| is the return code of the operation, | 71 // Used for GetMetadata(). |result| is the return code of the operation, |
65 // |file_info| is the obtained file info. | 72 // |file_info| is the obtained file info. |
66 typedef base::Callback< | 73 typedef base::Callback< |
67 void(base::PlatformFileError result, | 74 void(base::PlatformFileError result, |
68 const base::PlatformFileInfo& file_info)> GetMetadataCallback; | 75 const base::PlatformFileInfo& file_info)> GetMetadataCallback; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 kOperationOpenFile, | 363 kOperationOpenFile, |
357 kOperationCloseFile, | 364 kOperationCloseFile, |
358 kOperationGetLocalPath, | 365 kOperationGetLocalPath, |
359 kOperationCancel, | 366 kOperationCancel, |
360 }; | 367 }; |
361 }; | 368 }; |
362 | 369 |
363 } // namespace fileapi | 370 } // namespace fileapi |
364 | 371 |
365 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 372 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |