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

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

Issue 6604020: Introduce FileSystemFileUtil and -Proxy to decorate base::file_util in webkit/fileapi. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/file_path.h"
12 #include "base/file_util_proxy.h"
13 #include "base/platform_file.h"
14 #include "base/ref_counted.h"
15 #include "base/tracked_objects.h"
16
17 namespace base {
18 class MessageLoopProxy;
19 class Time;
20 }
21
22 namespace fileapi {
23
24 class FileSystemOperationContext;
25
26 using base::MessageLoopProxy;
27 using base::PlatformFile;
28
29 // This class provides asynchronous access to common file routines for the
30 // FileSystem API.
31 class FileSystemFileUtilProxy {
32 public:
33 typedef base::FileUtilProxy::Entry Entry;
34 typedef base::FileUtilProxy::StatusCallback StatusCallback;
35 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback;
36 typedef base::FileUtilProxy::EnsureFileExistsCallback
37 EnsureFileExistsCallback;
38 typedef base::FileUtilProxy::GetFileInfoCallback GetFileInfoCallback;
39 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback;
40
41 // Creates or opens a file with the given flags. It is invalid to pass NULL
42 // for the callback.
43 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
44 // a new file at the given |file_path| and calls back with
45 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
46 static bool CreateOrOpen(FileSystemOperationContext* context,
47 scoped_refptr<MessageLoopProxy> message_loop_proxy,
48 const FilePath& file_path,
49 int file_flags,
50 CreateOrOpenCallback* callback);
51
52 // Close the given file handle.
53 static bool Close(FileSystemOperationContext* context,
54 scoped_refptr<MessageLoopProxy> message_loop_proxy,
55 PlatformFile,
56 StatusCallback* callback);
57
58 // Ensures that the given |file_path| exist. This creates a empty new file
59 // at |file_path| if the |file_path| does not exist.
60 // If a new file han not existed and is created at the |file_path|,
61 // |created| of the callback argument is set true and |error code|
62 // is set PLATFORM_FILE_OK.
63 // If the file already exists, |created| is set false and |error code|
64 // is set PLATFORM_FILE_OK.
65 // If the file hasn't existed but it couldn't be created for some other
66 // reasons, |created| is set false and |error code| indicates the error.
67 static bool EnsureFileExists(
68 FileSystemOperationContext* context,
69 scoped_refptr<MessageLoopProxy> message_loop_proxy,
70 const FilePath& file_path,
71 EnsureFileExistsCallback* callback);
72
73 // Retrieves the information about a file. It is invalid to pass NULL for the
74 // callback.
75 static bool GetFileInfo(
76 FileSystemOperationContext* context,
77 scoped_refptr<MessageLoopProxy> message_loop_proxy,
78 const FilePath& file_path,
79 GetFileInfoCallback* callback);
80
81 static bool ReadDirectory(FileSystemOperationContext* context,
82 scoped_refptr<MessageLoopProxy> message_loop_proxy,
83 const FilePath& file_path,
84 ReadDirectoryCallback* callback);
85
86 // Creates directory at given path. It's an error to create
87 // if |exclusive| is true and dir already exists.
88 static bool CreateDirectory(
89 FileSystemOperationContext* context,
90 scoped_refptr<MessageLoopProxy> message_loop_proxy,
91 const FilePath& file_path,
92 bool exclusive,
93 StatusCallback* callback);
94
95 // Copies a file or a directory from |src_file_path| to |dest_file_path|
96 // Error cases:
97 // If destination file doesn't exist or destination's parent
98 // doesn't exists.
99 // If source dir exists but destination path is an existing file.
100 // If source file exists but destination path is an existing directory.
101 // If source is a parent of destination.
102 // If source doesn't exists.
103 static bool Copy(FileSystemOperationContext* context,
104 scoped_refptr<MessageLoopProxy> message_loop_proxy,
105 const FilePath& src_file_path,
106 const FilePath& dest_file_path,
107 StatusCallback* callback);
108
109 // Moves a file or a directory from src_file_path to dest_file_path.
110 // Error cases are similar to Copy method's error cases.
111 static bool Move(
112 FileSystemOperationContext* context,
113 scoped_refptr<MessageLoopProxy> message_loop_proxy,
114 const FilePath& src_file_path,
115 const FilePath& dest_file_path,
116 StatusCallback* callback);
117
118 // Deletes a file or a directory.
119 // It is an error to delete a non-empty directory with recursive=false.
120 static bool Delete(FileSystemOperationContext* context,
121 scoped_refptr<MessageLoopProxy> message_loop_proxy,
122 const FilePath& file_path,
123 bool recursive,
124 StatusCallback* callback);
125
126 // Touches a file. The callback can be NULL.
127 static bool Touch(
128 FileSystemOperationContext* context,
129 scoped_refptr<MessageLoopProxy> message_loop_proxy,
130 const FilePath& file_path,
131 const base::Time& last_access_time,
132 const base::Time& last_modified_time,
133 StatusCallback* callback);
134
135 // Truncates a file to the given length. If |length| is greater than the
136 // current length of the file, the file will be extended with zeroes.
137 // The callback can be NULL.
138 static bool Truncate(
139 FileSystemOperationContext* context,
140 scoped_refptr<MessageLoopProxy> message_loop_proxy,
141 const FilePath& path,
142 int64 length,
143 StatusCallback* callback);
144
145 private:
146 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy);
147 };
148
149 } // namespace fileapi
150
151 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698