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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup around ValidateFileSystemRoot Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_OPERATION_INTERFACE_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_
7 7
8 #include "base/process.h" 8 #include "base/process.h"
9 9
10 namespace base { 10 namespace base {
11 class Time; 11 class Time;
12 } // namespace base 12 } // namespace base
13 13
14 namespace net { 14 namespace net {
15 class URLRequest; 15 class URLRequest;
16 class URLRequestContext; 16 class URLRequestContext;
17 } // namespace net 17 } // namespace net
18 18
19 class GURL; 19 class GURL;
20 20
21 namespace fileapi { 21 namespace fileapi {
22 22
23 class FileSystemCallbackDispatcher;
24
23 // The interface class for FileSystemOperation implementations. 25 // The interface class for FileSystemOperation implementations.
24 // 26 //
25 // This interface defines file system operations required to implement 27 // This interface defines file system operations required to implement
26 // "File API: Directories and System" 28 // "File API: Directories and System"
27 // http://www.w3.org/TR/file-system-api/ 29 // http://www.w3.org/TR/file-system-api/
28 // 30 //
29 // DESIGN NOTES 31 // DESIGN NOTES
30 // 32 //
31 // This class is designed to 33 // This class is designed to
32 // 34 //
33 // 1) Serve one-time file system operation per instance. Only one 35 // 1) Serve one-time file system operation per instance. Only one
34 // method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, 36 // method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists,
35 // GetMetadata, ReadDirectory and Remove) may be called during the 37 // GetMetadata, ReadDirectory and Remove) may be called during the
36 // lifetime of this object and it should be called no more than once. 38 // lifetime of this object and it should be called no more than once.
37 // 39 //
38 // 2) Be self-destructed, or get deleted via base::Owned() after the 40 // 2) Be self-destructed, or get deleted via base::Owned() after the
39 // operation finishes and completion callback is called. 41 // operation finishes and completion callback is called.
40 // 42 //
41 // 3) Deliver the results of operations to the client via 43 // 3) Deliver the results of operations to the client via
42 // FileSystemCallbackDispatcher. 44 // FileSystemCallbackDispatcher.
43 // TODO(kinuko): Change the functions to take callbacks instead. 45 // TODO(kinuko): Change the functions to take callbacks instead.
44 // 46 //
45 class FileSystemOperationInterface { 47 class FileSystemOperationInterface {
46 public: 48 public:
47 virtual ~FileSystemOperationInterface() {} 49 virtual ~FileSystemOperationInterface() {}
48 50
49 // Opens a file system at |origin_url| of the |type|. Creates a new file
50 // system if |create| is true.
51 virtual void OpenFileSystem(const GURL& origin_url,
52 fileapi::FileSystemType type,
53 bool create) = 0;
54
55 // Creates a file at |path|. If |exclusive| is true, an error is raised 51 // Creates a file at |path|. If |exclusive| is true, an error is raised
56 // in case a file is already present at the URL. 52 // in case a file is already present at the URL.
57 virtual void CreateFile(const GURL& path, 53 virtual void CreateFile(const GURL& path,
58 bool exclusive) = 0; 54 bool exclusive) = 0;
59 55
60 // Creates a directory at |path|. If |exclusive| is true, an error is 56 // Creates a directory at |path|. If |exclusive| is true, an error is
61 // raised in case a directory is already present at the URL. If 57 // raised in case a directory is already present at the URL. If
62 // |recursive| is true, create parent directories as needed just like 58 // |recursive| is true, create parent directories as needed just like
63 // mkdir -p does. 59 // mkdir -p does.
64 virtual void CreateDirectory(const GURL& path, 60 virtual void CreateDirectory(const GURL& path,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void Write(const net::URLRequestContext* url_request_context, 94 virtual void Write(const net::URLRequestContext* url_request_context,
99 const GURL& path, 95 const GURL& path,
100 const GURL& blob_url, 96 const GURL& blob_url,
101 int64 offset) = 0; 97 int64 offset) = 0;
102 98
103 // Truncates a file at |path| to |length|. If |length| is larger than 99 // Truncates a file at |path| to |length|. If |length| is larger than
104 // the original file size, the file will be extended, and the extended 100 // the original file size, the file will be extended, and the extended
105 // part is filled with null bytes. 101 // part is filled with null bytes.
106 virtual void Truncate(const GURL& path, int64 length) = 0; 102 virtual void Truncate(const GURL& path, int64 length) = 0;
107 103
104 // Tries to cancel the current operation [we support cancelling write or
105 // truncate only]. Reports failure for the current operation, then reports
106 // success for the cancel operation itself via the |cancel_dispatcher|.
107 // The ownership of |cancel_dispatcher| is transfered to and will deleted
satorux1 2011/12/27 18:56:37 will deleted -> will be deleted?
kinuko 2011/12/28 10:59:35 Done.
108 // by the operation.
109 //
110 // E.g. a typical cancel flow would look like:
111 //
112 // abort_current_operation();
satorux1 2011/12/27 18:56:37 what's this? Please add some explanation. Besides
kinuko 2011/12/28 10:59:35 Done.
113 // dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT);
satorux1 2011/12/27 18:56:37 dispatcher here is the dispather attached to the o
kinuko 2011/12/28 10:59:35 Done.
114 // cancel_dispatcher->DidSucceed();
115 //
116 virtual void Cancel(FileSystemCallbackDispatcher* cancel_dispatcher) = 0;
117
108 // Modifies timestamps of a file or directory at |path| with 118 // Modifies timestamps of a file or directory at |path| with
109 // |last_access_time| and |last_modified_time|. The function DOES NOT 119 // |last_access_time| and |last_modified_time|. The function DOES NOT
110 // create a file unlike 'touch' command on Linux. 120 // create a file unlike 'touch' command on Linux.
111 // 121 //
112 // This function is used only by Pepper as of writing. 122 // This function is used only by Pepper as of writing.
113 virtual void TouchFile(const GURL& path, 123 virtual void TouchFile(const GURL& path,
114 const base::Time& last_access_time, 124 const base::Time& last_access_time,
115 const base::Time& last_modified_time) = 0; 125 const base::Time& last_modified_time) = 0;
116 126
117 // Opens a file at |path| with |file_flags|, where flags are OR'ed 127 // Opens a file at |path| with |file_flags|, where flags are OR'ed
118 // values of base::PlatformFileFlags. 128 // values of base::PlatformFileFlags.
119 // 129 //
120 // |peer_handle| is the process handle of a pepper plugin process, which 130 // |peer_handle| is the process handle of a pepper plugin process, which
121 // is necessary for underlying IPC calls with Pepper plugins. 131 // is necessary for underlying IPC calls with Pepper plugins.
122 // 132 //
123 // This function is used only by Pepper as of writing. 133 // This function is used only by Pepper as of writing.
124 virtual void OpenFile( 134 virtual void OpenFile(
125 const GURL& path, 135 const GURL& path,
126 int file_flags, 136 int file_flags,
127 base::ProcessHandle peer_handle) = 0; 137 base::ProcessHandle peer_handle) = 0;
128 }; 138 };
129 139
130 } // namespace fileapi 140 } // namespace fileapi
131 141
132 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_ 142 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698