1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
// Copyright (c) 2012 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_FILE_SYSTEM_FILE_UTIL_PROXY_H_
#define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
#include "base/callback.h"
#include "base/file_path.h"
#include "base/files/file_util_proxy.h"
#include "base/platform_file.h"
#include "webkit/fileapi/file_system_file_util.h"
#include "webkit/fileapi/file_system_operation.h"
namespace fileapi {
class FileSystemFileUtil;
class FileSystemOperationContext;
class FileSystemURL;
// This class provides asynchronous access to FileSystemFileUtil methods for
// FileSystem API operations. This also implements cross-FileUtil copy/move
// operations on top of FileSystemFileUtil methods.
class FileSystemFileUtilProxy {
public:
// Some of the proxy routines are just wrapping around the FileUtilProxy's
// relay methods, so we use the same types as FileUtilProxy for them.
typedef base::FileUtilProxy::Entry Entry;
typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback;
typedef base::Callback<void(base::PlatformFileError status)> StatusCallback;
typedef base::Callback<void(base::PlatformFileError status,
bool created)> EnsureFileExistsCallback;
typedef FileSystemOperation::GetMetadataCallback GetFileInfoCallback;
typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback;
typedef base::Callback<
void(base::PlatformFileError result,
const base::PlatformFileInfo& file_info,
const base::FilePath& platform_path,
FileSystemFileUtil::SnapshotFilePolicy snapshot_policy)>
SnapshotFileCallback;
// Deletes a file on the given context's task_runner.
static bool DeleteFile(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const StatusCallback& callback);
// Deletes a directory on the given context's task_runner.
static bool DeleteDirectory(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const StatusCallback& callback);
// Creates or opens a file with the given flags by calling |file_util|'s
// CreateOrOpen method on the given context's task_runner.
static bool CreateOrOpen(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
int file_flags,
const CreateOrOpenCallback& callback);
// Copies a local file or a directory from |src_url| to |dest_url|.
static bool CopyFileLocal(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback);
// Moves a local file or a directory from |src_url| to |dest_url|.
static bool MoveFileLocal(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback);
// Copies a file from local disk to the given filesystem destination.
// Primarily used for the Syncable filesystem type (e.g. Drive).
static bool CopyInForeignFile(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const base::FilePath& src_local_disk_file_path,
const FileSystemURL& dest_url,
const StatusCallback& callback);
// Ensures that the given |url| exist by calling |file_util|'s
// EnsureFileExists method on the given context's task_runner.
static bool EnsureFileExists(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const EnsureFileExistsCallback& callback);
// Creates directory at a given url by calling |file_util|'s
// CreateDirectory method on the given context's task_runner.
static bool CreateDirectory(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
bool exclusive,
bool recursive,
const StatusCallback& callback);
// Retrieves the information about a file by calling |file_util|'s
// GetFileInfo method on the given context's task_runner.
static bool GetFileInfo(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const GetFileInfoCallback& callback);
// Creates a snapshot file by calling |file_util|'s CreateSnapshotFile
// method on the given context's task_runner.
static bool CreateSnapshotFile(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const SnapshotFileCallback& callback);
// Reads the filenames in |url| by calling |file_util|'s
// ReadDirectory method on the given context's task_runner.
// TODO(kinuko): this should support returning entries in multiple chunks.
// (http://crbug.com/145908)
static bool ReadDirectory(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const ReadDirectoryCallback& callback);
// Touches a file by calling |file_util|'s Touch method
// on the given context's task_runner.
static bool Touch(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback);
// Truncates a file to the given length by calling |file_util|'s
// Truncate method on the given context's task_runner.
static bool Truncate(
FileSystemOperationContext* context,
FileSystemFileUtil* file_util,
const FileSystemURL& url,
int64 length,
const StatusCallback& callback);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy);
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
|