blob: 514c46100c56ce3d1ddea62ea384ce5442c95b1f [file] [log] [blame]
[email protected]4c03b2e92012-01-03 19:36:571// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]d5233ef42011-03-04 04:14:042// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
6#define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
7
8#include <vector>
9
10#include "base/callback.h"
11#include "base/file_path.h"
12#include "base/file_util_proxy.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/ref_counted.h"
[email protected]d5233ef42011-03-04 04:14:0414#include "base/platform_file.h"
[email protected]d5233ef42011-03-04 04:14:0415#include "base/tracked_objects.h"
16
17namespace base {
18class MessageLoopProxy;
[email protected]d5233ef42011-03-04 04:14:0419}
20
21namespace fileapi {
22
[email protected]d5233ef42011-03-04 04:14:0423using base::MessageLoopProxy;
24using base::PlatformFile;
[email protected]bacef3c2011-03-28 22:26:5025using base::PlatformFileError;
26using base::PlatformFileInfo;
[email protected]d5233ef42011-03-04 04:14:0427
[email protected]fea88cd2011-11-09 06:57:3028// This class provides relay methods for supporting asynchronous access to
29// FileSystem API operations. (Most of necessary relay methods are provided
30// by base::FileUtilProxy, but there are a few operations that are not
31// covered or are slightly different from the version of base::FileUtilProxy.
[email protected]d5233ef42011-03-04 04:14:0432class FileSystemFileUtilProxy {
33 public:
[email protected]0a3bd7e2011-10-19 07:21:5734 typedef base::FileUtilProxy::Entry Entry;
35
[email protected]0a3bd7e2011-10-19 07:21:5736 typedef base::Callback<void(PlatformFileError,
37 bool /* created */
38 )> EnsureFileExistsCallback;
39 typedef base::Callback<void(PlatformFileError,
40 const PlatformFileInfo&,
41 const FilePath& /* platform_path */
42 )> GetFileInfoCallback;
43 typedef base::Callback<void(PlatformFileError,
[email protected]bf48bed2012-02-24 20:49:0744 const std::vector<Entry>&,
45 bool has_more)> ReadDirectoryCallback;
[email protected]0a3bd7e2011-10-19 07:21:5746
[email protected]fea88cd2011-11-09 06:57:3047 typedef base::Callback<PlatformFileError(bool* /* created */
48 )> EnsureFileExistsTask;
49 typedef base::Callback<PlatformFileError(PlatformFileInfo*,
50 FilePath*)> GetFileInfoTask;
51 typedef base::Callback<PlatformFileError(std::vector<Entry>*
52 )> ReadDirectoryTask;
53
54 // Calls EnsureFileExistsTask |task| on the given |message_loop_proxy|.
55 static bool RelayEnsureFileExists(
[email protected]d5233ef42011-03-04 04:14:0456 scoped_refptr<MessageLoopProxy> message_loop_proxy,
[email protected]fea88cd2011-11-09 06:57:3057 const EnsureFileExistsTask& task,
[email protected]f1ef8d42011-10-17 19:39:5958 const EnsureFileExistsCallback& callback);
[email protected]d5233ef42011-03-04 04:14:0459
[email protected]fea88cd2011-11-09 06:57:3060 // Calls GetFileInfoTask |task| on the given |message_loop_proxy|.
61 static bool RelayGetFileInfo(
[email protected]d5233ef42011-03-04 04:14:0462 scoped_refptr<MessageLoopProxy> message_loop_proxy,
[email protected]fea88cd2011-11-09 06:57:3063 const GetFileInfoTask& task,
[email protected]0f695a72011-10-17 20:12:0564 const GetFileInfoCallback& callback);
[email protected]d5233ef42011-03-04 04:14:0465
[email protected]fea88cd2011-11-09 06:57:3066 // Calls ReadDirectoryTask |task| on the given |message_loop_proxy|.
67 // TODO: this should support returning entries in multiple chunks.
68 static bool RelayReadDirectory(
69 scoped_refptr<MessageLoopProxy> message_loop_proxy,
70 const ReadDirectoryTask& task,
71 const ReadDirectoryCallback& callback);
[email protected]d5233ef42011-03-04 04:14:0472
[email protected]d5233ef42011-03-04 04:14:0473 private:
74 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy);
75};
76
77} // namespace fileapi
78
79#endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_