| OLD | NEW |
| 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_FILE_UTIL_PROXY_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/callback_old.h" |
| 11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 12 #include "base/file_util_proxy.h" | 13 #include "base/file_util_proxy.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 15 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class MessageLoopProxy; | 19 class MessageLoopProxy; |
| 19 class Time; | 20 class Time; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace fileapi { | 23 namespace fileapi { |
| 23 | 24 |
| 24 class FileSystemOperationContext; | 25 class FileSystemOperationContext; |
| 25 | 26 |
| 26 using base::MessageLoopProxy; | 27 using base::MessageLoopProxy; |
| 27 using base::PlatformFile; | 28 using base::PlatformFile; |
| 28 using base::PlatformFileError; | 29 using base::PlatformFileError; |
| 29 using base::PlatformFileInfo; | 30 using base::PlatformFileInfo; |
| 30 | 31 |
| 31 // This class provides asynchronous access to common file routines for the | 32 // This class provides asynchronous access to common file routines for the |
| 32 // FileSystem API. | 33 // FileSystem API. |
| 33 class FileSystemFileUtilProxy { | 34 class FileSystemFileUtilProxy { |
| 34 public: | 35 public: |
| 35 typedef base::FileUtilProxy::StatusCallback StatusCallback; | 36 typedef base::FileUtilProxy::StatusCallback StatusCallback; |
| 36 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; | 37 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; |
| 37 typedef base::FileUtilProxy::EnsureFileExistsCallback | 38 typedef base::FileUtilProxy::EnsureFileExistsCallback |
| 38 EnsureFileExistsCallback; | 39 EnsureFileExistsCallback; |
| 39 typedef Callback3<PlatformFileError /* error code */, | 40 typedef base::Callback< |
| 40 const PlatformFileInfo& /* file_info */, | 41 void(PlatformFileError /* error code */, |
| 41 const FilePath& /* platform_path, where possible */ | 42 const PlatformFileInfo& /* file_info */, |
| 42 >::Type GetFileInfoCallback; | 43 const FilePath& /* platform_path, where possible */)> |
| 44 GetFileInfoCallback; |
| 43 typedef Callback2<PlatformFileError /* error code */, | 45 typedef Callback2<PlatformFileError /* error code */, |
| 44 const FilePath& /* local_path, where possible */ | 46 const FilePath& /* local_path, where possible */ |
| 45 >::Type GetLocalPathCallback; | 47 >::Type GetLocalPathCallback; |
| 46 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; | 48 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; |
| 47 | 49 |
| 48 // Creates or opens a file with the given flags. It is invalid to pass NULL | 50 // Creates or opens a file with the given flags. It is invalid to pass NULL |
| 49 // for the callback. | 51 // for the callback. |
| 50 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create | 52 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create |
| 51 // a new file at the given |file_path| and calls back with | 53 // a new file at the given |file_path| and calls back with |
| 52 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | 54 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 83 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 85 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 84 const FilePath& virtual_path, | 86 const FilePath& virtual_path, |
| 85 GetLocalPathCallback* callback); | 87 GetLocalPathCallback* callback); |
| 86 | 88 |
| 87 // Retrieves the information about a file. It is invalid to pass NULL for the | 89 // Retrieves the information about a file. It is invalid to pass NULL for the |
| 88 // callback. | 90 // callback. |
| 89 static bool GetFileInfo( | 91 static bool GetFileInfo( |
| 90 const FileSystemOperationContext& context, | 92 const FileSystemOperationContext& context, |
| 91 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 93 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 92 const FilePath& file_path, | 94 const FilePath& file_path, |
| 93 GetFileInfoCallback* callback); | 95 const GetFileInfoCallback& callback); |
| 94 | 96 |
| 95 static bool ReadDirectory(const FileSystemOperationContext& context, | 97 static bool ReadDirectory(const FileSystemOperationContext& context, |
| 96 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 98 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 97 const FilePath& file_path, | 99 const FilePath& file_path, |
| 98 ReadDirectoryCallback* callback); | 100 ReadDirectoryCallback* callback); |
| 99 | 101 |
| 100 // Creates directory at given path. It's an error to create | 102 // Creates directory at given path. It's an error to create |
| 101 // if |exclusive| is true and dir already exists. | 103 // if |exclusive| is true and dir already exists. |
| 102 static bool CreateDirectory( | 104 static bool CreateDirectory( |
| 103 const FileSystemOperationContext& context, | 105 const FileSystemOperationContext& context, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 int64 length, | 159 int64 length, |
| 158 StatusCallback* callback); | 160 StatusCallback* callback); |
| 159 | 161 |
| 160 private: | 162 private: |
| 161 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 163 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 } // namespace fileapi | 166 } // namespace fileapi |
| 165 | 167 |
| 166 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 168 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| OLD | NEW |