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

Side by Side Diff: base/file_util_proxy.h

Issue 8311010: base::Bind: Convert FileUtilProxy::CreateOrOpenCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
11 #include "base/callback.h"
11 #include "base/callback_old.h" 12 #include "base/callback_old.h"
12 #include "base/file_path.h" 13 #include "base/file_path.h"
13 #include "base/file_util.h" 14 #include "base/file_util.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/platform_file.h" 16 #include "base/platform_file.h"
16 #include "base/tracked_objects.h" 17 #include "base/tracked_objects.h"
17 18
18 namespace base { 19 namespace base {
19 20
20 class MessageLoopProxy; 21 class MessageLoopProxy;
(...skipping 10 matching lines...) Expand all
31 base::Time last_modified_time; 32 base::Time last_modified_time;
32 }; 33 };
33 34
34 // This callback is used by methods that report only an error code. It is 35 // This callback is used by methods that report only an error code. It is
35 // valid to pass NULL as the callback parameter to any function that takes a 36 // valid to pass NULL as the callback parameter to any function that takes a
36 // StatusCallback, in which case the operation will complete silently. 37 // StatusCallback, in which case the operation will complete silently.
37 // The ownership of |callback| is taken by the function and will always be 38 // The ownership of |callback| is taken by the function and will always be
38 // deleted by the function even on failure. 39 // deleted by the function even on failure.
39 typedef Callback1<PlatformFileError /* error code */>::Type StatusCallback; 40 typedef Callback1<PlatformFileError /* error code */>::Type StatusCallback;
40 41
41 typedef Callback3<PlatformFileError /* error code */, 42 typedef base::Callback<void(PlatformFileError /* error code */,
42 PassPlatformFile, 43 PassPlatformFile,
43 bool /* created */>::Type CreateOrOpenCallback; 44 bool /* created */)> CreateOrOpenCallback;
44 typedef Callback3<PlatformFileError /* error code */, 45 typedef Callback3<PlatformFileError /* error code */,
45 PassPlatformFile, 46 PassPlatformFile,
46 FilePath>::Type CreateTemporaryCallback; 47 FilePath>::Type CreateTemporaryCallback;
47 typedef Callback2<PlatformFileError /* error code */, 48 typedef Callback2<PlatformFileError /* error code */,
48 bool /* created */>::Type EnsureFileExistsCallback; 49 bool /* created */>::Type EnsureFileExistsCallback;
49 typedef Callback2<PlatformFileError /* error code */, 50 typedef Callback2<PlatformFileError /* error code */,
50 const PlatformFileInfo& /* file_info */ 51 const PlatformFileInfo& /* file_info */
51 >::Type GetFileInfoCallback; 52 >::Type GetFileInfoCallback;
52 typedef Callback2<PlatformFileError /* error code */, 53 typedef Callback2<PlatformFileError /* error code */,
53 const std::vector<Entry>&>::Type ReadDirectoryCallback; 54 const std::vector<Entry>&>::Type ReadDirectoryCallback;
54 typedef Callback3<PlatformFileError /* error code */, 55 typedef Callback3<PlatformFileError /* error code */,
55 const char* /* data */, 56 const char* /* data */,
56 int /* bytes read/written */>::Type ReadCallback; 57 int /* bytes read/written */>::Type ReadCallback;
57 typedef Callback2<PlatformFileError /* error code */, 58 typedef Callback2<PlatformFileError /* error code */,
58 int /* bytes written */>::Type WriteCallback; 59 int /* bytes written */>::Type WriteCallback;
59 60
60 // 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 NULL
61 // for the callback. 62 // for the callback.
62 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create 63 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
63 // 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. 65 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
65 // Takes ownership of |callback| and will delete it even on failure. 66 // Takes ownership of |callback| and will delete it even on failure.
66 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, 67 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy,
67 const FilePath& file_path, 68 const FilePath& file_path,
68 int file_flags, 69 int file_flags,
69 CreateOrOpenCallback* callback); 70 const CreateOrOpenCallback& callback);
70 71
71 // Creates a temporary file for writing. The path and an open file handle 72 // Creates a temporary file for writing. The path and an open file handle
72 // are returned. It is invalid to pass NULL for the callback. The additional 73 // are returned. It is invalid to pass NULL for the callback. The additional
73 // file flags will be added on top of the default file flags which are: 74 // file flags will be added on top of the default file flags which are:
74 // base::PLATFORM_FILE_CREATE_ALWAYS 75 // base::PLATFORM_FILE_CREATE_ALWAYS
75 // base::PLATFORM_FILE_WRITE 76 // base::PLATFORM_FILE_WRITE
76 // base::PLATFORM_FILE_TEMPORARY. 77 // base::PLATFORM_FILE_TEMPORARY.
77 // Set |additional_file_flags| to 0 for synchronous writes and set to 78 // Set |additional_file_flags| to 0 for synchronous writes and set to
78 // base::PLATFORM_FILE_ASYNC to support asynchronous file operations. 79 // base::PLATFORM_FILE_ASYNC to support asynchronous file operations.
79 static bool CreateTemporary( 80 static bool CreateTemporary(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 PlatformFile file, 221 PlatformFile file,
221 StatusCallback* callback); 222 StatusCallback* callback);
222 223
223 private: 224 private:
224 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); 225 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy);
225 }; 226 };
226 227
227 } // namespace base 228 } // namespace base
228 229
229 #endif // BASE_FILE_UTIL_PROXY_H_ 230 #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