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