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