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

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: rebased Created 8 years, 11 months 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
« no previous file with comments | « webkit/fileapi/file_system_operation.cc ('k') | webkit/fileapi/file_system_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 //
108 // E.g. a typical cancel implementation would look like:
109 //
110 // virtual void SomeOperationImpl::Cancel(
111 // scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher) {
112 // // Abort the current inflight operation first.
113 // ...
114 //
115 // // Dispatch ABORT error for the current operation by calling
116 // // DidFail() callback of the dispatcher attached to this operation.
117 // // (dispatcher_ in this example)
118 // dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT);
119 //
120 // // Dispatch 'success' for the cancel (or dispatch appropriate
121 // // error code with DidFail() if the cancel has somehow failed).
122 // cancel_dispatcher->DidSucceed();
123 // }
124 //
125 virtual void Cancel(
126 scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher) = 0;
127
108 // Modifies timestamps of a file or directory at |path| with 128 // Modifies timestamps of a file or directory at |path| with
109 // |last_access_time| and |last_modified_time|. The function DOES NOT 129 // |last_access_time| and |last_modified_time|. The function DOES NOT
110 // create a file unlike 'touch' command on Linux. 130 // create a file unlike 'touch' command on Linux.
111 // 131 //
112 // This function is used only by Pepper as of writing. 132 // This function is used only by Pepper as of writing.
113 virtual void TouchFile(const GURL& path, 133 virtual void TouchFile(const GURL& path,
114 const base::Time& last_access_time, 134 const base::Time& last_access_time,
115 const base::Time& last_modified_time) = 0; 135 const base::Time& last_modified_time) = 0;
116 136
117 // Opens a file at |path| with |file_flags|, where flags are OR'ed 137 // Opens a file at |path| with |file_flags|, where flags are OR'ed
118 // values of base::PlatformFileFlags. 138 // values of base::PlatformFileFlags.
119 // 139 //
120 // |peer_handle| is the process handle of a pepper plugin process, which 140 // |peer_handle| is the process handle of a pepper plugin process, which
121 // is necessary for underlying IPC calls with Pepper plugins. 141 // is necessary for underlying IPC calls with Pepper plugins.
122 // 142 //
123 // This function is used only by Pepper as of writing. 143 // This function is used only by Pepper as of writing.
124 virtual void OpenFile( 144 virtual void OpenFile(
125 const GURL& path, 145 const GURL& path,
126 int file_flags, 146 int file_flags,
127 base::ProcessHandle peer_handle) = 0; 147 base::ProcessHandle peer_handle) = 0;
128 }; 148 };
129 149
130 } // namespace fileapi 150 } // namespace fileapi
131 151
132 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_ 152 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_INTERFACE_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_operation.cc ('k') | webkit/fileapi/file_system_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698