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

Side by Side Diff: base/file_util_proxy.h

Issue 8294015: base::Bind: Convert FileUtilProxy::ReadCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fixes. Created 9 years, 2 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 | « no previous file | base/file_util_proxy.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 BASE_FILE_UTIL_PROXY_H_ 5 #ifndef BASE_FILE_UTIL_PROXY_H_
6 #define BASE_FILE_UTIL_PROXY_H_ 6 #define BASE_FILE_UTIL_PROXY_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 typedef base::Callback<void(PlatformFileError /* error code */, 45 typedef base::Callback<void(PlatformFileError /* error code */,
46 PassPlatformFile, 46 PassPlatformFile,
47 FilePath)> CreateTemporaryCallback; 47 FilePath)> CreateTemporaryCallback;
48 typedef base::Callback<void(PlatformFileError /* error code */, 48 typedef base::Callback<void(PlatformFileError /* error code */,
49 bool /* created */)> EnsureFileExistsCallback; 49 bool /* created */)> EnsureFileExistsCallback;
50 typedef base::Callback<void(PlatformFileError /* error code */, 50 typedef base::Callback<void(PlatformFileError /* error code */,
51 const PlatformFileInfo& /* file_info */)> 51 const PlatformFileInfo& /* file_info */)>
52 GetFileInfoCallback; 52 GetFileInfoCallback;
53 typedef base::Callback<void(PlatformFileError /* error code */, 53 typedef base::Callback<void(PlatformFileError /* error code */,
54 const std::vector<Entry>&)> ReadDirectoryCallback; 54 const std::vector<Entry>&)> ReadDirectoryCallback;
55 typedef Callback3<PlatformFileError /* error code */, 55 typedef base::Callback<void(PlatformFileError /* error code */,
56 const char* /* data */, 56 const char* /* data */,
57 int /* bytes read/written */>::Type ReadCallback; 57 int /* bytes read/written */)> ReadCallback;
58 typedef Callback2<PlatformFileError /* error code */, 58 typedef Callback2<PlatformFileError /* error code */,
59 int /* bytes written */>::Type WriteCallback; 59 int /* bytes written */>::Type WriteCallback;
60 60
61 // Creates or opens a file with the given flags. It is invalid to pass NULL 61 // Creates or opens a file with the given flags. It is invalid to pass a null
62 // for the callback. 62 // callback. If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to
63 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create 63 // create a new file at the given |file_path| and calls back with
64 // a new file at the given |file_path| and calls back with 64 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. Takes
65 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. 65 // ownership of |callback| and will delete it even on failure.
66 // Takes ownership of |callback| and will delete it even on failure.
67 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, 66 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy,
68 const FilePath& file_path, 67 const FilePath& file_path,
69 int file_flags, 68 int file_flags,
70 const CreateOrOpenCallback& callback); 69 const CreateOrOpenCallback& callback);
71 70
72 // Creates a temporary file for writing. The path and an open file handle 71 // Creates a temporary file for writing. The path and an open file handle are
73 // are returned. It is invalid to pass NULL for the callback. The additional 72 // returned. It is invalid to pass a null callback. The additional file flags
74 // file flags will be added on top of the default file flags which are: 73 // will be added on top of the default file flags which are:
75 // base::PLATFORM_FILE_CREATE_ALWAYS 74 // base::PLATFORM_FILE_CREATE_ALWAYS
76 // base::PLATFORM_FILE_WRITE 75 // base::PLATFORM_FILE_WRITE
77 // base::PLATFORM_FILE_TEMPORARY. 76 // base::PLATFORM_FILE_TEMPORARY.
78 // Set |additional_file_flags| to 0 for synchronous writes and set to 77 // Set |additional_file_flags| to 0 for synchronous writes and set to
79 // base::PLATFORM_FILE_ASYNC to support asynchronous file operations. 78 // base::PLATFORM_FILE_ASYNC to support asynchronous file operations.
80 static bool CreateTemporary( 79 static bool CreateTemporary(
81 scoped_refptr<MessageLoopProxy> message_loop_proxy, 80 scoped_refptr<MessageLoopProxy> message_loop_proxy,
82 int additional_file_flags, 81 int additional_file_flags,
83 const CreateTemporaryCallback& callback); 82 const CreateTemporaryCallback& callback);
84 83
85 // Close the given file handle. 84 // Close the given file handle.
86 static bool Close(scoped_refptr<MessageLoopProxy> message_loop_proxy, 85 static bool Close(scoped_refptr<MessageLoopProxy> message_loop_proxy,
87 PlatformFile, 86 PlatformFile,
88 StatusCallback* callback); 87 StatusCallback* callback);
89 88
90 // Ensures that the given |file_path| exist. This creates a empty new file 89 // Ensures that the given |file_path| exist. This creates a empty new file
91 // at |file_path| if the |file_path| does not exist. 90 // at |file_path| if the |file_path| does not exist.
92 // If a new file han not existed and is created at the |file_path|, 91 // If a new file does not exist and is created at the |file_path|, |created|
93 // |created| of the callback argument is set true and |error code| 92 // of the callback argument is set true and |error code| is set
94 // is set PLATFORM_FILE_OK. 93 // PLATFORM_FILE_OK. If the file already exists, |created| is set false and
95 // If the file already exists, |created| is set false and |error code| 94 // |error code| is set PLATFORM_FILE_OK. If the file hasn't existed but it
96 // is set PLATFORM_FILE_OK. 95 // couldn't be created for some other reasons, |created| is set false and
97 // If the file hasn't existed but it couldn't be created for some other 96 // |error code| indicates the error.
98 // reasons, |created| is set false and |error code| indicates the error.
99 static bool EnsureFileExists( 97 static bool EnsureFileExists(
100 scoped_refptr<MessageLoopProxy> message_loop_proxy, 98 scoped_refptr<MessageLoopProxy> message_loop_proxy,
101 const FilePath& file_path, 99 const FilePath& file_path,
102 const EnsureFileExistsCallback& callback); 100 const EnsureFileExistsCallback& callback);
103 101
104 // Retrieves the information about a file. It is invalid to pass NULL for the 102 // Retrieves the information about a file. It is invalid to pass a null
105 // callback. 103 // callback.
106 static bool GetFileInfo( 104 static bool GetFileInfo(
107 scoped_refptr<MessageLoopProxy> message_loop_proxy, 105 scoped_refptr<MessageLoopProxy> message_loop_proxy,
108 const FilePath& file_path, 106 const FilePath& file_path,
109 const GetFileInfoCallback& callback); 107 const GetFileInfoCallback& callback);
110 108
111 static bool GetFileInfoFromPlatformFile( 109 static bool GetFileInfoFromPlatformFile(
112 scoped_refptr<MessageLoopProxy> message_loop_proxy, 110 scoped_refptr<MessageLoopProxy> message_loop_proxy,
113 PlatformFile file, 111 PlatformFile file,
114 const GetFileInfoCallback& callback); 112 const GetFileInfoCallback& callback);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 bool recursive, 152 bool recursive,
155 StatusCallback* callback); 153 StatusCallback* callback);
156 154
157 // Deletes a directory and all of its contents. 155 // Deletes a directory and all of its contents.
158 static bool RecursiveDelete( 156 static bool RecursiveDelete(
159 scoped_refptr<MessageLoopProxy> message_loop_proxy, 157 scoped_refptr<MessageLoopProxy> message_loop_proxy,
160 const FilePath& file_path, 158 const FilePath& file_path,
161 StatusCallback* callback); 159 StatusCallback* callback);
162 160
163 // Reads from a file. On success, the file pointer is moved to position 161 // Reads from a file. On success, the file pointer is moved to position
164 // |offset + bytes_to_read| in the file. The callback can be NULL. 162 // |offset + bytes_to_read| in the file. The callback can be null.
165 static bool Read( 163 static bool Read(
166 scoped_refptr<MessageLoopProxy> message_loop_proxy, 164 scoped_refptr<MessageLoopProxy> message_loop_proxy,
167 PlatformFile file, 165 PlatformFile file,
168 int64 offset, 166 int64 offset,
169 int bytes_to_read, 167 int bytes_to_read,
170 ReadCallback* callback); 168 const ReadCallback& callback);
171 169
172 // Writes to a file. If |offset| is greater than the length of the file, 170 // Writes to a file. If |offset| is greater than the length of the file,
173 // |false| is returned. On success, the file pointer is moved to position 171 // |false| is returned. On success, the file pointer is moved to position
174 // |offset + bytes_to_write| in the file. The callback can be NULL. 172 // |offset + bytes_to_write| in the file. The callback can be NULL.
175 // |bytes_to_write| must be greater than zero. 173 // |bytes_to_write| must be greater than zero.
176 static bool Write( 174 static bool Write(
177 scoped_refptr<MessageLoopProxy> message_loop_proxy, 175 scoped_refptr<MessageLoopProxy> message_loop_proxy,
178 PlatformFile file, 176 PlatformFile file,
179 int64 offset, 177 int64 offset,
180 const char* buffer, 178 const char* buffer,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 PlatformFile file, 219 PlatformFile file,
222 StatusCallback* callback); 220 StatusCallback* callback);
223 221
224 private: 222 private:
225 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); 223 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy);
226 }; 224 };
227 225
228 } // namespace base 226 } // namespace base
229 227
230 #endif // BASE_FILE_UTIL_PROXY_H_ 228 #endif // BASE_FILE_UTIL_PROXY_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698