| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "webkit/browser/fileapi/file_system_operation.h" | 9 #include "webkit/browser/fileapi/file_system_operation.h" |
| 10 #include "webkit/common/fileapi/file_system_types.h" | 10 #include "webkit/common/fileapi/file_system_types.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // A helper class to perform async file operations in a synchronous way. | 22 // A helper class to perform async file operations in a synchronous way. |
| 23 class AsyncFileTestHelper { | 23 class AsyncFileTestHelper { |
| 24 public: | 24 public: |
| 25 typedef FileSystemOperation::FileEntryList FileEntryList; | 25 typedef FileSystemOperation::FileEntryList FileEntryList; |
| 26 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback; | 26 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback; |
| 27 | 27 |
| 28 static const int64 kDontCheckSize; | 28 static const int64 kDontCheckSize; |
| 29 | 29 |
| 30 // Performs Copy from |src| to |dest| and returns the status code. | 30 // Performs Copy from |src| to |dest| and returns the status code. |
| 31 static base::PlatformFileError Copy(FileSystemContext* context, | 31 static base::File::Error Copy(FileSystemContext* context, |
| 32 const FileSystemURL& src, | 32 const FileSystemURL& src, |
| 33 const FileSystemURL& dest); | 33 const FileSystemURL& dest); |
| 34 | 34 |
| 35 // Same as Copy, but this supports |progress_callback|. | 35 // Same as Copy, but this supports |progress_callback|. |
| 36 static base::PlatformFileError CopyWithProgress( | 36 static base::File::Error CopyWithProgress( |
| 37 FileSystemContext* context, | 37 FileSystemContext* context, |
| 38 const FileSystemURL& src, | 38 const FileSystemURL& src, |
| 39 const FileSystemURL& dest, | 39 const FileSystemURL& dest, |
| 40 const CopyProgressCallback& progress_callback); | 40 const CopyProgressCallback& progress_callback); |
| 41 | 41 |
| 42 // Performs Move from |src| to |dest| and returns the status code. | 42 // Performs Move from |src| to |dest| and returns the status code. |
| 43 static base::PlatformFileError Move(FileSystemContext* context, | 43 static base::File::Error Move(FileSystemContext* context, |
| 44 const FileSystemURL& src, | 44 const FileSystemURL& src, |
| 45 const FileSystemURL& dest); | 45 const FileSystemURL& dest); |
| 46 | 46 |
| 47 // Removes the given |url|. | 47 // Removes the given |url|. |
| 48 static base::PlatformFileError Remove(FileSystemContext* context, | 48 static base::File::Error Remove(FileSystemContext* context, |
| 49 const FileSystemURL& url, | 49 const FileSystemURL& url, |
| 50 bool recursive); | 50 bool recursive); |
| 51 | 51 |
| 52 // Performs ReadDirectory on |url|. | 52 // Performs ReadDirectory on |url|. |
| 53 static base::PlatformFileError ReadDirectory(FileSystemContext* context, | 53 static base::File::Error ReadDirectory(FileSystemContext* context, |
| 54 const FileSystemURL& url, | 54 const FileSystemURL& url, |
| 55 FileEntryList* entries); | 55 FileEntryList* entries); |
| 56 | 56 |
| 57 // Creates a directory at |url|. | 57 // Creates a directory at |url|. |
| 58 static base::PlatformFileError CreateDirectory(FileSystemContext* context, | 58 static base::File::Error CreateDirectory(FileSystemContext* context, |
| 59 const FileSystemURL& url); | 59 const FileSystemURL& url); |
| 60 | 60 |
| 61 // Creates a file at |url|. | 61 // Creates a file at |url|. |
| 62 static base::PlatformFileError CreateFile(FileSystemContext* context, | 62 static base::File::Error CreateFile(FileSystemContext* context, |
| 63 const FileSystemURL& url); | 63 const FileSystemURL& url); |
| 64 | 64 |
| 65 // Creates a file at |url| and fills with |buf|. | 65 // Creates a file at |url| and fills with |buf|. |
| 66 static base::PlatformFileError CreateFileWithData( | 66 static base::File::Error CreateFileWithData( |
| 67 FileSystemContext* context, | 67 FileSystemContext* context, |
| 68 const FileSystemURL& url, | 68 const FileSystemURL& url, |
| 69 const char* buf, | 69 const char* buf, |
| 70 int buf_size); | 70 int buf_size); |
| 71 | 71 |
| 72 // Truncates the file |url| to |size|. | 72 // Truncates the file |url| to |size|. |
| 73 static base::PlatformFileError TruncateFile(FileSystemContext* context, | 73 static base::File::Error TruncateFile(FileSystemContext* context, |
| 74 const FileSystemURL& url, | 74 const FileSystemURL& url, |
| 75 size_t size); | 75 size_t size); |
| 76 | 76 |
| 77 // Retrieves PlatformFileInfo for |url| and populates |file_info|. | 77 // Retrieves File::Info for |url| and populates |file_info|. |
| 78 static base::PlatformFileError GetMetadata(FileSystemContext* context, | 78 static base::File::Error GetMetadata(FileSystemContext* context, |
| 79 const FileSystemURL& url, | 79 const FileSystemURL& url, |
| 80 base::PlatformFileInfo* file_info); | 80 base::File::Info* file_info); |
| 81 | 81 |
| 82 // Retrieves FilePath for |url| and populates |platform_path|. | 82 // Retrieves FilePath for |url| and populates |platform_path|. |
| 83 static base::PlatformFileError GetPlatformPath(FileSystemContext* context, | 83 static base::File::Error GetPlatformPath(FileSystemContext* context, |
| 84 const FileSystemURL& url, | 84 const FileSystemURL& url, |
| 85 base::FilePath* platform_path); | 85 base::FilePath* platform_path); |
| 86 | 86 |
| 87 // Returns true if a file exists at |url| with |size|. If |size| is | 87 // Returns true if a file exists at |url| with |size|. If |size| is |
| 88 // kDontCheckSize it doesn't check the file size (but just check its | 88 // kDontCheckSize it doesn't check the file size (but just check its |
| 89 // existence). | 89 // existence). |
| 90 static bool FileExists(FileSystemContext* context, | 90 static bool FileExists(FileSystemContext* context, |
| 91 const FileSystemURL& url, | 91 const FileSystemURL& url, |
| 92 int64 size); | 92 int64 size); |
| 93 | 93 |
| 94 // Returns true if a directory exists at |url|. | 94 // Returns true if a directory exists at |url|. |
| 95 static bool DirectoryExists(FileSystemContext* context, | 95 static bool DirectoryExists(FileSystemContext* context, |
| 96 const FileSystemURL& url); | 96 const FileSystemURL& url); |
| 97 | 97 |
| 98 // Returns usage and quota. It's valid to pass NULL to |usage| and/or |quota|. | 98 // Returns usage and quota. It's valid to pass NULL to |usage| and/or |quota|. |
| 99 static quota::QuotaStatusCode GetUsageAndQuota( | 99 static quota::QuotaStatusCode GetUsageAndQuota( |
| 100 quota::QuotaManager* quota_manager, | 100 quota::QuotaManager* quota_manager, |
| 101 const GURL& origin, | 101 const GURL& origin, |
| 102 FileSystemType type, | 102 FileSystemType type, |
| 103 int64* usage, | 103 int64* usage, |
| 104 int64* quota); | 104 int64* quota); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace fileapi | 107 } // namespace fileapi |
| 108 | 108 |
| 109 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ | 109 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_ |
| OLD | NEW |