summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/async_file_test_helper.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 11:46:30 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 11:46:30 +0000
commit07b64878754a4eac0541b8a9d68e9608c148f7df (patch)
tree1775b7e79b6748ba893bf2c251bd1e86e7e0ec7e /webkit/fileapi/async_file_test_helper.h
parentf9c63abac8f48ecf6def9cbb9c895deb9927c92c (diff)
downloadchromium_src-07b64878754a4eac0541b8a9d68e9608c148f7df.zip
chromium_src-07b64878754a4eac0541b8a9d68e9608c148f7df.tar.gz
chromium_src-07b64878754a4eac0541b8a9d68e9608c148f7df.tar.bz2
Retry: Introduce AsyncFileTestHelper for testing with async file/quota operations
Also gradually deprecate FileUtilHelper since its code is no longer used in the actual code path (used only in unittests). Original review (with lgtm): https://codereview.chromium.org/12223006/ No changes made from the original review (the link error should be gone now by other gypi change that is already landed) BUG=146215 TEST=content_unittests:LocalFileSystem* TBR=jam, tzik, tbarzic (original reviewers) Review URL: https://codereview.chromium.org/12209068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/async_file_test_helper.h')
-rw-r--r--webkit/fileapi/async_file_test_helper.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/webkit/fileapi/async_file_test_helper.h b/webkit/fileapi/async_file_test_helper.h
new file mode 100644
index 0000000..9955b40
--- /dev/null
+++ b/webkit/fileapi/async_file_test_helper.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_ASYNC_FILE_TEST_HELPER_H_
+#define WEBKIT_FILEAPI_ASYNC_FILE_TEST_HELPER_H_
+
+#include "base/basictypes.h"
+#include "webkit/fileapi/file_system_operation.h"
+#include "webkit/fileapi/file_system_types.h"
+#include "webkit/quota/quota_status_code.h"
+
+namespace quota {
+class QuotaManager;
+}
+
+namespace fileapi {
+
+class FileSystemContext;
+class FileSystemURL;
+
+// A helper class to perform async file operations in a synchronous way.
+class AsyncFileTestHelper {
+ public:
+ typedef FileSystemOperation::FileEntryList FileEntryList;
+
+ static const int64 kDontCheckSize;
+
+ // Performs Copy from |src| to |dest| and returns the status code.
+ static base::PlatformFileError Copy(FileSystemContext* context,
+ const FileSystemURL& src,
+ const FileSystemURL& dest);
+
+ // Performs Move from |src| to |dest| and returns the status code.
+ static base::PlatformFileError Move(FileSystemContext* context,
+ const FileSystemURL& src,
+ const FileSystemURL& dest);
+
+ // Removes the given |url|.
+ static base::PlatformFileError Remove(FileSystemContext* context,
+ const FileSystemURL& url,
+ bool recursive);
+
+ // Performs ReadDirectory on |url|.
+ static base::PlatformFileError ReadDirectory(FileSystemContext* context,
+ const FileSystemURL& url,
+ FileEntryList* entries);
+
+ // Creates a directory at |url|.
+ static base::PlatformFileError CreateDirectory(FileSystemContext* context,
+ const FileSystemURL& url);
+
+ // Creates a file at |url|.
+ static base::PlatformFileError CreateFile(FileSystemContext* context,
+ const FileSystemURL& url);
+
+ // Truncates the file |url| to |size|.
+ static base::PlatformFileError TruncateFile(FileSystemContext* context,
+ const FileSystemURL& url,
+ size_t size);
+
+ // Retrieves PlatformFileInfo for |url| and populates |file_info|.
+ static base::PlatformFileError GetMetadata(FileSystemContext* context,
+ const FileSystemURL& url,
+ base::PlatformFileInfo* file_info,
+ base::FilePath* platform_path);
+
+ // Returns true if a file exists at |url| with |size|. If |size| is
+ // kDontCheckSize it doesn't check the file size (but just check its
+ // existence).
+ static bool FileExists(FileSystemContext* context,
+ const FileSystemURL& url,
+ int64 size);
+
+ // Returns true if a directory exists at |url|.
+ static bool DirectoryExists(FileSystemContext* context,
+ const FileSystemURL& url);
+
+ // Returns usage and quota. It's valid to pass NULL to |usage| and/or |quota|.
+ static quota::QuotaStatusCode GetUsageAndQuota(
+ quota::QuotaManager* quota_manager,
+ const GURL& origin,
+ FileSystemType type,
+ int64* usage,
+ int64* quota);
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_FILEAPI_ASYNC_FILE_TEST_HELPER_H_